1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.call = call;
|
7 | exports.default = void 0;
|
8 | exports.note = note;
|
9 | exports.noteOnce = noteOnce;
|
10 | exports.preMessage = void 0;
|
11 | exports.resetWarned = resetWarned;
|
12 | exports.warning = warning;
|
13 | exports.warningOnce = warningOnce;
|
14 |
|
15 | var warned = {};
|
16 | var preWarningFns = [];
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | var preMessage = exports.preMessage = function preMessage(fn) {
|
23 | preWarningFns.push(fn);
|
24 | };
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | function warning(valid, message) {
|
38 | if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
39 | var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
40 | return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'warning');
|
41 | }, message);
|
42 | if (finalMessage) {
|
43 | console.error("Warning: ".concat(finalMessage));
|
44 | }
|
45 | }
|
46 | }
|
47 |
|
48 |
|
49 | function note(valid, message) {
|
50 | if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
51 | var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
52 | return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'note');
|
53 | }, message);
|
54 | if (finalMessage) {
|
55 | console.warn("Note: ".concat(finalMessage));
|
56 | }
|
57 | }
|
58 | }
|
59 | function resetWarned() {
|
60 | warned = {};
|
61 | }
|
62 | function call(method, valid, message) {
|
63 | if (!valid && !warned[message]) {
|
64 | method(false, message);
|
65 | warned[message] = true;
|
66 | }
|
67 | }
|
68 |
|
69 |
|
70 | function warningOnce(valid, message) {
|
71 | call(warning, valid, message);
|
72 | }
|
73 |
|
74 |
|
75 | function noteOnce(valid, message) {
|
76 | call(note, valid, message);
|
77 | }
|
78 | warningOnce.preMessage = preMessage;
|
79 | warningOnce.resetWarned = resetWarned;
|
80 | warningOnce.noteOnce = noteOnce;
|
81 | var _default = exports.default = warningOnce; |
\ | No newline at end of file |