1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | (function (global, factory) {
|
13 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
14 | typeof define === 'function' && define.amd ? define(factory) :
|
15 | (global.React = factory());
|
16 | }(this, (function () { 'use strict';
|
17 |
|
18 |
|
19 |
|
20 | var ReactVersion = '16.7.0';
|
21 |
|
22 |
|
23 |
|
24 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
25 |
|
26 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
27 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
28 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
29 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
30 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
31 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
32 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
33 |
|
34 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
35 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
36 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
37 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
38 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
39 |
|
40 | var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
41 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
42 |
|
43 | function getIteratorFn(maybeIterable) {
|
44 | if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
45 | return null;
|
46 | }
|
47 | var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
48 | if (typeof maybeIterator === 'function') {
|
49 | return maybeIterator;
|
50 | }
|
51 | return null;
|
52 | }
|
53 |
|
54 | var enableHooks = false;
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | var enableSchedulerTracing = true;
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | var enableSchedulerDebugging = true;
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | var enableStableConcurrentModeAPIs = false;
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
103 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
104 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
105 |
|
106 | function toObject(val) {
|
107 | if (val === null || val === undefined) {
|
108 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
109 | }
|
110 |
|
111 | return Object(val);
|
112 | }
|
113 |
|
114 | function shouldUseNative() {
|
115 | try {
|
116 | if (!Object.assign) {
|
117 | return false;
|
118 | }
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | var test1 = new String('abc');
|
124 | test1[5] = 'de';
|
125 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
126 | return false;
|
127 | }
|
128 |
|
129 |
|
130 | var test2 = {};
|
131 | for (var i = 0; i < 10; i++) {
|
132 | test2['_' + String.fromCharCode(i)] = i;
|
133 | }
|
134 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
135 | return test2[n];
|
136 | });
|
137 | if (order2.join('') !== '0123456789') {
|
138 | return false;
|
139 | }
|
140 |
|
141 |
|
142 | var test3 = {};
|
143 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
144 | test3[letter] = letter;
|
145 | });
|
146 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
147 | 'abcdefghijklmnopqrst') {
|
148 | return false;
|
149 | }
|
150 |
|
151 | return true;
|
152 | } catch (err) {
|
153 |
|
154 | return false;
|
155 | }
|
156 | }
|
157 |
|
158 | var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
159 | var from;
|
160 | var to = toObject(target);
|
161 | var symbols;
|
162 |
|
163 | for (var s = 1; s < arguments.length; s++) {
|
164 | from = Object(arguments[s]);
|
165 |
|
166 | for (var key in from) {
|
167 | if (hasOwnProperty.call(from, key)) {
|
168 | to[key] = from[key];
|
169 | }
|
170 | }
|
171 |
|
172 | if (getOwnPropertySymbols) {
|
173 | symbols = getOwnPropertySymbols(from);
|
174 | for (var i = 0; i < symbols.length; i++) {
|
175 | if (propIsEnumerable.call(from, symbols[i])) {
|
176 | to[symbols[i]] = from[symbols[i]];
|
177 | }
|
178 | }
|
179 | }
|
180 | }
|
181 |
|
182 | return to;
|
183 | };
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 | var validateFormat = function () {};
|
197 |
|
198 | {
|
199 | validateFormat = function (format) {
|
200 | if (format === undefined) {
|
201 | throw new Error('invariant requires an error message argument');
|
202 | }
|
203 | };
|
204 | }
|
205 |
|
206 | function invariant(condition, format, a, b, c, d, e, f) {
|
207 | validateFormat(format);
|
208 |
|
209 | if (!condition) {
|
210 | var error = void 0;
|
211 | if (format === undefined) {
|
212 | error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
213 | } else {
|
214 | var args = [a, b, c, d, e, f];
|
215 | var argIndex = 0;
|
216 | error = new Error(format.replace(/%s/g, function () {
|
217 | return args[argIndex++];
|
218 | }));
|
219 | error.name = 'Invariant Violation';
|
220 | }
|
221 |
|
222 | error.framesToPop = 1;
|
223 | throw error;
|
224 | }
|
225 | }
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 | var lowPriorityWarning = function () {};
|
245 |
|
246 | {
|
247 | var printWarning = function (format) {
|
248 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
249 | args[_key - 1] = arguments[_key];
|
250 | }
|
251 |
|
252 | var argIndex = 0;
|
253 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
254 | return args[argIndex++];
|
255 | });
|
256 | if (typeof console !== 'undefined') {
|
257 | console.warn(message);
|
258 | }
|
259 | try {
|
260 |
|
261 |
|
262 |
|
263 | throw new Error(message);
|
264 | } catch (x) {}
|
265 | };
|
266 |
|
267 | lowPriorityWarning = function (condition, format) {
|
268 | if (format === undefined) {
|
269 | throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
270 | }
|
271 | if (!condition) {
|
272 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
273 | args[_key2 - 2] = arguments[_key2];
|
274 | }
|
275 |
|
276 | printWarning.apply(undefined, [format].concat(args));
|
277 | }
|
278 | };
|
279 | }
|
280 |
|
281 | var lowPriorityWarning$1 = lowPriorityWarning;
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | var warningWithoutStack = function () {};
|
291 |
|
292 | {
|
293 | warningWithoutStack = function (condition, format) {
|
294 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
295 | args[_key - 2] = arguments[_key];
|
296 | }
|
297 |
|
298 | if (format === undefined) {
|
299 | throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
300 | }
|
301 | if (args.length > 8) {
|
302 |
|
303 | throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
304 | }
|
305 | if (condition) {
|
306 | return;
|
307 | }
|
308 | if (typeof console !== 'undefined') {
|
309 | var argsWithFormat = args.map(function (item) {
|
310 | return '' + item;
|
311 | });
|
312 | argsWithFormat.unshift('Warning: ' + format);
|
313 |
|
314 |
|
315 |
|
316 | Function.prototype.apply.call(console.error, console, argsWithFormat);
|
317 | }
|
318 | try {
|
319 |
|
320 |
|
321 |
|
322 | var argIndex = 0;
|
323 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
324 | return args[argIndex++];
|
325 | });
|
326 | throw new Error(message);
|
327 | } catch (x) {}
|
328 | };
|
329 | }
|
330 |
|
331 | var warningWithoutStack$1 = warningWithoutStack;
|
332 |
|
333 | var didWarnStateUpdateForUnmountedComponent = {};
|
334 |
|
335 | function warnNoop(publicInstance, callerName) {
|
336 | {
|
337 | var _constructor = publicInstance.constructor;
|
338 | var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
339 | var warningKey = componentName + '.' + callerName;
|
340 | if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
341 | return;
|
342 | }
|
343 | warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
|
344 | didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
345 | }
|
346 | }
|
347 |
|
348 |
|
349 |
|
350 |
|
351 | var ReactNoopUpdateQueue = {
|
352 | |
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 | isMounted: function (publicInstance) {
|
360 | return false;
|
361 | },
|
362 |
|
363 | |
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 | enqueueForceUpdate: function (publicInstance, callback, callerName) {
|
379 | warnNoop(publicInstance, 'forceUpdate');
|
380 | },
|
381 |
|
382 | |
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 | enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
|
396 | warnNoop(publicInstance, 'replaceState');
|
397 | },
|
398 |
|
399 | |
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 | enqueueSetState: function (publicInstance, partialState, callback, callerName) {
|
412 | warnNoop(publicInstance, 'setState');
|
413 | }
|
414 | };
|
415 |
|
416 | var emptyObject = {};
|
417 | {
|
418 | Object.freeze(emptyObject);
|
419 | }
|
420 |
|
421 |
|
422 |
|
423 |
|
424 | function Component(props, context, updater) {
|
425 | this.props = props;
|
426 | this.context = context;
|
427 |
|
428 | this.refs = emptyObject;
|
429 |
|
430 |
|
431 | this.updater = updater || ReactNoopUpdateQueue;
|
432 | }
|
433 |
|
434 | Component.prototype.isReactComponent = {};
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 | Component.prototype.setState = function (partialState, callback) {
|
462 | !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
|
463 | this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
464 | };
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 | Component.prototype.forceUpdate = function (callback) {
|
481 | this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
482 | };
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 | {
|
490 | var deprecatedAPIs = {
|
491 | isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
492 | replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
493 | };
|
494 | var defineDeprecationWarning = function (methodName, info) {
|
495 | Object.defineProperty(Component.prototype, methodName, {
|
496 | get: function () {
|
497 | lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
498 | return undefined;
|
499 | }
|
500 | });
|
501 | };
|
502 | for (var fnName in deprecatedAPIs) {
|
503 | if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
504 | defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
505 | }
|
506 | }
|
507 | }
|
508 |
|
509 | function ComponentDummy() {}
|
510 | ComponentDummy.prototype = Component.prototype;
|
511 |
|
512 |
|
513 |
|
514 |
|
515 | function PureComponent(props, context, updater) {
|
516 | this.props = props;
|
517 | this.context = context;
|
518 |
|
519 | this.refs = emptyObject;
|
520 | this.updater = updater || ReactNoopUpdateQueue;
|
521 | }
|
522 |
|
523 | var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
524 | pureComponentPrototype.constructor = PureComponent;
|
525 |
|
526 | objectAssign(pureComponentPrototype, Component.prototype);
|
527 | pureComponentPrototype.isPureReactComponent = true;
|
528 |
|
529 |
|
530 | function createRef() {
|
531 | var refObject = {
|
532 | current: null
|
533 | };
|
534 | {
|
535 | Object.seal(refObject);
|
536 | }
|
537 | return refObject;
|
538 | }
|
539 |
|
540 |
|
541 |
|
542 |
|
543 | var ImmediatePriority = 1;
|
544 | var UserBlockingPriority = 2;
|
545 | var NormalPriority = 3;
|
546 | var LowPriority = 4;
|
547 | var IdlePriority = 5;
|
548 |
|
549 |
|
550 |
|
551 |
|
552 | var maxSigned31BitInt = 1073741823;
|
553 |
|
554 |
|
555 | var IMMEDIATE_PRIORITY_TIMEOUT = -1;
|
556 |
|
557 | var USER_BLOCKING_PRIORITY = 250;
|
558 | var NORMAL_PRIORITY_TIMEOUT = 5000;
|
559 | var LOW_PRIORITY_TIMEOUT = 10000;
|
560 |
|
561 | var IDLE_PRIORITY = maxSigned31BitInt;
|
562 |
|
563 |
|
564 | var firstCallbackNode = null;
|
565 |
|
566 | var currentDidTimeout = false;
|
567 |
|
568 | var isSchedulerPaused = false;
|
569 |
|
570 | var currentPriorityLevel = NormalPriority;
|
571 | var currentEventStartTime = -1;
|
572 | var currentExpirationTime = -1;
|
573 |
|
574 |
|
575 | var isExecutingCallback = false;
|
576 |
|
577 | var isHostCallbackScheduled = false;
|
578 |
|
579 | var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
|
580 |
|
581 | function ensureHostCallbackIsScheduled() {
|
582 | if (isExecutingCallback) {
|
583 |
|
584 | return;
|
585 | }
|
586 |
|
587 | var expirationTime = firstCallbackNode.expirationTime;
|
588 | if (!isHostCallbackScheduled) {
|
589 | isHostCallbackScheduled = true;
|
590 | } else {
|
591 |
|
592 | cancelHostCallback();
|
593 | }
|
594 | requestHostCallback(flushWork, expirationTime);
|
595 | }
|
596 |
|
597 | function flushFirstCallback() {
|
598 | var flushedNode = firstCallbackNode;
|
599 |
|
600 |
|
601 |
|
602 | var next = firstCallbackNode.next;
|
603 | if (firstCallbackNode === next) {
|
604 |
|
605 | firstCallbackNode = null;
|
606 | next = null;
|
607 | } else {
|
608 | var lastCallbackNode = firstCallbackNode.previous;
|
609 | firstCallbackNode = lastCallbackNode.next = next;
|
610 | next.previous = lastCallbackNode;
|
611 | }
|
612 |
|
613 | flushedNode.next = flushedNode.previous = null;
|
614 |
|
615 |
|
616 | var callback = flushedNode.callback;
|
617 | var expirationTime = flushedNode.expirationTime;
|
618 | var priorityLevel = flushedNode.priorityLevel;
|
619 | var previousPriorityLevel = currentPriorityLevel;
|
620 | var previousExpirationTime = currentExpirationTime;
|
621 | currentPriorityLevel = priorityLevel;
|
622 | currentExpirationTime = expirationTime;
|
623 | var continuationCallback;
|
624 | try {
|
625 | continuationCallback = callback();
|
626 | } finally {
|
627 | currentPriorityLevel = previousPriorityLevel;
|
628 | currentExpirationTime = previousExpirationTime;
|
629 | }
|
630 |
|
631 |
|
632 |
|
633 | if (typeof continuationCallback === 'function') {
|
634 | var continuationNode = {
|
635 | callback: continuationCallback,
|
636 | priorityLevel: priorityLevel,
|
637 | expirationTime: expirationTime,
|
638 | next: null,
|
639 | previous: null
|
640 | };
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 | if (firstCallbackNode === null) {
|
647 |
|
648 | firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
|
649 | } else {
|
650 | var nextAfterContinuation = null;
|
651 | var node = firstCallbackNode;
|
652 | do {
|
653 | if (node.expirationTime >= expirationTime) {
|
654 |
|
655 |
|
656 | nextAfterContinuation = node;
|
657 | break;
|
658 | }
|
659 | node = node.next;
|
660 | } while (node !== firstCallbackNode);
|
661 |
|
662 | if (nextAfterContinuation === null) {
|
663 |
|
664 |
|
665 | nextAfterContinuation = firstCallbackNode;
|
666 | } else if (nextAfterContinuation === firstCallbackNode) {
|
667 |
|
668 | firstCallbackNode = continuationNode;
|
669 | ensureHostCallbackIsScheduled();
|
670 | }
|
671 |
|
672 | var previous = nextAfterContinuation.previous;
|
673 | previous.next = nextAfterContinuation.previous = continuationNode;
|
674 | continuationNode.next = nextAfterContinuation;
|
675 | continuationNode.previous = previous;
|
676 | }
|
677 | }
|
678 | }
|
679 |
|
680 | function flushImmediateWork() {
|
681 | if (
|
682 |
|
683 | currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
|
684 | isExecutingCallback = true;
|
685 | try {
|
686 | do {
|
687 | flushFirstCallback();
|
688 | } while (
|
689 |
|
690 | firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
|
691 | } finally {
|
692 | isExecutingCallback = false;
|
693 | if (firstCallbackNode !== null) {
|
694 |
|
695 | ensureHostCallbackIsScheduled();
|
696 | } else {
|
697 | isHostCallbackScheduled = false;
|
698 | }
|
699 | }
|
700 | }
|
701 | }
|
702 |
|
703 | function flushWork(didTimeout) {
|
704 |
|
705 |
|
706 | if (enableSchedulerDebugging && isSchedulerPaused) {
|
707 | return;
|
708 | }
|
709 |
|
710 | isExecutingCallback = true;
|
711 | var previousDidTimeout = currentDidTimeout;
|
712 | currentDidTimeout = didTimeout;
|
713 | try {
|
714 | if (didTimeout) {
|
715 |
|
716 | while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {
|
717 |
|
718 |
|
719 |
|
720 |
|
721 | var currentTime = getCurrentTime();
|
722 | if (firstCallbackNode.expirationTime <= currentTime) {
|
723 | do {
|
724 | flushFirstCallback();
|
725 | } while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused));
|
726 | continue;
|
727 | }
|
728 | break;
|
729 | }
|
730 | } else {
|
731 |
|
732 | if (firstCallbackNode !== null) {
|
733 | do {
|
734 | if (enableSchedulerDebugging && isSchedulerPaused) {
|
735 | break;
|
736 | }
|
737 | flushFirstCallback();
|
738 | } while (firstCallbackNode !== null && !shouldYieldToHost());
|
739 | }
|
740 | }
|
741 | } finally {
|
742 | isExecutingCallback = false;
|
743 | currentDidTimeout = previousDidTimeout;
|
744 | if (firstCallbackNode !== null) {
|
745 |
|
746 | ensureHostCallbackIsScheduled();
|
747 | } else {
|
748 | isHostCallbackScheduled = false;
|
749 | }
|
750 |
|
751 | flushImmediateWork();
|
752 | }
|
753 | }
|
754 |
|
755 | function unstable_runWithPriority(priorityLevel, eventHandler) {
|
756 | switch (priorityLevel) {
|
757 | case ImmediatePriority:
|
758 | case UserBlockingPriority:
|
759 | case NormalPriority:
|
760 | case LowPriority:
|
761 | case IdlePriority:
|
762 | break;
|
763 | default:
|
764 | priorityLevel = NormalPriority;
|
765 | }
|
766 |
|
767 | var previousPriorityLevel = currentPriorityLevel;
|
768 | var previousEventStartTime = currentEventStartTime;
|
769 | currentPriorityLevel = priorityLevel;
|
770 | currentEventStartTime = getCurrentTime();
|
771 |
|
772 | try {
|
773 | return eventHandler();
|
774 | } finally {
|
775 | currentPriorityLevel = previousPriorityLevel;
|
776 | currentEventStartTime = previousEventStartTime;
|
777 |
|
778 |
|
779 | flushImmediateWork();
|
780 | }
|
781 | }
|
782 |
|
783 | function unstable_wrapCallback(callback) {
|
784 | var parentPriorityLevel = currentPriorityLevel;
|
785 | return function () {
|
786 |
|
787 | var previousPriorityLevel = currentPriorityLevel;
|
788 | var previousEventStartTime = currentEventStartTime;
|
789 | currentPriorityLevel = parentPriorityLevel;
|
790 | currentEventStartTime = getCurrentTime();
|
791 |
|
792 | try {
|
793 | return callback.apply(this, arguments);
|
794 | } finally {
|
795 | currentPriorityLevel = previousPriorityLevel;
|
796 | currentEventStartTime = previousEventStartTime;
|
797 | flushImmediateWork();
|
798 | }
|
799 | };
|
800 | }
|
801 |
|
802 | function unstable_scheduleCallback(callback, deprecated_options) {
|
803 | var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
|
804 |
|
805 | var expirationTime;
|
806 | if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
|
807 |
|
808 | expirationTime = startTime + deprecated_options.timeout;
|
809 | } else {
|
810 | switch (currentPriorityLevel) {
|
811 | case ImmediatePriority:
|
812 | expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
|
813 | break;
|
814 | case UserBlockingPriority:
|
815 | expirationTime = startTime + USER_BLOCKING_PRIORITY;
|
816 | break;
|
817 | case IdlePriority:
|
818 | expirationTime = startTime + IDLE_PRIORITY;
|
819 | break;
|
820 | case LowPriority:
|
821 | expirationTime = startTime + LOW_PRIORITY_TIMEOUT;
|
822 | break;
|
823 | case NormalPriority:
|
824 | default:
|
825 | expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
|
826 | }
|
827 | }
|
828 |
|
829 | var newNode = {
|
830 | callback: callback,
|
831 | priorityLevel: currentPriorityLevel,
|
832 | expirationTime: expirationTime,
|
833 | next: null,
|
834 | previous: null
|
835 | };
|
836 |
|
837 |
|
838 |
|
839 |
|
840 | if (firstCallbackNode === null) {
|
841 |
|
842 | firstCallbackNode = newNode.next = newNode.previous = newNode;
|
843 | ensureHostCallbackIsScheduled();
|
844 | } else {
|
845 | var next = null;
|
846 | var node = firstCallbackNode;
|
847 | do {
|
848 | if (node.expirationTime > expirationTime) {
|
849 |
|
850 | next = node;
|
851 | break;
|
852 | }
|
853 | node = node.next;
|
854 | } while (node !== firstCallbackNode);
|
855 |
|
856 | if (next === null) {
|
857 |
|
858 |
|
859 | next = firstCallbackNode;
|
860 | } else if (next === firstCallbackNode) {
|
861 |
|
862 | firstCallbackNode = newNode;
|
863 | ensureHostCallbackIsScheduled();
|
864 | }
|
865 |
|
866 | var previous = next.previous;
|
867 | previous.next = next.previous = newNode;
|
868 | newNode.next = next;
|
869 | newNode.previous = previous;
|
870 | }
|
871 |
|
872 | return newNode;
|
873 | }
|
874 |
|
875 | function unstable_pauseExecution() {
|
876 | isSchedulerPaused = true;
|
877 | }
|
878 |
|
879 | function unstable_continueExecution() {
|
880 | isSchedulerPaused = false;
|
881 | if (firstCallbackNode !== null) {
|
882 | ensureHostCallbackIsScheduled();
|
883 | }
|
884 | }
|
885 |
|
886 | function unstable_getFirstCallbackNode() {
|
887 | return firstCallbackNode;
|
888 | }
|
889 |
|
890 | function unstable_cancelCallback(callbackNode) {
|
891 | var next = callbackNode.next;
|
892 | if (next === null) {
|
893 |
|
894 | return;
|
895 | }
|
896 |
|
897 | if (next === callbackNode) {
|
898 |
|
899 | firstCallbackNode = null;
|
900 | } else {
|
901 |
|
902 | if (callbackNode === firstCallbackNode) {
|
903 | firstCallbackNode = next;
|
904 | }
|
905 | var previous = callbackNode.previous;
|
906 | previous.next = next;
|
907 | next.previous = previous;
|
908 | }
|
909 |
|
910 | callbackNode.next = callbackNode.previous = null;
|
911 | }
|
912 |
|
913 | function unstable_getCurrentPriorityLevel() {
|
914 | return currentPriorityLevel;
|
915 | }
|
916 |
|
917 | function unstable_shouldYield() {
|
918 | return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
|
919 | }
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 | var localDate = Date;
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 | var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
|
939 | var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
|
940 |
|
941 |
|
942 |
|
943 | var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
|
944 | var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
|
945 |
|
946 | var getCurrentTime;
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 | var ANIMATION_FRAME_TIMEOUT = 100;
|
954 | var rAFID;
|
955 | var rAFTimeoutID;
|
956 | var requestAnimationFrameWithTimeout = function (callback) {
|
957 |
|
958 | rAFID = localRequestAnimationFrame(function (timestamp) {
|
959 |
|
960 | localClearTimeout(rAFTimeoutID);
|
961 | callback(timestamp);
|
962 | });
|
963 | rAFTimeoutID = localSetTimeout(function () {
|
964 |
|
965 | localCancelAnimationFrame(rAFID);
|
966 | callback(getCurrentTime());
|
967 | }, ANIMATION_FRAME_TIMEOUT);
|
968 | };
|
969 |
|
970 | if (hasNativePerformanceNow) {
|
971 | var Performance = performance;
|
972 | getCurrentTime = function () {
|
973 | return Performance.now();
|
974 | };
|
975 | } else {
|
976 | getCurrentTime = function () {
|
977 | return localDate.now();
|
978 | };
|
979 | }
|
980 |
|
981 | var requestHostCallback;
|
982 | var cancelHostCallback;
|
983 | var shouldYieldToHost;
|
984 |
|
985 | var globalValue = null;
|
986 | if (typeof window !== 'undefined') {
|
987 | globalValue = window;
|
988 | } else if (typeof global !== 'undefined') {
|
989 | globalValue = global;
|
990 | }
|
991 |
|
992 | if (globalValue && globalValue._schedMock) {
|
993 |
|
994 | var globalImpl = globalValue._schedMock;
|
995 | requestHostCallback = globalImpl[0];
|
996 | cancelHostCallback = globalImpl[1];
|
997 | shouldYieldToHost = globalImpl[2];
|
998 | getCurrentTime = globalImpl[3];
|
999 | } else if (
|
1000 |
|
1001 |
|
1002 | typeof window === 'undefined' ||
|
1003 |
|
1004 | typeof MessageChannel !== 'function') {
|
1005 |
|
1006 |
|
1007 | var _callback = null;
|
1008 | var _flushCallback = function (didTimeout) {
|
1009 | if (_callback !== null) {
|
1010 | try {
|
1011 | _callback(didTimeout);
|
1012 | } finally {
|
1013 | _callback = null;
|
1014 | }
|
1015 | }
|
1016 | };
|
1017 | requestHostCallback = function (cb, ms) {
|
1018 | if (_callback !== null) {
|
1019 |
|
1020 | setTimeout(requestHostCallback, 0, cb);
|
1021 | } else {
|
1022 | _callback = cb;
|
1023 | setTimeout(_flushCallback, 0, false);
|
1024 | }
|
1025 | };
|
1026 | cancelHostCallback = function () {
|
1027 | _callback = null;
|
1028 | };
|
1029 | shouldYieldToHost = function () {
|
1030 | return false;
|
1031 | };
|
1032 | } else {
|
1033 | if (typeof console !== 'undefined') {
|
1034 |
|
1035 | if (typeof localRequestAnimationFrame !== 'function') {
|
1036 | console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
1037 | }
|
1038 | if (typeof localCancelAnimationFrame !== 'function') {
|
1039 | console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
1040 | }
|
1041 | }
|
1042 |
|
1043 | var scheduledHostCallback = null;
|
1044 | var isMessageEventScheduled = false;
|
1045 | var timeoutTime = -1;
|
1046 |
|
1047 | var isAnimationFrameScheduled = false;
|
1048 |
|
1049 | var isFlushingHostCallback = false;
|
1050 |
|
1051 | var frameDeadline = 0;
|
1052 |
|
1053 |
|
1054 |
|
1055 | var previousFrameTime = 33;
|
1056 | var activeFrameTime = 33;
|
1057 |
|
1058 | shouldYieldToHost = function () {
|
1059 | return frameDeadline <= getCurrentTime();
|
1060 | };
|
1061 |
|
1062 |
|
1063 | var channel = new MessageChannel();
|
1064 | var port = channel.port2;
|
1065 | channel.port1.onmessage = function (event) {
|
1066 | isMessageEventScheduled = false;
|
1067 |
|
1068 | var prevScheduledCallback = scheduledHostCallback;
|
1069 | var prevTimeoutTime = timeoutTime;
|
1070 | scheduledHostCallback = null;
|
1071 | timeoutTime = -1;
|
1072 |
|
1073 | var currentTime = getCurrentTime();
|
1074 |
|
1075 | var didTimeout = false;
|
1076 | if (frameDeadline - currentTime <= 0) {
|
1077 |
|
1078 |
|
1079 | if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
|
1080 |
|
1081 |
|
1082 | didTimeout = true;
|
1083 | } else {
|
1084 |
|
1085 | if (!isAnimationFrameScheduled) {
|
1086 |
|
1087 | isAnimationFrameScheduled = true;
|
1088 | requestAnimationFrameWithTimeout(animationTick);
|
1089 | }
|
1090 |
|
1091 | scheduledHostCallback = prevScheduledCallback;
|
1092 | timeoutTime = prevTimeoutTime;
|
1093 | return;
|
1094 | }
|
1095 | }
|
1096 |
|
1097 | if (prevScheduledCallback !== null) {
|
1098 | isFlushingHostCallback = true;
|
1099 | try {
|
1100 | prevScheduledCallback(didTimeout);
|
1101 | } finally {
|
1102 | isFlushingHostCallback = false;
|
1103 | }
|
1104 | }
|
1105 | };
|
1106 |
|
1107 | var animationTick = function (rafTime) {
|
1108 | if (scheduledHostCallback !== null) {
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 | requestAnimationFrameWithTimeout(animationTick);
|
1118 | } else {
|
1119 |
|
1120 | isAnimationFrameScheduled = false;
|
1121 | return;
|
1122 | }
|
1123 |
|
1124 | var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
|
1125 | if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
|
1126 | if (nextFrameTime < 8) {
|
1127 |
|
1128 |
|
1129 | nextFrameTime = 8;
|
1130 | }
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 | activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
|
1139 | } else {
|
1140 | previousFrameTime = nextFrameTime;
|
1141 | }
|
1142 | frameDeadline = rafTime + activeFrameTime;
|
1143 | if (!isMessageEventScheduled) {
|
1144 | isMessageEventScheduled = true;
|
1145 | port.postMessage(undefined);
|
1146 | }
|
1147 | };
|
1148 |
|
1149 | requestHostCallback = function (callback, absoluteTimeout) {
|
1150 | scheduledHostCallback = callback;
|
1151 | timeoutTime = absoluteTimeout;
|
1152 | if (isFlushingHostCallback || absoluteTimeout < 0) {
|
1153 |
|
1154 | port.postMessage(undefined);
|
1155 | } else if (!isAnimationFrameScheduled) {
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 | isAnimationFrameScheduled = true;
|
1161 | requestAnimationFrameWithTimeout(animationTick);
|
1162 | }
|
1163 | };
|
1164 |
|
1165 | cancelHostCallback = function () {
|
1166 | scheduledHostCallback = null;
|
1167 | isMessageEventScheduled = false;
|
1168 | timeoutTime = -1;
|
1169 | };
|
1170 | }
|
1171 |
|
1172 | var DEFAULT_THREAD_ID = 0;
|
1173 |
|
1174 |
|
1175 | var interactionIDCounter = 0;
|
1176 | var threadIDCounter = 0;
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 | var interactionsRef = null;
|
1183 |
|
1184 |
|
1185 | var subscriberRef = null;
|
1186 |
|
1187 | if (enableSchedulerTracing) {
|
1188 | interactionsRef = {
|
1189 | current: new Set()
|
1190 | };
|
1191 | subscriberRef = {
|
1192 | current: null
|
1193 | };
|
1194 | }
|
1195 |
|
1196 | function unstable_clear(callback) {
|
1197 | if (!enableSchedulerTracing) {
|
1198 | return callback();
|
1199 | }
|
1200 |
|
1201 | var prevInteractions = interactionsRef.current;
|
1202 | interactionsRef.current = new Set();
|
1203 |
|
1204 | try {
|
1205 | return callback();
|
1206 | } finally {
|
1207 | interactionsRef.current = prevInteractions;
|
1208 | }
|
1209 | }
|
1210 |
|
1211 | function unstable_getCurrent() {
|
1212 | if (!enableSchedulerTracing) {
|
1213 | return null;
|
1214 | } else {
|
1215 | return interactionsRef.current;
|
1216 | }
|
1217 | }
|
1218 |
|
1219 | function unstable_getThreadID() {
|
1220 | return ++threadIDCounter;
|
1221 | }
|
1222 |
|
1223 | function unstable_trace(name, timestamp, callback) {
|
1224 | var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
|
1225 |
|
1226 | if (!enableSchedulerTracing) {
|
1227 | return callback();
|
1228 | }
|
1229 |
|
1230 | var interaction = {
|
1231 | __count: 1,
|
1232 | id: interactionIDCounter++,
|
1233 | name: name,
|
1234 | timestamp: timestamp
|
1235 | };
|
1236 |
|
1237 | var prevInteractions = interactionsRef.current;
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 | var interactions = new Set(prevInteractions);
|
1243 | interactions.add(interaction);
|
1244 | interactionsRef.current = interactions;
|
1245 |
|
1246 | var subscriber = subscriberRef.current;
|
1247 | var returnValue = void 0;
|
1248 |
|
1249 | try {
|
1250 | if (subscriber !== null) {
|
1251 | subscriber.onInteractionTraced(interaction);
|
1252 | }
|
1253 | } finally {
|
1254 | try {
|
1255 | if (subscriber !== null) {
|
1256 | subscriber.onWorkStarted(interactions, threadID);
|
1257 | }
|
1258 | } finally {
|
1259 | try {
|
1260 | returnValue = callback();
|
1261 | } finally {
|
1262 | interactionsRef.current = prevInteractions;
|
1263 |
|
1264 | try {
|
1265 | if (subscriber !== null) {
|
1266 | subscriber.onWorkStopped(interactions, threadID);
|
1267 | }
|
1268 | } finally {
|
1269 | interaction.__count--;
|
1270 |
|
1271 |
|
1272 |
|
1273 | if (subscriber !== null && interaction.__count === 0) {
|
1274 | subscriber.onInteractionScheduledWorkCompleted(interaction);
|
1275 | }
|
1276 | }
|
1277 | }
|
1278 | }
|
1279 | }
|
1280 |
|
1281 | return returnValue;
|
1282 | }
|
1283 |
|
1284 | function unstable_wrap(callback) {
|
1285 | var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
|
1286 |
|
1287 | if (!enableSchedulerTracing) {
|
1288 | return callback;
|
1289 | }
|
1290 |
|
1291 | var wrappedInteractions = interactionsRef.current;
|
1292 |
|
1293 | var subscriber = subscriberRef.current;
|
1294 | if (subscriber !== null) {
|
1295 | subscriber.onWorkScheduled(wrappedInteractions, threadID);
|
1296 | }
|
1297 |
|
1298 |
|
1299 |
|
1300 | wrappedInteractions.forEach(function (interaction) {
|
1301 | interaction.__count++;
|
1302 | });
|
1303 |
|
1304 | var hasRun = false;
|
1305 |
|
1306 | function wrapped() {
|
1307 | var prevInteractions = interactionsRef.current;
|
1308 | interactionsRef.current = wrappedInteractions;
|
1309 |
|
1310 | subscriber = subscriberRef.current;
|
1311 |
|
1312 | try {
|
1313 | var returnValue = void 0;
|
1314 |
|
1315 | try {
|
1316 | if (subscriber !== null) {
|
1317 | subscriber.onWorkStarted(wrappedInteractions, threadID);
|
1318 | }
|
1319 | } finally {
|
1320 | try {
|
1321 | returnValue = callback.apply(undefined, arguments);
|
1322 | } finally {
|
1323 | interactionsRef.current = prevInteractions;
|
1324 |
|
1325 | if (subscriber !== null) {
|
1326 | subscriber.onWorkStopped(wrappedInteractions, threadID);
|
1327 | }
|
1328 | }
|
1329 | }
|
1330 |
|
1331 | return returnValue;
|
1332 | } finally {
|
1333 | if (!hasRun) {
|
1334 |
|
1335 |
|
1336 |
|
1337 | hasRun = true;
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 | wrappedInteractions.forEach(function (interaction) {
|
1343 | interaction.__count--;
|
1344 |
|
1345 | if (subscriber !== null && interaction.__count === 0) {
|
1346 | subscriber.onInteractionScheduledWorkCompleted(interaction);
|
1347 | }
|
1348 | });
|
1349 | }
|
1350 | }
|
1351 | }
|
1352 |
|
1353 | wrapped.cancel = function cancel() {
|
1354 | subscriber = subscriberRef.current;
|
1355 |
|
1356 | try {
|
1357 | if (subscriber !== null) {
|
1358 | subscriber.onWorkCanceled(wrappedInteractions, threadID);
|
1359 | }
|
1360 | } finally {
|
1361 |
|
1362 |
|
1363 |
|
1364 | wrappedInteractions.forEach(function (interaction) {
|
1365 | interaction.__count--;
|
1366 |
|
1367 | if (subscriber && interaction.__count === 0) {
|
1368 | subscriber.onInteractionScheduledWorkCompleted(interaction);
|
1369 | }
|
1370 | });
|
1371 | }
|
1372 | };
|
1373 |
|
1374 | return wrapped;
|
1375 | }
|
1376 |
|
1377 | var subscribers = null;
|
1378 | if (enableSchedulerTracing) {
|
1379 | subscribers = new Set();
|
1380 | }
|
1381 |
|
1382 | function unstable_subscribe(subscriber) {
|
1383 | if (enableSchedulerTracing) {
|
1384 | subscribers.add(subscriber);
|
1385 |
|
1386 | if (subscribers.size === 1) {
|
1387 | subscriberRef.current = {
|
1388 | onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
|
1389 | onInteractionTraced: onInteractionTraced,
|
1390 | onWorkCanceled: onWorkCanceled,
|
1391 | onWorkScheduled: onWorkScheduled,
|
1392 | onWorkStarted: onWorkStarted,
|
1393 | onWorkStopped: onWorkStopped
|
1394 | };
|
1395 | }
|
1396 | }
|
1397 | }
|
1398 |
|
1399 | function unstable_unsubscribe(subscriber) {
|
1400 | if (enableSchedulerTracing) {
|
1401 | subscribers.delete(subscriber);
|
1402 |
|
1403 | if (subscribers.size === 0) {
|
1404 | subscriberRef.current = null;
|
1405 | }
|
1406 | }
|
1407 | }
|
1408 |
|
1409 | function onInteractionTraced(interaction) {
|
1410 | var didCatchError = false;
|
1411 | var caughtError = null;
|
1412 |
|
1413 | subscribers.forEach(function (subscriber) {
|
1414 | try {
|
1415 | subscriber.onInteractionTraced(interaction);
|
1416 | } catch (error) {
|
1417 | if (!didCatchError) {
|
1418 | didCatchError = true;
|
1419 | caughtError = error;
|
1420 | }
|
1421 | }
|
1422 | });
|
1423 |
|
1424 | if (didCatchError) {
|
1425 | throw caughtError;
|
1426 | }
|
1427 | }
|
1428 |
|
1429 | function onInteractionScheduledWorkCompleted(interaction) {
|
1430 | var didCatchError = false;
|
1431 | var caughtError = null;
|
1432 |
|
1433 | subscribers.forEach(function (subscriber) {
|
1434 | try {
|
1435 | subscriber.onInteractionScheduledWorkCompleted(interaction);
|
1436 | } catch (error) {
|
1437 | if (!didCatchError) {
|
1438 | didCatchError = true;
|
1439 | caughtError = error;
|
1440 | }
|
1441 | }
|
1442 | });
|
1443 |
|
1444 | if (didCatchError) {
|
1445 | throw caughtError;
|
1446 | }
|
1447 | }
|
1448 |
|
1449 | function onWorkScheduled(interactions, threadID) {
|
1450 | var didCatchError = false;
|
1451 | var caughtError = null;
|
1452 |
|
1453 | subscribers.forEach(function (subscriber) {
|
1454 | try {
|
1455 | subscriber.onWorkScheduled(interactions, threadID);
|
1456 | } catch (error) {
|
1457 | if (!didCatchError) {
|
1458 | didCatchError = true;
|
1459 | caughtError = error;
|
1460 | }
|
1461 | }
|
1462 | });
|
1463 |
|
1464 | if (didCatchError) {
|
1465 | throw caughtError;
|
1466 | }
|
1467 | }
|
1468 |
|
1469 | function onWorkStarted(interactions, threadID) {
|
1470 | var didCatchError = false;
|
1471 | var caughtError = null;
|
1472 |
|
1473 | subscribers.forEach(function (subscriber) {
|
1474 | try {
|
1475 | subscriber.onWorkStarted(interactions, threadID);
|
1476 | } catch (error) {
|
1477 | if (!didCatchError) {
|
1478 | didCatchError = true;
|
1479 | caughtError = error;
|
1480 | }
|
1481 | }
|
1482 | });
|
1483 |
|
1484 | if (didCatchError) {
|
1485 | throw caughtError;
|
1486 | }
|
1487 | }
|
1488 |
|
1489 | function onWorkStopped(interactions, threadID) {
|
1490 | var didCatchError = false;
|
1491 | var caughtError = null;
|
1492 |
|
1493 | subscribers.forEach(function (subscriber) {
|
1494 | try {
|
1495 | subscriber.onWorkStopped(interactions, threadID);
|
1496 | } catch (error) {
|
1497 | if (!didCatchError) {
|
1498 | didCatchError = true;
|
1499 | caughtError = error;
|
1500 | }
|
1501 | }
|
1502 | });
|
1503 |
|
1504 | if (didCatchError) {
|
1505 | throw caughtError;
|
1506 | }
|
1507 | }
|
1508 |
|
1509 | function onWorkCanceled(interactions, threadID) {
|
1510 | var didCatchError = false;
|
1511 | var caughtError = null;
|
1512 |
|
1513 | subscribers.forEach(function (subscriber) {
|
1514 | try {
|
1515 | subscriber.onWorkCanceled(interactions, threadID);
|
1516 | } catch (error) {
|
1517 | if (!didCatchError) {
|
1518 | didCatchError = true;
|
1519 | caughtError = error;
|
1520 | }
|
1521 | }
|
1522 | });
|
1523 |
|
1524 | if (didCatchError) {
|
1525 | throw caughtError;
|
1526 | }
|
1527 | }
|
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
|
1533 |
|
1534 |
|
1535 | var ReactCurrentOwner = {
|
1536 | |
1537 |
|
1538 |
|
1539 |
|
1540 | current: null,
|
1541 | currentDispatcher: null
|
1542 | };
|
1543 |
|
1544 | var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
1545 |
|
1546 | var describeComponentFrame = function (name, source, ownerName) {
|
1547 | var sourceInfo = '';
|
1548 | if (source) {
|
1549 | var path = source.fileName;
|
1550 | var fileName = path.replace(BEFORE_SLASH_RE, '');
|
1551 | {
|
1552 |
|
1553 |
|
1554 | if (/^index\./.test(fileName)) {
|
1555 | var match = path.match(BEFORE_SLASH_RE);
|
1556 | if (match) {
|
1557 | var pathBeforeSlash = match[1];
|
1558 | if (pathBeforeSlash) {
|
1559 | var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
1560 | fileName = folderName + '/' + fileName;
|
1561 | }
|
1562 | }
|
1563 | }
|
1564 | }
|
1565 | sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
1566 | } else if (ownerName) {
|
1567 | sourceInfo = ' (created by ' + ownerName + ')';
|
1568 | }
|
1569 | return '\n in ' + (name || 'Unknown') + sourceInfo;
|
1570 | };
|
1571 |
|
1572 | var Resolved = 1;
|
1573 |
|
1574 |
|
1575 | function refineResolvedLazyComponent(lazyComponent) {
|
1576 | return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
1577 | }
|
1578 |
|
1579 | function getWrappedName(outerType, innerType, wrapperName) {
|
1580 | var functionName = innerType.displayName || innerType.name || '';
|
1581 | return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
|
1582 | }
|
1583 |
|
1584 | function getComponentName(type) {
|
1585 | if (type == null) {
|
1586 |
|
1587 | return null;
|
1588 | }
|
1589 | {
|
1590 | if (typeof type.tag === 'number') {
|
1591 | warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
1592 | }
|
1593 | }
|
1594 | if (typeof type === 'function') {
|
1595 | return type.displayName || type.name || null;
|
1596 | }
|
1597 | if (typeof type === 'string') {
|
1598 | return type;
|
1599 | }
|
1600 | switch (type) {
|
1601 | case REACT_CONCURRENT_MODE_TYPE:
|
1602 | return 'ConcurrentMode';
|
1603 | case REACT_FRAGMENT_TYPE:
|
1604 | return 'Fragment';
|
1605 | case REACT_PORTAL_TYPE:
|
1606 | return 'Portal';
|
1607 | case REACT_PROFILER_TYPE:
|
1608 | return 'Profiler';
|
1609 | case REACT_STRICT_MODE_TYPE:
|
1610 | return 'StrictMode';
|
1611 | case REACT_SUSPENSE_TYPE:
|
1612 | return 'Suspense';
|
1613 | }
|
1614 | if (typeof type === 'object') {
|
1615 | switch (type.$$typeof) {
|
1616 | case REACT_CONTEXT_TYPE:
|
1617 | return 'Context.Consumer';
|
1618 | case REACT_PROVIDER_TYPE:
|
1619 | return 'Context.Provider';
|
1620 | case REACT_FORWARD_REF_TYPE:
|
1621 | return getWrappedName(type, type.render, 'ForwardRef');
|
1622 | case REACT_MEMO_TYPE:
|
1623 | return getComponentName(type.type);
|
1624 | case REACT_LAZY_TYPE:
|
1625 | {
|
1626 | var thenable = type;
|
1627 | var resolvedThenable = refineResolvedLazyComponent(thenable);
|
1628 | if (resolvedThenable) {
|
1629 | return getComponentName(resolvedThenable);
|
1630 | }
|
1631 | }
|
1632 | }
|
1633 | }
|
1634 | return null;
|
1635 | }
|
1636 |
|
1637 | var ReactDebugCurrentFrame = {};
|
1638 |
|
1639 | var currentlyValidatingElement = null;
|
1640 |
|
1641 | function setCurrentlyValidatingElement(element) {
|
1642 | {
|
1643 | currentlyValidatingElement = element;
|
1644 | }
|
1645 | }
|
1646 |
|
1647 | {
|
1648 |
|
1649 | ReactDebugCurrentFrame.getCurrentStack = null;
|
1650 |
|
1651 | ReactDebugCurrentFrame.getStackAddendum = function () {
|
1652 | var stack = '';
|
1653 |
|
1654 |
|
1655 | if (currentlyValidatingElement) {
|
1656 | var name = getComponentName(currentlyValidatingElement.type);
|
1657 | var owner = currentlyValidatingElement._owner;
|
1658 | stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
1659 | }
|
1660 |
|
1661 |
|
1662 | var impl = ReactDebugCurrentFrame.getCurrentStack;
|
1663 | if (impl) {
|
1664 | stack += impl() || '';
|
1665 | }
|
1666 |
|
1667 | return stack;
|
1668 | };
|
1669 | }
|
1670 |
|
1671 | var ReactSharedInternals = {
|
1672 | ReactCurrentOwner: ReactCurrentOwner,
|
1673 |
|
1674 | assign: objectAssign
|
1675 | };
|
1676 |
|
1677 | {
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 |
|
1683 | objectAssign(ReactSharedInternals, {
|
1684 | Scheduler: {
|
1685 | unstable_cancelCallback: unstable_cancelCallback,
|
1686 | unstable_shouldYield: unstable_shouldYield,
|
1687 | unstable_now: getCurrentTime,
|
1688 | unstable_scheduleCallback: unstable_scheduleCallback,
|
1689 | unstable_runWithPriority: unstable_runWithPriority,
|
1690 | unstable_wrapCallback: unstable_wrapCallback,
|
1691 | unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
|
1692 | unstable_pauseExecution: unstable_pauseExecution,
|
1693 | unstable_continueExecution: unstable_continueExecution,
|
1694 | unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel
|
1695 | },
|
1696 | SchedulerTracing: {
|
1697 | __interactionsRef: interactionsRef,
|
1698 | __subscriberRef: subscriberRef,
|
1699 | unstable_clear: unstable_clear,
|
1700 | unstable_getCurrent: unstable_getCurrent,
|
1701 | unstable_getThreadID: unstable_getThreadID,
|
1702 | unstable_subscribe: unstable_subscribe,
|
1703 | unstable_trace: unstable_trace,
|
1704 | unstable_unsubscribe: unstable_unsubscribe,
|
1705 | unstable_wrap: unstable_wrap
|
1706 | }
|
1707 | });
|
1708 | }
|
1709 |
|
1710 | {
|
1711 | objectAssign(ReactSharedInternals, {
|
1712 |
|
1713 | ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
1714 |
|
1715 |
|
1716 | ReactComponentTreeHook: {}
|
1717 | });
|
1718 | }
|
1719 |
|
1720 |
|
1721 |
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 | var warning = warningWithoutStack$1;
|
1728 |
|
1729 | {
|
1730 | warning = function (condition, format) {
|
1731 | if (condition) {
|
1732 | return;
|
1733 | }
|
1734 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
1735 | var stack = ReactDebugCurrentFrame.getStackAddendum();
|
1736 |
|
1737 |
|
1738 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
1739 | args[_key - 2] = arguments[_key];
|
1740 | }
|
1741 |
|
1742 | warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
|
1743 | };
|
1744 | }
|
1745 |
|
1746 | var warning$1 = warning;
|
1747 |
|
1748 | var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
1749 |
|
1750 | var RESERVED_PROPS = {
|
1751 | key: true,
|
1752 | ref: true,
|
1753 | __self: true,
|
1754 | __source: true
|
1755 | };
|
1756 |
|
1757 | var specialPropKeyWarningShown = void 0;
|
1758 | var specialPropRefWarningShown = void 0;
|
1759 |
|
1760 | function hasValidRef(config) {
|
1761 | {
|
1762 | if (hasOwnProperty$1.call(config, 'ref')) {
|
1763 | var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
1764 | if (getter && getter.isReactWarning) {
|
1765 | return false;
|
1766 | }
|
1767 | }
|
1768 | }
|
1769 | return config.ref !== undefined;
|
1770 | }
|
1771 |
|
1772 | function hasValidKey(config) {
|
1773 | {
|
1774 | if (hasOwnProperty$1.call(config, 'key')) {
|
1775 | var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
1776 | if (getter && getter.isReactWarning) {
|
1777 | return false;
|
1778 | }
|
1779 | }
|
1780 | }
|
1781 | return config.key !== undefined;
|
1782 | }
|
1783 |
|
1784 | function defineKeyPropWarningGetter(props, displayName) {
|
1785 | var warnAboutAccessingKey = function () {
|
1786 | if (!specialPropKeyWarningShown) {
|
1787 | specialPropKeyWarningShown = true;
|
1788 | warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
|
1789 | }
|
1790 | };
|
1791 | warnAboutAccessingKey.isReactWarning = true;
|
1792 | Object.defineProperty(props, 'key', {
|
1793 | get: warnAboutAccessingKey,
|
1794 | configurable: true
|
1795 | });
|
1796 | }
|
1797 |
|
1798 | function defineRefPropWarningGetter(props, displayName) {
|
1799 | var warnAboutAccessingRef = function () {
|
1800 | if (!specialPropRefWarningShown) {
|
1801 | specialPropRefWarningShown = true;
|
1802 | warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
|
1803 | }
|
1804 | };
|
1805 | warnAboutAccessingRef.isReactWarning = true;
|
1806 | Object.defineProperty(props, 'ref', {
|
1807 | get: warnAboutAccessingRef,
|
1808 | configurable: true
|
1809 | });
|
1810 | }
|
1811 |
|
1812 | /**
|
1813 | * Factory method to create a new React element. This no longer adheres to
|
1814 | * the class pattern, so do not use new to call it. Also, no instanceof check
|
1815 | * will work. Instead test $$typeof field against Symbol.for('react.element') to check
|
1816 | * if something is a React Element.
|
1817 | *
|
1818 | * @param {*} type
|
1819 | * @param {*} key
|
1820 | * @param {string|object} ref
|
1821 | * @param {*} self A *temporary* helper to detect places where `this` is
|
1822 | * different from the `owner` when React.createElement is called, so that we
|
1823 | * can warn. We want to get rid of owner and replace string `ref`s with arrow
|
1824 | * functions, and as long as `this` and owner are the same, there will be no
|
1825 | * change in behavior.
|
1826 | * @param {*} source An annotation object (added by a transpiler or otherwise)
|
1827 | * indicating filename, line number, and/or other information.
|
1828 | * @param {*} owner
|
1829 | * @param {*} props
|
1830 | * @internal
|
1831 | */
|
1832 | var ReactElement = function (type, key, ref, self, source, owner, props) {
|
1833 | var element = {
|
1834 |
|
1835 | $$typeof: REACT_ELEMENT_TYPE,
|
1836 |
|
1837 |
|
1838 | type: type,
|
1839 | key: key,
|
1840 | ref: ref,
|
1841 | props: props,
|
1842 |
|
1843 |
|
1844 | _owner: owner
|
1845 | };
|
1846 |
|
1847 | {
|
1848 |
|
1849 |
|
1850 |
|
1851 |
|
1852 | element._store = {};
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 | Object.defineProperty(element._store, 'validated', {
|
1859 | configurable: false,
|
1860 | enumerable: false,
|
1861 | writable: true,
|
1862 | value: false
|
1863 | });
|
1864 |
|
1865 | Object.defineProperty(element, '_self', {
|
1866 | configurable: false,
|
1867 | enumerable: false,
|
1868 | writable: false,
|
1869 | value: self
|
1870 | });
|
1871 |
|
1872 |
|
1873 | Object.defineProperty(element, '_source', {
|
1874 | configurable: false,
|
1875 | enumerable: false,
|
1876 | writable: false,
|
1877 | value: source
|
1878 | });
|
1879 | if (Object.freeze) {
|
1880 | Object.freeze(element.props);
|
1881 | Object.freeze(element);
|
1882 | }
|
1883 | }
|
1884 |
|
1885 | return element;
|
1886 | };
|
1887 |
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 | function createElement(type, config, children) {
|
1893 | var propName = void 0;
|
1894 |
|
1895 |
|
1896 | var props = {};
|
1897 |
|
1898 | var key = null;
|
1899 | var ref = null;
|
1900 | var self = null;
|
1901 | var source = null;
|
1902 |
|
1903 | if (config != null) {
|
1904 | if (hasValidRef(config)) {
|
1905 | ref = config.ref;
|
1906 | }
|
1907 | if (hasValidKey(config)) {
|
1908 | key = '' + config.key;
|
1909 | }
|
1910 |
|
1911 | self = config.__self === undefined ? null : config.__self;
|
1912 | source = config.__source === undefined ? null : config.__source;
|
1913 |
|
1914 | for (propName in config) {
|
1915 | if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
1916 | props[propName] = config[propName];
|
1917 | }
|
1918 | }
|
1919 | }
|
1920 |
|
1921 |
|
1922 |
|
1923 | var childrenLength = arguments.length - 2;
|
1924 | if (childrenLength === 1) {
|
1925 | props.children = children;
|
1926 | } else if (childrenLength > 1) {
|
1927 | var childArray = Array(childrenLength);
|
1928 | for (var i = 0; i < childrenLength; i++) {
|
1929 | childArray[i] = arguments[i + 2];
|
1930 | }
|
1931 | {
|
1932 | if (Object.freeze) {
|
1933 | Object.freeze(childArray);
|
1934 | }
|
1935 | }
|
1936 | props.children = childArray;
|
1937 | }
|
1938 |
|
1939 |
|
1940 | if (type && type.defaultProps) {
|
1941 | var defaultProps = type.defaultProps;
|
1942 | for (propName in defaultProps) {
|
1943 | if (props[propName] === undefined) {
|
1944 | props[propName] = defaultProps[propName];
|
1945 | }
|
1946 | }
|
1947 | }
|
1948 | {
|
1949 | if (key || ref) {
|
1950 | var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
1951 | if (key) {
|
1952 | defineKeyPropWarningGetter(props, displayName);
|
1953 | }
|
1954 | if (ref) {
|
1955 | defineRefPropWarningGetter(props, displayName);
|
1956 | }
|
1957 | }
|
1958 | }
|
1959 | return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
1960 | }
|
1961 |
|
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 |
|
1967 |
|
1968 | function cloneAndReplaceKey(oldElement, newKey) {
|
1969 | var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
1970 |
|
1971 | return newElement;
|
1972 | }
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 | function cloneElement(element, config, children) {
|
1979 | !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
|
1980 |
|
1981 | var propName = void 0;
|
1982 |
|
1983 |
|
1984 | var props = objectAssign({}, element.props);
|
1985 |
|
1986 |
|
1987 | var key = element.key;
|
1988 | var ref = element.ref;
|
1989 |
|
1990 | var self = element._self;
|
1991 |
|
1992 |
|
1993 |
|
1994 | var source = element._source;
|
1995 |
|
1996 |
|
1997 | var owner = element._owner;
|
1998 |
|
1999 | if (config != null) {
|
2000 | if (hasValidRef(config)) {
|
2001 |
|
2002 | ref = config.ref;
|
2003 | owner = ReactCurrentOwner.current;
|
2004 | }
|
2005 | if (hasValidKey(config)) {
|
2006 | key = '' + config.key;
|
2007 | }
|
2008 |
|
2009 |
|
2010 | var defaultProps = void 0;
|
2011 | if (element.type && element.type.defaultProps) {
|
2012 | defaultProps = element.type.defaultProps;
|
2013 | }
|
2014 | for (propName in config) {
|
2015 | if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
2016 | if (config[propName] === undefined && defaultProps !== undefined) {
|
2017 |
|
2018 | props[propName] = defaultProps[propName];
|
2019 | } else {
|
2020 | props[propName] = config[propName];
|
2021 | }
|
2022 | }
|
2023 | }
|
2024 | }
|
2025 |
|
2026 |
|
2027 |
|
2028 | var childrenLength = arguments.length - 2;
|
2029 | if (childrenLength === 1) {
|
2030 | props.children = children;
|
2031 | } else if (childrenLength > 1) {
|
2032 | var childArray = Array(childrenLength);
|
2033 | for (var i = 0; i < childrenLength; i++) {
|
2034 | childArray[i] = arguments[i + 2];
|
2035 | }
|
2036 | props.children = childArray;
|
2037 | }
|
2038 |
|
2039 | return ReactElement(element.type, key, ref, self, source, owner, props);
|
2040 | }
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 | function isValidElement(object) {
|
2050 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
2051 | }
|
2052 |
|
2053 | var SEPARATOR = '.';
|
2054 | var SUBSEPARATOR = ':';
|
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 | function escape(key) {
|
2063 | var escapeRegex = /[=:]/g;
|
2064 | var escaperLookup = {
|
2065 | '=': '=0',
|
2066 | ':': '=2'
|
2067 | };
|
2068 | var escapedString = ('' + key).replace(escapeRegex, function (match) {
|
2069 | return escaperLookup[match];
|
2070 | });
|
2071 |
|
2072 | return '$' + escapedString;
|
2073 | }
|
2074 |
|
2075 |
|
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 | var didWarnAboutMaps = false;
|
2081 |
|
2082 | var userProvidedKeyEscapeRegex = /\/+/g;
|
2083 | function escapeUserProvidedKey(text) {
|
2084 | return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
2085 | }
|
2086 |
|
2087 | var POOL_SIZE = 10;
|
2088 | var traverseContextPool = [];
|
2089 | function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
|
2090 | if (traverseContextPool.length) {
|
2091 | var traverseContext = traverseContextPool.pop();
|
2092 | traverseContext.result = mapResult;
|
2093 | traverseContext.keyPrefix = keyPrefix;
|
2094 | traverseContext.func = mapFunction;
|
2095 | traverseContext.context = mapContext;
|
2096 | traverseContext.count = 0;
|
2097 | return traverseContext;
|
2098 | } else {
|
2099 | return {
|
2100 | result: mapResult,
|
2101 | keyPrefix: keyPrefix,
|
2102 | func: mapFunction,
|
2103 | context: mapContext,
|
2104 | count: 0
|
2105 | };
|
2106 | }
|
2107 | }
|
2108 |
|
2109 | function releaseTraverseContext(traverseContext) {
|
2110 | traverseContext.result = null;
|
2111 | traverseContext.keyPrefix = null;
|
2112 | traverseContext.func = null;
|
2113 | traverseContext.context = null;
|
2114 | traverseContext.count = 0;
|
2115 | if (traverseContextPool.length < POOL_SIZE) {
|
2116 | traverseContextPool.push(traverseContext);
|
2117 | }
|
2118 | }
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 | function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
|
2129 | var type = typeof children;
|
2130 |
|
2131 | if (type === 'undefined' || type === 'boolean') {
|
2132 |
|
2133 | children = null;
|
2134 | }
|
2135 |
|
2136 | var invokeCallback = false;
|
2137 |
|
2138 | if (children === null) {
|
2139 | invokeCallback = true;
|
2140 | } else {
|
2141 | switch (type) {
|
2142 | case 'string':
|
2143 | case 'number':
|
2144 | invokeCallback = true;
|
2145 | break;
|
2146 | case 'object':
|
2147 | switch (children.$$typeof) {
|
2148 | case REACT_ELEMENT_TYPE:
|
2149 | case REACT_PORTAL_TYPE:
|
2150 | invokeCallback = true;
|
2151 | }
|
2152 | }
|
2153 | }
|
2154 |
|
2155 | if (invokeCallback) {
|
2156 | callback(traverseContext, children,
|
2157 |
|
2158 |
|
2159 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
|
2160 | return 1;
|
2161 | }
|
2162 |
|
2163 | var child = void 0;
|
2164 | var nextName = void 0;
|
2165 | var subtreeCount = 0;
|
2166 | var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
2167 |
|
2168 | if (Array.isArray(children)) {
|
2169 | for (var i = 0; i < children.length; i++) {
|
2170 | child = children[i];
|
2171 | nextName = nextNamePrefix + getComponentKey(child, i);
|
2172 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
2173 | }
|
2174 | } else {
|
2175 | var iteratorFn = getIteratorFn(children);
|
2176 | if (typeof iteratorFn === 'function') {
|
2177 | {
|
2178 |
|
2179 | if (iteratorFn === children.entries) {
|
2180 | !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
|
2181 | didWarnAboutMaps = true;
|
2182 | }
|
2183 | }
|
2184 |
|
2185 | var iterator = iteratorFn.call(children);
|
2186 | var step = void 0;
|
2187 | var ii = 0;
|
2188 | while (!(step = iterator.next()).done) {
|
2189 | child = step.value;
|
2190 | nextName = nextNamePrefix + getComponentKey(child, ii++);
|
2191 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
2192 | }
|
2193 | } else if (type === 'object') {
|
2194 | var addendum = '';
|
2195 | {
|
2196 | addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
|
2197 | }
|
2198 | var childrenString = '' + children;
|
2199 | invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
|
2200 | }
|
2201 | }
|
2202 |
|
2203 | return subtreeCount;
|
2204 | }
|
2205 |
|
2206 |
|
2207 |
|
2208 |
|
2209 |
|
2210 |
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 | function traverseAllChildren(children, callback, traverseContext) {
|
2223 | if (children == null) {
|
2224 | return 0;
|
2225 | }
|
2226 |
|
2227 | return traverseAllChildrenImpl(children, '', callback, traverseContext);
|
2228 | }
|
2229 |
|
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 | function getComponentKey(component, index) {
|
2238 |
|
2239 |
|
2240 | if (typeof component === 'object' && component !== null && component.key != null) {
|
2241 |
|
2242 | return escape(component.key);
|
2243 | }
|
2244 |
|
2245 | return index.toString(36);
|
2246 | }
|
2247 |
|
2248 | function forEachSingleChild(bookKeeping, child, name) {
|
2249 | var func = bookKeeping.func,
|
2250 | context = bookKeeping.context;
|
2251 |
|
2252 | func.call(context, child, bookKeeping.count++);
|
2253 | }
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 |
|
2264 |
|
2265 |
|
2266 |
|
2267 | function forEachChildren(children, forEachFunc, forEachContext) {
|
2268 | if (children == null) {
|
2269 | return children;
|
2270 | }
|
2271 | var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
|
2272 | traverseAllChildren(children, forEachSingleChild, traverseContext);
|
2273 | releaseTraverseContext(traverseContext);
|
2274 | }
|
2275 |
|
2276 | function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
2277 | var result = bookKeeping.result,
|
2278 | keyPrefix = bookKeeping.keyPrefix,
|
2279 | func = bookKeeping.func,
|
2280 | context = bookKeeping.context;
|
2281 |
|
2282 |
|
2283 | var mappedChild = func.call(context, child, bookKeeping.count++);
|
2284 | if (Array.isArray(mappedChild)) {
|
2285 | mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
|
2286 | return c;
|
2287 | });
|
2288 | } else if (mappedChild != null) {
|
2289 | if (isValidElement(mappedChild)) {
|
2290 | mappedChild = cloneAndReplaceKey(mappedChild,
|
2291 |
|
2292 |
|
2293 | keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
|
2294 | }
|
2295 | result.push(mappedChild);
|
2296 | }
|
2297 | }
|
2298 |
|
2299 | function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
2300 | var escapedPrefix = '';
|
2301 | if (prefix != null) {
|
2302 | escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
2303 | }
|
2304 | var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
|
2305 | traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
2306 | releaseTraverseContext(traverseContext);
|
2307 | }
|
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 |
|
2314 |
|
2315 |
|
2316 |
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 | function mapChildren(children, func, context) {
|
2323 | if (children == null) {
|
2324 | return children;
|
2325 | }
|
2326 | var result = [];
|
2327 | mapIntoWithKeyPrefixInternal(children, result, null, func, context);
|
2328 | return result;
|
2329 | }
|
2330 |
|
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 |
|
2336 |
|
2337 |
|
2338 |
|
2339 |
|
2340 | function countChildren(children) {
|
2341 | return traverseAllChildren(children, function () {
|
2342 | return null;
|
2343 | }, null);
|
2344 | }
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 | function toArray(children) {
|
2353 | var result = [];
|
2354 | mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
|
2355 | return child;
|
2356 | });
|
2357 | return result;
|
2358 | }
|
2359 |
|
2360 |
|
2361 |
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 |
|
2371 |
|
2372 |
|
2373 |
|
2374 | function onlyChild(children) {
|
2375 | !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
|
2376 | return children;
|
2377 | }
|
2378 |
|
2379 | function createContext(defaultValue, calculateChangedBits) {
|
2380 | if (calculateChangedBits === undefined) {
|
2381 | calculateChangedBits = null;
|
2382 | } else {
|
2383 | {
|
2384 | !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
|
2385 | }
|
2386 | }
|
2387 |
|
2388 | var context = {
|
2389 | $$typeof: REACT_CONTEXT_TYPE,
|
2390 | _calculateChangedBits: calculateChangedBits,
|
2391 |
|
2392 |
|
2393 |
|
2394 |
|
2395 |
|
2396 | _currentValue: defaultValue,
|
2397 | _currentValue2: defaultValue,
|
2398 |
|
2399 |
|
2400 | _threadCount: 0,
|
2401 |
|
2402 | Provider: null,
|
2403 | Consumer: null
|
2404 | };
|
2405 |
|
2406 | context.Provider = {
|
2407 | $$typeof: REACT_PROVIDER_TYPE,
|
2408 | _context: context
|
2409 | };
|
2410 |
|
2411 | var hasWarnedAboutUsingNestedContextConsumers = false;
|
2412 | var hasWarnedAboutUsingConsumerProvider = false;
|
2413 |
|
2414 | {
|
2415 |
|
2416 |
|
2417 |
|
2418 | var Consumer = {
|
2419 | $$typeof: REACT_CONTEXT_TYPE,
|
2420 | _context: context,
|
2421 | _calculateChangedBits: context._calculateChangedBits
|
2422 | };
|
2423 |
|
2424 | Object.defineProperties(Consumer, {
|
2425 | Provider: {
|
2426 | get: function () {
|
2427 | if (!hasWarnedAboutUsingConsumerProvider) {
|
2428 | hasWarnedAboutUsingConsumerProvider = true;
|
2429 | warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
|
2430 | }
|
2431 | return context.Provider;
|
2432 | },
|
2433 | set: function (_Provider) {
|
2434 | context.Provider = _Provider;
|
2435 | }
|
2436 | },
|
2437 | _currentValue: {
|
2438 | get: function () {
|
2439 | return context._currentValue;
|
2440 | },
|
2441 | set: function (_currentValue) {
|
2442 | context._currentValue = _currentValue;
|
2443 | }
|
2444 | },
|
2445 | _currentValue2: {
|
2446 | get: function () {
|
2447 | return context._currentValue2;
|
2448 | },
|
2449 | set: function (_currentValue2) {
|
2450 | context._currentValue2 = _currentValue2;
|
2451 | }
|
2452 | },
|
2453 | _threadCount: {
|
2454 | get: function () {
|
2455 | return context._threadCount;
|
2456 | },
|
2457 | set: function (_threadCount) {
|
2458 | context._threadCount = _threadCount;
|
2459 | }
|
2460 | },
|
2461 | Consumer: {
|
2462 | get: function () {
|
2463 | if (!hasWarnedAboutUsingNestedContextConsumers) {
|
2464 | hasWarnedAboutUsingNestedContextConsumers = true;
|
2465 | warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
|
2466 | }
|
2467 | return context.Consumer;
|
2468 | }
|
2469 | }
|
2470 | });
|
2471 |
|
2472 | context.Consumer = Consumer;
|
2473 | }
|
2474 |
|
2475 | {
|
2476 | context._currentRenderer = null;
|
2477 | context._currentRenderer2 = null;
|
2478 | }
|
2479 |
|
2480 | return context;
|
2481 | }
|
2482 |
|
2483 | function lazy(ctor) {
|
2484 | var lazyType = {
|
2485 | $$typeof: REACT_LAZY_TYPE,
|
2486 | _ctor: ctor,
|
2487 |
|
2488 | _status: -1,
|
2489 | _result: null
|
2490 | };
|
2491 |
|
2492 | {
|
2493 |
|
2494 | var defaultProps = void 0;
|
2495 | var propTypes = void 0;
|
2496 | Object.defineProperties(lazyType, {
|
2497 | defaultProps: {
|
2498 | configurable: true,
|
2499 | get: function () {
|
2500 | return defaultProps;
|
2501 | },
|
2502 | set: function (newDefaultProps) {
|
2503 | warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
|
2504 | defaultProps = newDefaultProps;
|
2505 |
|
2506 | Object.defineProperty(lazyType, 'defaultProps', {
|
2507 | enumerable: true
|
2508 | });
|
2509 | }
|
2510 | },
|
2511 | propTypes: {
|
2512 | configurable: true,
|
2513 | get: function () {
|
2514 | return propTypes;
|
2515 | },
|
2516 | set: function (newPropTypes) {
|
2517 | warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
|
2518 | propTypes = newPropTypes;
|
2519 |
|
2520 | Object.defineProperty(lazyType, 'propTypes', {
|
2521 | enumerable: true
|
2522 | });
|
2523 | }
|
2524 | }
|
2525 | });
|
2526 | }
|
2527 |
|
2528 | return lazyType;
|
2529 | }
|
2530 |
|
2531 | function forwardRef(render) {
|
2532 | {
|
2533 | if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
|
2534 | warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
|
2535 | } else if (typeof render !== 'function') {
|
2536 | warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
2537 | } else {
|
2538 | !(
|
2539 |
|
2540 | render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0;
|
2541 | }
|
2542 |
|
2543 | if (render != null) {
|
2544 | !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
|
2545 | }
|
2546 | }
|
2547 |
|
2548 | return {
|
2549 | $$typeof: REACT_FORWARD_REF_TYPE,
|
2550 | render: render
|
2551 | };
|
2552 | }
|
2553 |
|
2554 | function isValidElementType(type) {
|
2555 | return typeof type === 'string' || typeof type === 'function' ||
|
2556 |
|
2557 | type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
2558 | }
|
2559 |
|
2560 | function memo(type, compare) {
|
2561 | {
|
2562 | if (!isValidElementType(type)) {
|
2563 | warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
|
2564 | }
|
2565 | }
|
2566 | return {
|
2567 | $$typeof: REACT_MEMO_TYPE,
|
2568 | type: type,
|
2569 | compare: compare === undefined ? null : compare
|
2570 | };
|
2571 | }
|
2572 |
|
2573 | function resolveDispatcher() {
|
2574 | var dispatcher = ReactCurrentOwner.currentDispatcher;
|
2575 | !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component.') : void 0;
|
2576 | return dispatcher;
|
2577 | }
|
2578 |
|
2579 | function useContext(Context, observedBits) {
|
2580 | var dispatcher = resolveDispatcher();
|
2581 | {
|
2582 |
|
2583 | if (Context._context !== undefined) {
|
2584 | var realContext = Context._context;
|
2585 |
|
2586 |
|
2587 | if (realContext.Consumer === Context) {
|
2588 | warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
|
2589 | } else if (realContext.Provider === Context) {
|
2590 | warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
|
2591 | }
|
2592 | }
|
2593 | }
|
2594 | return dispatcher.useContext(Context, observedBits);
|
2595 | }
|
2596 |
|
2597 | function useState(initialState) {
|
2598 | var dispatcher = resolveDispatcher();
|
2599 | return dispatcher.useState(initialState);
|
2600 | }
|
2601 |
|
2602 | function useReducer(reducer, initialState, initialAction) {
|
2603 | var dispatcher = resolveDispatcher();
|
2604 | return dispatcher.useReducer(reducer, initialState, initialAction);
|
2605 | }
|
2606 |
|
2607 | function useRef(initialValue) {
|
2608 | var dispatcher = resolveDispatcher();
|
2609 | return dispatcher.useRef(initialValue);
|
2610 | }
|
2611 |
|
2612 | function useEffect(create, inputs) {
|
2613 | var dispatcher = resolveDispatcher();
|
2614 | return dispatcher.useEffect(create, inputs);
|
2615 | }
|
2616 |
|
2617 | function useLayoutEffect(create, inputs) {
|
2618 | var dispatcher = resolveDispatcher();
|
2619 | return dispatcher.useLayoutEffect(create, inputs);
|
2620 | }
|
2621 |
|
2622 | function useCallback(callback, inputs) {
|
2623 | var dispatcher = resolveDispatcher();
|
2624 | return dispatcher.useCallback(callback, inputs);
|
2625 | }
|
2626 |
|
2627 | function useMemo(create, inputs) {
|
2628 | var dispatcher = resolveDispatcher();
|
2629 | return dispatcher.useMemo(create, inputs);
|
2630 | }
|
2631 |
|
2632 | function useImperativeMethods(ref, create, inputs) {
|
2633 | var dispatcher = resolveDispatcher();
|
2634 | return dispatcher.useImperativeMethods(ref, create, inputs);
|
2635 | }
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 |
|
2646 | var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
2647 |
|
2648 | var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
2649 |
|
2650 |
|
2651 |
|
2652 |
|
2653 |
|
2654 |
|
2655 |
|
2656 |
|
2657 |
|
2658 |
|
2659 | var printWarning$1 = function() {};
|
2660 |
|
2661 | {
|
2662 | var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
2663 | var loggedTypeFailures = {};
|
2664 |
|
2665 | printWarning$1 = function(text) {
|
2666 | var message = 'Warning: ' + text;
|
2667 | if (typeof console !== 'undefined') {
|
2668 | console.error(message);
|
2669 | }
|
2670 | try {
|
2671 |
|
2672 |
|
2673 |
|
2674 | throw new Error(message);
|
2675 | } catch (x) {}
|
2676 | };
|
2677 | }
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 |
|
2690 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
2691 | {
|
2692 | for (var typeSpecName in typeSpecs) {
|
2693 | if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
2694 | var error;
|
2695 |
|
2696 |
|
2697 |
|
2698 | try {
|
2699 |
|
2700 |
|
2701 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
2702 | var err = Error(
|
2703 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
2704 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
2705 | );
|
2706 | err.name = 'Invariant Violation';
|
2707 | throw err;
|
2708 | }
|
2709 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
2710 | } catch (ex) {
|
2711 | error = ex;
|
2712 | }
|
2713 | if (error && !(error instanceof Error)) {
|
2714 | printWarning$1(
|
2715 | (componentName || 'React class') + ': type specification of ' +
|
2716 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
2717 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
2718 | 'You may have forgotten to pass an argument to the type checker ' +
|
2719 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
2720 | 'shape all require an argument).'
|
2721 | );
|
2722 |
|
2723 | }
|
2724 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
2725 |
|
2726 |
|
2727 | loggedTypeFailures[error.message] = true;
|
2728 |
|
2729 | var stack = getStack ? getStack() : '';
|
2730 |
|
2731 | printWarning$1(
|
2732 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
2733 | );
|
2734 | }
|
2735 | }
|
2736 | }
|
2737 | }
|
2738 | }
|
2739 |
|
2740 | var checkPropTypes_1 = checkPropTypes;
|
2741 |
|
2742 |
|
2743 |
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 |
|
2749 | var propTypesMisspellWarningShown = void 0;
|
2750 |
|
2751 | {
|
2752 | propTypesMisspellWarningShown = false;
|
2753 | }
|
2754 |
|
2755 | function getDeclarationErrorAddendum() {
|
2756 | if (ReactCurrentOwner.current) {
|
2757 | var name = getComponentName(ReactCurrentOwner.current.type);
|
2758 | if (name) {
|
2759 | return '\n\nCheck the render method of `' + name + '`.';
|
2760 | }
|
2761 | }
|
2762 | return '';
|
2763 | }
|
2764 |
|
2765 | function getSourceInfoErrorAddendum(elementProps) {
|
2766 | if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
|
2767 | var source = elementProps.__source;
|
2768 | var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
2769 | var lineNumber = source.lineNumber;
|
2770 | return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
2771 | }
|
2772 | return '';
|
2773 | }
|
2774 |
|
2775 |
|
2776 |
|
2777 |
|
2778 |
|
2779 |
|
2780 | var ownerHasKeyUseWarning = {};
|
2781 |
|
2782 | function getCurrentComponentErrorInfo(parentType) {
|
2783 | var info = getDeclarationErrorAddendum();
|
2784 |
|
2785 | if (!info) {
|
2786 | var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
2787 | if (parentName) {
|
2788 | info = '\n\nCheck the top-level render call using <' + parentName + '>.';
|
2789 | }
|
2790 | }
|
2791 | return info;
|
2792 | }
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 |
|
2802 |
|
2803 |
|
2804 |
|
2805 | function validateExplicitKey(element, parentType) {
|
2806 | if (!element._store || element._store.validated || element.key != null) {
|
2807 | return;
|
2808 | }
|
2809 | element._store.validated = true;
|
2810 |
|
2811 | var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
2812 | if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
2813 | return;
|
2814 | }
|
2815 | ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
2816 |
|
2817 |
|
2818 |
|
2819 |
|
2820 | var childOwner = '';
|
2821 | if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
2822 |
|
2823 | childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
|
2824 | }
|
2825 |
|
2826 | setCurrentlyValidatingElement(element);
|
2827 | {
|
2828 | warning$1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
2829 | }
|
2830 | setCurrentlyValidatingElement(null);
|
2831 | }
|
2832 |
|
2833 |
|
2834 |
|
2835 |
|
2836 |
|
2837 |
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 | function validateChildKeys(node, parentType) {
|
2843 | if (typeof node !== 'object') {
|
2844 | return;
|
2845 | }
|
2846 | if (Array.isArray(node)) {
|
2847 | for (var i = 0; i < node.length; i++) {
|
2848 | var child = node[i];
|
2849 | if (isValidElement(child)) {
|
2850 | validateExplicitKey(child, parentType);
|
2851 | }
|
2852 | }
|
2853 | } else if (isValidElement(node)) {
|
2854 |
|
2855 | if (node._store) {
|
2856 | node._store.validated = true;
|
2857 | }
|
2858 | } else if (node) {
|
2859 | var iteratorFn = getIteratorFn(node);
|
2860 | if (typeof iteratorFn === 'function') {
|
2861 |
|
2862 |
|
2863 | if (iteratorFn !== node.entries) {
|
2864 | var iterator = iteratorFn.call(node);
|
2865 | var step = void 0;
|
2866 | while (!(step = iterator.next()).done) {
|
2867 | if (isValidElement(step.value)) {
|
2868 | validateExplicitKey(step.value, parentType);
|
2869 | }
|
2870 | }
|
2871 | }
|
2872 | }
|
2873 | }
|
2874 | }
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 |
|
2882 | function validatePropTypes(element) {
|
2883 | var type = element.type;
|
2884 | if (type === null || type === undefined || typeof type === 'string') {
|
2885 | return;
|
2886 | }
|
2887 | var name = getComponentName(type);
|
2888 | var propTypes = void 0;
|
2889 | if (typeof type === 'function') {
|
2890 | propTypes = type.propTypes;
|
2891 | } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
2892 |
|
2893 |
|
2894 | type.$$typeof === REACT_MEMO_TYPE)) {
|
2895 | propTypes = type.propTypes;
|
2896 | } else {
|
2897 | return;
|
2898 | }
|
2899 | if (propTypes) {
|
2900 | setCurrentlyValidatingElement(element);
|
2901 | checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
|
2902 | setCurrentlyValidatingElement(null);
|
2903 | } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
2904 | propTypesMisspellWarningShown = true;
|
2905 | warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
2906 | }
|
2907 | if (typeof type.getDefaultProps === 'function') {
|
2908 | !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
|
2909 | }
|
2910 | }
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 | function validateFragmentProps(fragment) {
|
2917 | setCurrentlyValidatingElement(fragment);
|
2918 |
|
2919 | var keys = Object.keys(fragment.props);
|
2920 | for (var i = 0; i < keys.length; i++) {
|
2921 | var key = keys[i];
|
2922 | if (key !== 'children' && key !== 'key') {
|
2923 | warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
2924 | break;
|
2925 | }
|
2926 | }
|
2927 |
|
2928 | if (fragment.ref !== null) {
|
2929 | warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
|
2930 | }
|
2931 |
|
2932 | setCurrentlyValidatingElement(null);
|
2933 | }
|
2934 |
|
2935 | function createElementWithValidation(type, props, children) {
|
2936 | var validType = isValidElementType(type);
|
2937 |
|
2938 |
|
2939 |
|
2940 | if (!validType) {
|
2941 | var info = '';
|
2942 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
2943 | info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
2944 | }
|
2945 |
|
2946 | var sourceInfo = getSourceInfoErrorAddendum(props);
|
2947 | if (sourceInfo) {
|
2948 | info += sourceInfo;
|
2949 | } else {
|
2950 | info += getDeclarationErrorAddendum();
|
2951 | }
|
2952 |
|
2953 | var typeString = void 0;
|
2954 | if (type === null) {
|
2955 | typeString = 'null';
|
2956 | } else if (Array.isArray(type)) {
|
2957 | typeString = 'array';
|
2958 | } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
2959 | typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
|
2960 | info = ' Did you accidentally export a JSX literal instead of a component?';
|
2961 | } else {
|
2962 | typeString = typeof type;
|
2963 | }
|
2964 |
|
2965 | warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
2966 | }
|
2967 |
|
2968 | var element = createElement.apply(this, arguments);
|
2969 |
|
2970 |
|
2971 |
|
2972 | if (element == null) {
|
2973 | return element;
|
2974 | }
|
2975 |
|
2976 |
|
2977 |
|
2978 |
|
2979 |
|
2980 |
|
2981 | if (validType) {
|
2982 | for (var i = 2; i < arguments.length; i++) {
|
2983 | validateChildKeys(arguments[i], type);
|
2984 | }
|
2985 | }
|
2986 |
|
2987 | if (type === REACT_FRAGMENT_TYPE) {
|
2988 | validateFragmentProps(element);
|
2989 | } else {
|
2990 | validatePropTypes(element);
|
2991 | }
|
2992 |
|
2993 | return element;
|
2994 | }
|
2995 |
|
2996 | function createFactoryWithValidation(type) {
|
2997 | var validatedFactory = createElementWithValidation.bind(null, type);
|
2998 | validatedFactory.type = type;
|
2999 |
|
3000 | {
|
3001 | Object.defineProperty(validatedFactory, 'type', {
|
3002 | enumerable: false,
|
3003 | get: function () {
|
3004 | lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
|
3005 | Object.defineProperty(this, 'type', {
|
3006 | value: type
|
3007 | });
|
3008 | return type;
|
3009 | }
|
3010 | });
|
3011 | }
|
3012 |
|
3013 | return validatedFactory;
|
3014 | }
|
3015 |
|
3016 | function cloneElementWithValidation(element, props, children) {
|
3017 | var newElement = cloneElement.apply(this, arguments);
|
3018 | for (var i = 2; i < arguments.length; i++) {
|
3019 | validateChildKeys(arguments[i], newElement.type);
|
3020 | }
|
3021 | validatePropTypes(newElement);
|
3022 | return newElement;
|
3023 | }
|
3024 |
|
3025 | var React = {
|
3026 | Children: {
|
3027 | map: mapChildren,
|
3028 | forEach: forEachChildren,
|
3029 | count: countChildren,
|
3030 | toArray: toArray,
|
3031 | only: onlyChild
|
3032 | },
|
3033 |
|
3034 | createRef: createRef,
|
3035 | Component: Component,
|
3036 | PureComponent: PureComponent,
|
3037 |
|
3038 | createContext: createContext,
|
3039 | forwardRef: forwardRef,
|
3040 | lazy: lazy,
|
3041 | memo: memo,
|
3042 |
|
3043 | Fragment: REACT_FRAGMENT_TYPE,
|
3044 | StrictMode: REACT_STRICT_MODE_TYPE,
|
3045 | Suspense: REACT_SUSPENSE_TYPE,
|
3046 |
|
3047 | createElement: createElementWithValidation,
|
3048 | cloneElement: cloneElementWithValidation,
|
3049 | createFactory: createFactoryWithValidation,
|
3050 | isValidElement: isValidElement,
|
3051 |
|
3052 | version: ReactVersion,
|
3053 |
|
3054 | unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
|
3055 | unstable_Profiler: REACT_PROFILER_TYPE,
|
3056 |
|
3057 | __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
|
3058 | };
|
3059 |
|
3060 |
|
3061 |
|
3062 |
|
3063 |
|
3064 |
|
3065 | if (enableStableConcurrentModeAPIs) {
|
3066 | React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
3067 | React.Profiler = REACT_PROFILER_TYPE;
|
3068 | React.unstable_ConcurrentMode = undefined;
|
3069 | React.unstable_Profiler = undefined;
|
3070 | }
|
3071 |
|
3072 | if (enableHooks) {
|
3073 | React.useCallback = useCallback;
|
3074 | React.useContext = useContext;
|
3075 | React.useEffect = useEffect;
|
3076 | React.useImperativeMethods = useImperativeMethods;
|
3077 | React.useLayoutEffect = useLayoutEffect;
|
3078 | React.useMemo = useMemo;
|
3079 | React.useReducer = useReducer;
|
3080 | React.useRef = useRef;
|
3081 | React.useState = useState;
|
3082 | }
|
3083 |
|
3084 |
|
3085 |
|
3086 | var React$2 = Object.freeze({
|
3087 | default: React
|
3088 | });
|
3089 |
|
3090 | var React$3 = ( React$2 && React ) || React$2;
|
3091 |
|
3092 |
|
3093 |
|
3094 | var react = React$3.default || React$3;
|
3095 |
|
3096 | return react;
|
3097 |
|
3098 | })));
|