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(require('react')) :
|
14 | typeof define === 'function' && define.amd ? define(['react'], factory) :
|
15 | (global.ReactART = factory(global.React));
|
16 | }(this, (function (React) { 'use strict';
|
17 |
|
18 | function _extends() {
|
19 | _extends = Object.assign || function (target) {
|
20 | for (var i = 1; i < arguments.length; i++) {
|
21 | var source = arguments[i];
|
22 |
|
23 | for (var key in source) {
|
24 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
25 | target[key] = source[key];
|
26 | }
|
27 | }
|
28 | }
|
29 |
|
30 | return target;
|
31 | };
|
32 |
|
33 | return _extends.apply(this, arguments);
|
34 | }
|
35 |
|
36 | function _inheritsLoose(subClass, superClass) {
|
37 | subClass.prototype = Object.create(superClass.prototype);
|
38 | subClass.prototype.constructor = subClass;
|
39 | subClass.__proto__ = superClass;
|
40 | }
|
41 |
|
42 | function _assertThisInitialized(self) {
|
43 | if (self === void 0) {
|
44 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
45 | }
|
46 |
|
47 | return self;
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 | var ReactVersion = '16.11.0';
|
53 |
|
54 | var LegacyRoot = 0;
|
55 | var BatchedRoot = 1;
|
56 | var ConcurrentRoot = 2;
|
57 |
|
58 | var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
59 | var _assign = ReactInternals.assign;
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | var FunctionComponent = 0;
|
66 | var ClassComponent = 1;
|
67 | var IndeterminateComponent = 2;
|
68 |
|
69 | var HostRoot = 3;
|
70 |
|
71 | var HostPortal = 4;
|
72 |
|
73 | var HostComponent = 5;
|
74 | var HostText = 6;
|
75 | var Fragment = 7;
|
76 | var Mode = 8;
|
77 | var ContextConsumer = 9;
|
78 | var ContextProvider = 10;
|
79 | var ForwardRef = 11;
|
80 | var Profiler = 12;
|
81 | var SuspenseComponent = 13;
|
82 | var MemoComponent = 14;
|
83 | var SimpleMemoComponent = 15;
|
84 | var LazyComponent = 16;
|
85 | var IncompleteClassComponent = 17;
|
86 | var DehydratedFragment = 18;
|
87 | var SuspenseListComponent = 19;
|
88 | var FundamentalComponent = 20;
|
89 | var ScopeComponent = 21;
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | var warningWithoutStack = function () {};
|
109 |
|
110 | {
|
111 | warningWithoutStack = function (condition, format) {
|
112 | for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
113 | args[_key - 2] = arguments[_key];
|
114 | }
|
115 |
|
116 | if (format === undefined) {
|
117 | throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
118 | }
|
119 |
|
120 | if (args.length > 8) {
|
121 |
|
122 | throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
123 | }
|
124 |
|
125 | if (condition) {
|
126 | return;
|
127 | }
|
128 |
|
129 | if (typeof console !== 'undefined') {
|
130 | var argsWithFormat = args.map(function (item) {
|
131 | return '' + item;
|
132 | });
|
133 | argsWithFormat.unshift('Warning: ' + format);
|
134 |
|
135 |
|
136 | Function.prototype.apply.call(console.error, console, argsWithFormat);
|
137 | }
|
138 |
|
139 | try {
|
140 |
|
141 |
|
142 |
|
143 | var argIndex = 0;
|
144 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
145 | return args[argIndex++];
|
146 | });
|
147 | throw new Error(message);
|
148 | } catch (x) {}
|
149 | };
|
150 | }
|
151 |
|
152 | var warningWithoutStack$1 = warningWithoutStack;
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 | function get(key) {
|
171 | return key._reactInternalFiber;
|
172 | }
|
173 |
|
174 | function set$1(key, value) {
|
175 | key._reactInternalFiber = value;
|
176 | }
|
177 |
|
178 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
179 |
|
180 |
|
181 |
|
182 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
183 | ReactSharedInternals.ReactCurrentDispatcher = {
|
184 | current: null
|
185 | };
|
186 | }
|
187 |
|
188 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
189 | ReactSharedInternals.ReactCurrentBatchConfig = {
|
190 | suspense: null
|
191 | };
|
192 | }
|
193 |
|
194 |
|
195 |
|
196 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
197 | var REACT_ELEMENT_TYPE$1 = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
198 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
199 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
200 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
201 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
202 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
203 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
204 |
|
205 |
|
206 |
|
207 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
208 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
209 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
210 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
211 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
212 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
213 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
214 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
215 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
216 | var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
217 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
218 | function getIteratorFn(maybeIterable) {
|
219 | if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
220 | return null;
|
221 | }
|
222 |
|
223 | var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
224 |
|
225 | if (typeof maybeIterator === 'function') {
|
226 | return maybeIterator;
|
227 | }
|
228 |
|
229 | return null;
|
230 | }
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 | var warning = warningWithoutStack$1;
|
240 |
|
241 | {
|
242 | warning = function (condition, format) {
|
243 | if (condition) {
|
244 | return;
|
245 | }
|
246 |
|
247 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
248 | var stack = ReactDebugCurrentFrame.getStackAddendum();
|
249 |
|
250 | for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
251 | args[_key - 2] = arguments[_key];
|
252 | }
|
253 |
|
254 | warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
|
255 | };
|
256 | }
|
257 |
|
258 | var warning$1 = warning;
|
259 |
|
260 | var Uninitialized = -1;
|
261 | var Pending = 0;
|
262 | var Resolved = 1;
|
263 | var Rejected = 2;
|
264 | function refineResolvedLazyComponent(lazyComponent) {
|
265 | return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
266 | }
|
267 | function initializeLazyComponentType(lazyComponent) {
|
268 | if (lazyComponent._status === Uninitialized) {
|
269 | lazyComponent._status = Pending;
|
270 | var ctor = lazyComponent._ctor;
|
271 | var thenable = ctor();
|
272 | lazyComponent._result = thenable;
|
273 | thenable.then(function (moduleObject) {
|
274 | if (lazyComponent._status === Pending) {
|
275 | var defaultExport = moduleObject.default;
|
276 |
|
277 | {
|
278 | if (defaultExport === undefined) {
|
279 | warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
|
280 | }
|
281 | }
|
282 |
|
283 | lazyComponent._status = Resolved;
|
284 | lazyComponent._result = defaultExport;
|
285 | }
|
286 | }, function (error) {
|
287 | if (lazyComponent._status === Pending) {
|
288 | lazyComponent._status = Rejected;
|
289 | lazyComponent._result = error;
|
290 | }
|
291 | });
|
292 | }
|
293 | }
|
294 |
|
295 | function getWrappedName(outerType, innerType, wrapperName) {
|
296 | var functionName = innerType.displayName || innerType.name || '';
|
297 | return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
298 | }
|
299 |
|
300 | function getComponentName(type) {
|
301 | if (type == null) {
|
302 |
|
303 | return null;
|
304 | }
|
305 |
|
306 | {
|
307 | if (typeof type.tag === 'number') {
|
308 | warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
309 | }
|
310 | }
|
311 |
|
312 | if (typeof type === 'function') {
|
313 | return type.displayName || type.name || null;
|
314 | }
|
315 |
|
316 | if (typeof type === 'string') {
|
317 | return type;
|
318 | }
|
319 |
|
320 | switch (type) {
|
321 | case REACT_FRAGMENT_TYPE:
|
322 | return 'Fragment';
|
323 |
|
324 | case REACT_PORTAL_TYPE:
|
325 | return 'Portal';
|
326 |
|
327 | case REACT_PROFILER_TYPE:
|
328 | return "Profiler";
|
329 |
|
330 | case REACT_STRICT_MODE_TYPE:
|
331 | return 'StrictMode';
|
332 |
|
333 | case REACT_SUSPENSE_TYPE:
|
334 | return 'Suspense';
|
335 |
|
336 | case REACT_SUSPENSE_LIST_TYPE:
|
337 | return 'SuspenseList';
|
338 | }
|
339 |
|
340 | if (typeof type === 'object') {
|
341 | switch (type.$$typeof) {
|
342 | case REACT_CONTEXT_TYPE:
|
343 | return 'Context.Consumer';
|
344 |
|
345 | case REACT_PROVIDER_TYPE:
|
346 | return 'Context.Provider';
|
347 |
|
348 | case REACT_FORWARD_REF_TYPE:
|
349 | return getWrappedName(type, type.render, 'ForwardRef');
|
350 |
|
351 | case REACT_MEMO_TYPE:
|
352 | return getComponentName(type.type);
|
353 |
|
354 | case REACT_LAZY_TYPE:
|
355 | {
|
356 | var thenable = type;
|
357 | var resolvedThenable = refineResolvedLazyComponent(thenable);
|
358 |
|
359 | if (resolvedThenable) {
|
360 | return getComponentName(resolvedThenable);
|
361 | }
|
362 |
|
363 | break;
|
364 | }
|
365 | }
|
366 | }
|
367 |
|
368 | return null;
|
369 | }
|
370 |
|
371 |
|
372 | var NoEffect =
|
373 |
|
374 | 0;
|
375 | var PerformedWork =
|
376 |
|
377 | 1;
|
378 |
|
379 | var Placement =
|
380 |
|
381 | 2;
|
382 | var Update =
|
383 |
|
384 | 4;
|
385 | var PlacementAndUpdate =
|
386 |
|
387 | 6;
|
388 | var Deletion =
|
389 |
|
390 | 8;
|
391 | var ContentReset =
|
392 |
|
393 | 16;
|
394 | var Callback =
|
395 |
|
396 | 32;
|
397 | var DidCapture =
|
398 |
|
399 | 64;
|
400 | var Ref =
|
401 |
|
402 | 128;
|
403 | var Snapshot =
|
404 |
|
405 | 256;
|
406 | var Passive =
|
407 |
|
408 | 512;
|
409 | var Hydrating =
|
410 |
|
411 | 1024;
|
412 | var HydratingAndUpdate =
|
413 |
|
414 | 1028;
|
415 |
|
416 | var LifecycleEffectMask =
|
417 |
|
418 | 932;
|
419 |
|
420 | var HostEffectMask =
|
421 |
|
422 | 2047;
|
423 | var Incomplete =
|
424 |
|
425 | 2048;
|
426 | var ShouldCapture =
|
427 |
|
428 | 4096;
|
429 |
|
430 | var enableUserTimingAPI = true;
|
431 |
|
432 | var debugRenderPhaseSideEffects = false;
|
433 |
|
434 |
|
435 |
|
436 |
|
437 | var debugRenderPhaseSideEffectsForStrictMode = true;
|
438 |
|
439 |
|
440 | var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
|
441 |
|
442 | var warnAboutDeprecatedLifecycles = true;
|
443 |
|
444 | var enableProfilerTimer = true;
|
445 |
|
446 | var enableSchedulerTracing = true;
|
447 |
|
448 | var enableSuspenseServerRenderer = false;
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 | var enableFlareAPI = false;
|
465 |
|
466 | var enableFundamentalAPI = false;
|
467 |
|
468 | var enableScopeAPI = false;
|
469 |
|
470 |
|
471 |
|
472 |
|
473 | var warnAboutUnmockedScheduler = false;
|
474 |
|
475 |
|
476 | var flushSuspenseFallbacksInTests = true;
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 | var enableSuspenseCallback = false;
|
483 |
|
484 |
|
485 |
|
486 | var warnAboutDefaultPropsOnFunctionComponents = false;
|
487 | var warnAboutStringRefs = false;
|
488 | var disableLegacyContext = false;
|
489 | var disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
490 |
|
491 | var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
492 | function getNearestMountedFiber(fiber) {
|
493 | var node = fiber;
|
494 | var nearestMounted = fiber;
|
495 |
|
496 | if (!fiber.alternate) {
|
497 |
|
498 |
|
499 | var nextNode = node;
|
500 |
|
501 | do {
|
502 | node = nextNode;
|
503 |
|
504 | if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
|
505 |
|
506 |
|
507 |
|
508 | nearestMounted = node.return;
|
509 | }
|
510 |
|
511 | nextNode = node.return;
|
512 | } while (nextNode);
|
513 | } else {
|
514 | while (node.return) {
|
515 | node = node.return;
|
516 | }
|
517 | }
|
518 |
|
519 | if (node.tag === HostRoot) {
|
520 |
|
521 |
|
522 | return nearestMounted;
|
523 | }
|
524 |
|
525 |
|
526 |
|
527 | return null;
|
528 | }
|
529 |
|
530 |
|
531 | function isFiberMounted(fiber) {
|
532 | return getNearestMountedFiber(fiber) === fiber;
|
533 | }
|
534 | function isMounted(component) {
|
535 | {
|
536 | var owner = ReactCurrentOwner.current;
|
537 |
|
538 | if (owner !== null && owner.tag === ClassComponent) {
|
539 | var ownerFiber = owner;
|
540 | var instance = ownerFiber.stateNode;
|
541 | !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component') : void 0;
|
542 | instance._warnedAboutRefsInRender = true;
|
543 | }
|
544 | }
|
545 |
|
546 | var fiber = get(component);
|
547 |
|
548 | if (!fiber) {
|
549 | return false;
|
550 | }
|
551 |
|
552 | return getNearestMountedFiber(fiber) === fiber;
|
553 | }
|
554 |
|
555 | function assertIsMounted(fiber) {
|
556 | if (!(getNearestMountedFiber(fiber) === fiber)) {
|
557 | {
|
558 | throw Error("Unable to find node on an unmounted component.");
|
559 | }
|
560 | }
|
561 | }
|
562 |
|
563 | function findCurrentFiberUsingSlowPath(fiber) {
|
564 | var alternate = fiber.alternate;
|
565 |
|
566 | if (!alternate) {
|
567 |
|
568 | var nearestMounted = getNearestMountedFiber(fiber);
|
569 |
|
570 | if (!(nearestMounted !== null)) {
|
571 | {
|
572 | throw Error("Unable to find node on an unmounted component.");
|
573 | }
|
574 | }
|
575 |
|
576 | if (nearestMounted !== fiber) {
|
577 | return null;
|
578 | }
|
579 |
|
580 | return fiber;
|
581 | }
|
582 |
|
583 |
|
584 |
|
585 |
|
586 | var a = fiber;
|
587 | var b = alternate;
|
588 |
|
589 | while (true) {
|
590 | var parentA = a.return;
|
591 |
|
592 | if (parentA === null) {
|
593 |
|
594 | break;
|
595 | }
|
596 |
|
597 | var parentB = parentA.alternate;
|
598 |
|
599 | if (parentB === null) {
|
600 |
|
601 |
|
602 |
|
603 |
|
604 | var nextParent = parentA.return;
|
605 |
|
606 | if (nextParent !== null) {
|
607 | a = b = nextParent;
|
608 | continue;
|
609 | }
|
610 |
|
611 |
|
612 | break;
|
613 | }
|
614 |
|
615 |
|
616 |
|
617 |
|
618 | if (parentA.child === parentB.child) {
|
619 | var child = parentA.child;
|
620 |
|
621 | while (child) {
|
622 | if (child === a) {
|
623 |
|
624 | assertIsMounted(parentA);
|
625 | return fiber;
|
626 | }
|
627 |
|
628 | if (child === b) {
|
629 |
|
630 | assertIsMounted(parentA);
|
631 | return alternate;
|
632 | }
|
633 |
|
634 | child = child.sibling;
|
635 | }
|
636 |
|
637 |
|
638 |
|
639 | {
|
640 | {
|
641 | throw Error("Unable to find node on an unmounted component.");
|
642 | }
|
643 | }
|
644 | }
|
645 |
|
646 | if (a.return !== b.return) {
|
647 |
|
648 |
|
649 |
|
650 |
|
651 | a = parentA;
|
652 | b = parentB;
|
653 | } else {
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 | var didFindChild = false;
|
660 | var _child = parentA.child;
|
661 |
|
662 | while (_child) {
|
663 | if (_child === a) {
|
664 | didFindChild = true;
|
665 | a = parentA;
|
666 | b = parentB;
|
667 | break;
|
668 | }
|
669 |
|
670 | if (_child === b) {
|
671 | didFindChild = true;
|
672 | b = parentA;
|
673 | a = parentB;
|
674 | break;
|
675 | }
|
676 |
|
677 | _child = _child.sibling;
|
678 | }
|
679 |
|
680 | if (!didFindChild) {
|
681 |
|
682 | _child = parentB.child;
|
683 |
|
684 | while (_child) {
|
685 | if (_child === a) {
|
686 | didFindChild = true;
|
687 | a = parentB;
|
688 | b = parentA;
|
689 | break;
|
690 | }
|
691 |
|
692 | if (_child === b) {
|
693 | didFindChild = true;
|
694 | b = parentB;
|
695 | a = parentA;
|
696 | break;
|
697 | }
|
698 |
|
699 | _child = _child.sibling;
|
700 | }
|
701 |
|
702 | if (!didFindChild) {
|
703 | {
|
704 | throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.");
|
705 | }
|
706 | }
|
707 | }
|
708 | }
|
709 |
|
710 | if (!(a.alternate === b)) {
|
711 | {
|
712 | throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.");
|
713 | }
|
714 | }
|
715 | }
|
716 |
|
717 |
|
718 |
|
719 | if (!(a.tag === HostRoot)) {
|
720 | {
|
721 | throw Error("Unable to find node on an unmounted component.");
|
722 | }
|
723 | }
|
724 |
|
725 | if (a.stateNode.current === a) {
|
726 |
|
727 | return fiber;
|
728 | }
|
729 |
|
730 |
|
731 | return alternate;
|
732 | }
|
733 | function findCurrentHostFiber(parent) {
|
734 | var currentParent = findCurrentFiberUsingSlowPath(parent);
|
735 |
|
736 | if (!currentParent) {
|
737 | return null;
|
738 | }
|
739 |
|
740 |
|
741 | var node = currentParent;
|
742 |
|
743 | while (true) {
|
744 | if (node.tag === HostComponent || node.tag === HostText) {
|
745 | return node;
|
746 | } else if (node.child) {
|
747 | node.child.return = node;
|
748 | node = node.child;
|
749 | continue;
|
750 | }
|
751 |
|
752 | if (node === currentParent) {
|
753 | return null;
|
754 | }
|
755 |
|
756 | while (!node.sibling) {
|
757 | if (!node.return || node.return === currentParent) {
|
758 | return null;
|
759 | }
|
760 |
|
761 | node = node.return;
|
762 | }
|
763 |
|
764 | node.sibling.return = node.return;
|
765 | node = node.sibling;
|
766 | }
|
767 |
|
768 |
|
769 |
|
770 | return null;
|
771 | }
|
772 |
|
773 | var _class = function(mixins){
|
774 | var proto = {};
|
775 | for (var i = 0, l = arguments.length; i < l; i++){
|
776 | var mixin = arguments[i];
|
777 | if (typeof mixin == 'function') mixin = mixin.prototype;
|
778 | for (var key in mixin) proto[key] = mixin[key];
|
779 | }
|
780 | if (!proto.initialize) proto.initialize = function(){};
|
781 | proto.constructor = function(a,b,c,d,e,f,g,h){
|
782 | return new proto.initialize(a,b,c,d,e,f,g,h);
|
783 | };
|
784 | proto.constructor.prototype = proto.initialize.prototype = proto;
|
785 | return proto.constructor;
|
786 | };
|
787 |
|
788 | function Transform(xx, yx, xy, yy, x, y){
|
789 | if (xx && typeof xx == 'object'){
|
790 | yx = xx.yx; yy = xx.yy; y = xx.y;
|
791 | xy = xx.xy; x = xx.x; xx = xx.xx;
|
792 | }
|
793 | this.xx = xx == null ? 1 : xx;
|
794 | this.yx = yx || 0;
|
795 | this.xy = xy || 0;
|
796 | this.yy = yy == null ? 1 : yy;
|
797 | this.x = (x == null ? this.x : x) || 0;
|
798 | this.y = (y == null ? this.y : y) || 0;
|
799 | this._transform();
|
800 | return this;
|
801 | }
|
802 |
|
803 | var transform = _class({
|
804 |
|
805 | initialize: Transform,
|
806 |
|
807 | _transform: function(){},
|
808 |
|
809 | xx: 1, yx: 0, x: 0,
|
810 | xy: 0, yy: 1, y: 0,
|
811 |
|
812 | transform: function(xx, yx, xy, yy, x, y){
|
813 | var m = this;
|
814 | if (xx && typeof xx == 'object'){
|
815 | yx = xx.yx; yy = xx.yy; y = xx.y;
|
816 | xy = xx.xy; x = xx.x; xx = xx.xx;
|
817 | }
|
818 | if (!x) x = 0;
|
819 | if (!y) y = 0;
|
820 | return this.transformTo(
|
821 | m.xx * xx + m.xy * yx,
|
822 | m.yx * xx + m.yy * yx,
|
823 | m.xx * xy + m.xy * yy,
|
824 | m.yx * xy + m.yy * yy,
|
825 | m.xx * x + m.xy * y + m.x,
|
826 | m.yx * x + m.yy * y + m.y
|
827 | );
|
828 | },
|
829 |
|
830 | transformTo: Transform,
|
831 |
|
832 | translate: function(x, y){
|
833 | return this.transform(1, 0, 0, 1, x, y);
|
834 | },
|
835 |
|
836 | move: function(x, y){
|
837 | this.x += x || 0;
|
838 | this.y += y || 0;
|
839 | this._transform();
|
840 | return this;
|
841 | },
|
842 |
|
843 | scale: function(x, y){
|
844 | if (y == null) y = x;
|
845 | return this.transform(x, 0, 0, y, 0, 0);
|
846 | },
|
847 |
|
848 | rotate: function(deg, x, y){
|
849 | if (x == null || y == null){
|
850 | x = (this.left || 0) + (this.width || 0) / 2;
|
851 | y = (this.top || 0) + (this.height || 0) / 2;
|
852 | }
|
853 |
|
854 | var rad = deg * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
|
855 |
|
856 | this.transform(1, 0, 0, 1, x, y);
|
857 | var m = this;
|
858 |
|
859 | return this.transformTo(
|
860 | cos * m.xx - sin * m.yx,
|
861 | sin * m.xx + cos * m.yx,
|
862 | cos * m.xy - sin * m.yy,
|
863 | sin * m.xy + cos * m.yy,
|
864 | m.x,
|
865 | m.y
|
866 | ).transform(1, 0, 0, 1, -x, -y);
|
867 | },
|
868 |
|
869 | moveTo: function(x, y){
|
870 | var m = this;
|
871 | return this.transformTo(m.xx, m.yx, m.xy, m.yy, x, y);
|
872 | },
|
873 |
|
874 | rotateTo: function(deg, x, y){
|
875 | var m = this;
|
876 | var flip = m.yx / m.xx > m.yy / m.xy ? -1 : 1;
|
877 | if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = -flip;
|
878 | return this.rotate(deg - Math.atan2(flip * m.yx, flip * m.xx) * 180 / Math.PI, x, y);
|
879 | },
|
880 |
|
881 | scaleTo: function(x, y){
|
882 |
|
883 | var m = this;
|
884 |
|
885 | var h = Math.sqrt(m.xx * m.xx + m.yx * m.yx);
|
886 | m.xx /= h; m.yx /= h;
|
887 |
|
888 | h = Math.sqrt(m.yy * m.yy + m.xy * m.xy);
|
889 | m.yy /= h; m.xy /= h;
|
890 |
|
891 | return this.scale(x, y);
|
892 | },
|
893 |
|
894 | resizeTo: function(width, height){
|
895 | var w = this.width, h = this.height;
|
896 | if (!w || !h) return this;
|
897 | return this.scaleTo(width / w, height / h);
|
898 | },
|
899 |
|
900 | |
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 | inversePoint: function(x, y){
|
915 | var a = this.xx, b = this.yx,
|
916 | c = this.xy, d = this.yy,
|
917 | e = this.x, f = this.y;
|
918 | var det = b * c - a * d;
|
919 | if (det == 0) return null;
|
920 | return {
|
921 | x: (d * (e - x) + c * (y - f)) / det,
|
922 | y: (a * (f - y) + b * (x - e)) / det
|
923 | };
|
924 | },
|
925 |
|
926 | point: function(x, y){
|
927 | var m = this;
|
928 | return {
|
929 | x: m.xx * x + m.xy * y + m.x,
|
930 | y: m.yx * x + m.yy * y + m.y
|
931 | };
|
932 | }
|
933 |
|
934 | });
|
935 |
|
936 | var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 | function createCommonjsModule(fn, module) {
|
943 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
944 | }
|
945 |
|
946 | var current = createCommonjsModule(function (module, exports) {
|
947 | function warning(){
|
948 | throw new Error('You must require a mode before requiring anything else.');
|
949 | }
|
950 |
|
951 | exports.Surface = warning;
|
952 | exports.Path = warning;
|
953 | exports.Shape = warning;
|
954 | exports.Group = warning;
|
955 | exports.ClippingRectangle = warning;
|
956 | exports.Text = warning;
|
957 |
|
958 | exports.setCurrent = function(mode){
|
959 | for (var key in mode){
|
960 | exports[key] = mode[key];
|
961 | }
|
962 | };
|
963 | });
|
964 |
|
965 | var current_1 = current.Surface;
|
966 | var current_2 = current.Path;
|
967 | var current_3 = current.Shape;
|
968 | var current_4 = current.Group;
|
969 | var current_5 = current.ClippingRectangle;
|
970 | var current_6 = current.Text;
|
971 | var current_7 = current.setCurrent;
|
972 |
|
973 | var TYPES = {
|
974 | CLIPPING_RECTANGLE: 'ClippingRectangle',
|
975 | GROUP: 'Group',
|
976 | SHAPE: 'Shape',
|
977 | TEXT: 'Text'
|
978 | };
|
979 | var EVENT_TYPES = {
|
980 | onClick: 'click',
|
981 | onMouseMove: 'mousemove',
|
982 | onMouseOver: 'mouseover',
|
983 | onMouseOut: 'mouseout',
|
984 | onMouseUp: 'mouseup',
|
985 | onMouseDown: 'mousedown'
|
986 | };
|
987 | function childrenAsString(children) {
|
988 | if (!children) {
|
989 | return '';
|
990 | } else if (typeof children === 'string') {
|
991 | return children;
|
992 | } else if (children.length) {
|
993 | return children.join('');
|
994 | } else {
|
995 | return '';
|
996 | }
|
997 | }
|
998 |
|
999 |
|
1000 |
|
1001 | function shim() {
|
1002 | {
|
1003 | {
|
1004 | throw Error("The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.");
|
1005 | }
|
1006 | }
|
1007 | }
|
1008 |
|
1009 |
|
1010 | var supportsPersistence = false;
|
1011 | var cloneInstance = shim;
|
1012 | var cloneFundamentalInstance = shim;
|
1013 | var createContainerChildSet = shim;
|
1014 | var appendChildToContainerChildSet = shim;
|
1015 | var finalizeContainerChildren = shim;
|
1016 | var replaceContainerChildren = shim;
|
1017 | var cloneHiddenInstance = shim;
|
1018 | var cloneHiddenTextInstance = shim;
|
1019 |
|
1020 |
|
1021 |
|
1022 | function shim$1() {
|
1023 | {
|
1024 | {
|
1025 | throw Error("The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.");
|
1026 | }
|
1027 | }
|
1028 | }
|
1029 |
|
1030 |
|
1031 | var supportsHydration = false;
|
1032 | var canHydrateInstance = shim$1;
|
1033 | var canHydrateTextInstance = shim$1;
|
1034 | var canHydrateSuspenseInstance = shim$1;
|
1035 | var isSuspenseInstancePending = shim$1;
|
1036 | var isSuspenseInstanceFallback = shim$1;
|
1037 | var registerSuspenseInstanceRetry = shim$1;
|
1038 | var getNextHydratableSibling = shim$1;
|
1039 | var getFirstHydratableChild = shim$1;
|
1040 | var hydrateInstance = shim$1;
|
1041 | var hydrateTextInstance = shim$1;
|
1042 | var hydrateSuspenseInstance = shim$1;
|
1043 | var getNextHydratableInstanceAfterSuspenseInstance = shim$1;
|
1044 | var commitHydratedContainer = shim$1;
|
1045 | var commitHydratedSuspenseInstance = shim$1;
|
1046 | var clearSuspenseBoundary = shim$1;
|
1047 | var clearSuspenseBoundaryFromContainer = shim$1;
|
1048 | var didNotMatchHydratedContainerTextInstance = shim$1;
|
1049 | var didNotMatchHydratedTextInstance = shim$1;
|
1050 | var didNotHydrateContainerInstance = shim$1;
|
1051 | var didNotHydrateInstance = shim$1;
|
1052 | var didNotFindHydratableContainerInstance = shim$1;
|
1053 | var didNotFindHydratableContainerTextInstance = shim$1;
|
1054 | var didNotFindHydratableContainerSuspenseInstance = shim$1;
|
1055 | var didNotFindHydratableInstance = shim$1;
|
1056 | var didNotFindHydratableTextInstance = shim$1;
|
1057 | var didNotFindHydratableSuspenseInstance = shim$1;
|
1058 |
|
1059 | var pooledTransform = new transform();
|
1060 | var NO_CONTEXT = {};
|
1061 | var UPDATE_SIGNAL = {};
|
1062 |
|
1063 | {
|
1064 | Object.freeze(NO_CONTEXT);
|
1065 | Object.freeze(UPDATE_SIGNAL);
|
1066 | }
|
1067 |
|
1068 |
|
1069 |
|
1070 | function addEventListeners(instance, type, listener) {
|
1071 |
|
1072 |
|
1073 | if (!instance._listeners) {
|
1074 | instance._listeners = {};
|
1075 | instance._subscriptions = {};
|
1076 | }
|
1077 |
|
1078 | instance._listeners[type] = listener;
|
1079 |
|
1080 | if (listener) {
|
1081 | if (!instance._subscriptions[type]) {
|
1082 | instance._subscriptions[type] = instance.subscribe(type, createEventHandler(instance), instance);
|
1083 | }
|
1084 | } else {
|
1085 | if (instance._subscriptions[type]) {
|
1086 | instance._subscriptions[type]();
|
1087 |
|
1088 | delete instance._subscriptions[type];
|
1089 | }
|
1090 | }
|
1091 | }
|
1092 |
|
1093 | function createEventHandler(instance) {
|
1094 | return function handleEvent(event) {
|
1095 | var listener = instance._listeners[event.type];
|
1096 |
|
1097 | if (!listener) {
|
1098 | } else if (typeof listener === 'function') {
|
1099 | listener.call(instance, event);
|
1100 | } else if (listener.handleEvent) {
|
1101 | listener.handleEvent(event);
|
1102 | }
|
1103 | };
|
1104 | }
|
1105 |
|
1106 | function destroyEventListeners(instance) {
|
1107 | if (instance._subscriptions) {
|
1108 | for (var type in instance._subscriptions) {
|
1109 | instance._subscriptions[type]();
|
1110 | }
|
1111 | }
|
1112 |
|
1113 | instance._subscriptions = null;
|
1114 | instance._listeners = null;
|
1115 | }
|
1116 |
|
1117 | function getScaleX(props) {
|
1118 | if (props.scaleX != null) {
|
1119 | return props.scaleX;
|
1120 | } else if (props.scale != null) {
|
1121 | return props.scale;
|
1122 | } else {
|
1123 | return 1;
|
1124 | }
|
1125 | }
|
1126 |
|
1127 | function getScaleY(props) {
|
1128 | if (props.scaleY != null) {
|
1129 | return props.scaleY;
|
1130 | } else if (props.scale != null) {
|
1131 | return props.scale;
|
1132 | } else {
|
1133 | return 1;
|
1134 | }
|
1135 | }
|
1136 |
|
1137 | function isSameFont(oldFont, newFont) {
|
1138 | if (oldFont === newFont) {
|
1139 | return true;
|
1140 | } else if (typeof newFont === 'string' || typeof oldFont === 'string') {
|
1141 | return false;
|
1142 | } else {
|
1143 | return newFont.fontSize === oldFont.fontSize && newFont.fontStyle === oldFont.fontStyle && newFont.fontVariant === oldFont.fontVariant && newFont.fontWeight === oldFont.fontWeight && newFont.fontFamily === oldFont.fontFamily;
|
1144 | }
|
1145 | }
|
1146 |
|
1147 |
|
1148 |
|
1149 | function applyClippingRectangleProps(instance, props) {
|
1150 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1151 | applyNodeProps(instance, props, prevProps);
|
1152 | instance.width = props.width;
|
1153 | instance.height = props.height;
|
1154 | }
|
1155 |
|
1156 | function applyGroupProps(instance, props) {
|
1157 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1158 | applyNodeProps(instance, props, prevProps);
|
1159 | instance.width = props.width;
|
1160 | instance.height = props.height;
|
1161 | }
|
1162 |
|
1163 | function applyNodeProps(instance, props) {
|
1164 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1165 | var scaleX = getScaleX(props);
|
1166 | var scaleY = getScaleY(props);
|
1167 | pooledTransform.transformTo(1, 0, 0, 1, 0, 0).move(props.x || 0, props.y || 0).rotate(props.rotation || 0, props.originX, props.originY).scale(scaleX, scaleY, props.originX, props.originY);
|
1168 |
|
1169 | if (props.transform != null) {
|
1170 | pooledTransform.transform(props.transform);
|
1171 | }
|
1172 |
|
1173 | if (instance.xx !== pooledTransform.xx || instance.yx !== pooledTransform.yx || instance.xy !== pooledTransform.xy || instance.yy !== pooledTransform.yy || instance.x !== pooledTransform.x || instance.y !== pooledTransform.y) {
|
1174 | instance.transformTo(pooledTransform);
|
1175 | }
|
1176 |
|
1177 | if (props.cursor !== prevProps.cursor || props.title !== prevProps.title) {
|
1178 | instance.indicate(props.cursor, props.title);
|
1179 | }
|
1180 |
|
1181 | if (instance.blend && props.opacity !== prevProps.opacity) {
|
1182 | instance.blend(props.opacity == null ? 1 : props.opacity);
|
1183 | }
|
1184 |
|
1185 | if (props.visible !== prevProps.visible) {
|
1186 | if (props.visible == null || props.visible) {
|
1187 | instance.show();
|
1188 | } else {
|
1189 | instance.hide();
|
1190 | }
|
1191 | }
|
1192 |
|
1193 | for (var type in EVENT_TYPES) {
|
1194 | addEventListeners(instance, EVENT_TYPES[type], props[type]);
|
1195 | }
|
1196 | }
|
1197 |
|
1198 | function applyRenderableNodeProps(instance, props) {
|
1199 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1200 | applyNodeProps(instance, props, prevProps);
|
1201 |
|
1202 | if (prevProps.fill !== props.fill) {
|
1203 | if (props.fill && props.fill.applyFill) {
|
1204 | props.fill.applyFill(instance);
|
1205 | } else {
|
1206 | instance.fill(props.fill);
|
1207 | }
|
1208 | }
|
1209 |
|
1210 | if (prevProps.stroke !== props.stroke || prevProps.strokeWidth !== props.strokeWidth || prevProps.strokeCap !== props.strokeCap || prevProps.strokeJoin !== props.strokeJoin ||
|
1211 | prevProps.strokeDash !== props.strokeDash) {
|
1212 | instance.stroke(props.stroke, props.strokeWidth, props.strokeCap, props.strokeJoin, props.strokeDash);
|
1213 | }
|
1214 | }
|
1215 |
|
1216 | function applyShapeProps(instance, props) {
|
1217 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1218 | applyRenderableNodeProps(instance, props, prevProps);
|
1219 | var path = props.d || childrenAsString(props.children);
|
1220 | var prevDelta = instance._prevDelta;
|
1221 | var prevPath = instance._prevPath;
|
1222 |
|
1223 | if (path !== prevPath || path.delta !== prevDelta || prevProps.height !== props.height || prevProps.width !== props.width) {
|
1224 | instance.draw(path, props.width, props.height);
|
1225 | instance._prevDelta = path.delta;
|
1226 | instance._prevPath = path;
|
1227 | }
|
1228 | }
|
1229 |
|
1230 | function applyTextProps(instance, props) {
|
1231 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1232 | applyRenderableNodeProps(instance, props, prevProps);
|
1233 | var string = props.children;
|
1234 |
|
1235 | if (instance._currentString !== string || !isSameFont(props.font, prevProps.font) || props.alignment !== prevProps.alignment || props.path !== prevProps.path) {
|
1236 | instance.draw(string, props.font, props.alignment, props.path);
|
1237 | instance._currentString = string;
|
1238 | }
|
1239 | }
|
1240 |
|
1241 | function appendInitialChild(parentInstance, child) {
|
1242 | if (typeof child === 'string') {
|
1243 |
|
1244 | {
|
1245 | {
|
1246 | throw Error("Text children should already be flattened.");
|
1247 | }
|
1248 | }
|
1249 |
|
1250 | return;
|
1251 | }
|
1252 |
|
1253 | child.inject(parentInstance);
|
1254 | }
|
1255 | function createInstance(type, props, internalInstanceHandle) {
|
1256 | var instance;
|
1257 |
|
1258 | switch (type) {
|
1259 | case TYPES.CLIPPING_RECTANGLE:
|
1260 | instance = current.ClippingRectangle();
|
1261 | instance._applyProps = applyClippingRectangleProps;
|
1262 | break;
|
1263 |
|
1264 | case TYPES.GROUP:
|
1265 | instance = current.Group();
|
1266 | instance._applyProps = applyGroupProps;
|
1267 | break;
|
1268 |
|
1269 | case TYPES.SHAPE:
|
1270 | instance = current.Shape();
|
1271 | instance._applyProps = applyShapeProps;
|
1272 | break;
|
1273 |
|
1274 | case TYPES.TEXT:
|
1275 | instance = current.Text(props.children, props.font, props.alignment, props.path);
|
1276 | instance._applyProps = applyTextProps;
|
1277 | break;
|
1278 | }
|
1279 |
|
1280 | if (!instance) {
|
1281 | {
|
1282 | throw Error("ReactART does not support the type \"" + type + "\"");
|
1283 | }
|
1284 | }
|
1285 |
|
1286 | instance._applyProps(instance, props);
|
1287 |
|
1288 | return instance;
|
1289 | }
|
1290 | function createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
|
1291 | return text;
|
1292 | }
|
1293 | function finalizeInitialChildren(domElement, type, props) {
|
1294 | return false;
|
1295 | }
|
1296 | function getPublicInstance(instance) {
|
1297 | return instance;
|
1298 | }
|
1299 | function prepareForCommit() {
|
1300 | }
|
1301 | function prepareUpdate(domElement, type, oldProps, newProps) {
|
1302 | return UPDATE_SIGNAL;
|
1303 | }
|
1304 | function resetAfterCommit() {
|
1305 | }
|
1306 | function resetTextContent(domElement) {
|
1307 | }
|
1308 | function shouldDeprioritizeSubtree(type, props) {
|
1309 | return false;
|
1310 | }
|
1311 | function getRootHostContext() {
|
1312 | return NO_CONTEXT;
|
1313 | }
|
1314 | function getChildHostContext() {
|
1315 | return NO_CONTEXT;
|
1316 | }
|
1317 | var scheduleTimeout = setTimeout;
|
1318 | var cancelTimeout = clearTimeout;
|
1319 | var noTimeout = -1;
|
1320 | function shouldSetTextContent(type, props) {
|
1321 | return typeof props.children === 'string' || typeof props.children === 'number';
|
1322 | }
|
1323 |
|
1324 | var isPrimaryRenderer = false;
|
1325 |
|
1326 | var warnsIfNotActing = false;
|
1327 | var supportsMutation = true;
|
1328 | function appendChild(parentInstance, child) {
|
1329 | if (child.parentNode === parentInstance) {
|
1330 | child.eject();
|
1331 | }
|
1332 |
|
1333 | child.inject(parentInstance);
|
1334 | }
|
1335 | function appendChildToContainer(parentInstance, child) {
|
1336 | if (child.parentNode === parentInstance) {
|
1337 | child.eject();
|
1338 | }
|
1339 |
|
1340 | child.inject(parentInstance);
|
1341 | }
|
1342 | function insertBefore(parentInstance, child, beforeChild) {
|
1343 | if (!(child !== beforeChild)) {
|
1344 | {
|
1345 | throw Error("ReactART: Can not insert node before itself");
|
1346 | }
|
1347 | }
|
1348 |
|
1349 | child.injectBefore(beforeChild);
|
1350 | }
|
1351 | function insertInContainerBefore(parentInstance, child, beforeChild) {
|
1352 | if (!(child !== beforeChild)) {
|
1353 | {
|
1354 | throw Error("ReactART: Can not insert node before itself");
|
1355 | }
|
1356 | }
|
1357 |
|
1358 | child.injectBefore(beforeChild);
|
1359 | }
|
1360 | function removeChild(parentInstance, child) {
|
1361 | destroyEventListeners(child);
|
1362 | child.eject();
|
1363 | }
|
1364 | function removeChildFromContainer(parentInstance, child) {
|
1365 | destroyEventListeners(child);
|
1366 | child.eject();
|
1367 | }
|
1368 |
|
1369 |
|
1370 | function commitUpdate(instance, updatePayload, type, oldProps, newProps) {
|
1371 | instance._applyProps(instance, newProps, oldProps);
|
1372 | }
|
1373 | function hideInstance(instance) {
|
1374 | instance.hide();
|
1375 | }
|
1376 |
|
1377 | function unhideInstance(instance, props) {
|
1378 | if (props.visible == null || props.visible) {
|
1379 | instance.show();
|
1380 | }
|
1381 | }
|
1382 | function unhideTextInstance(textInstance, text) {
|
1383 | }
|
1384 | function mountResponderInstance(responder, responderInstance, props, state, instance) {
|
1385 | throw new Error('Not yet implemented.');
|
1386 | }
|
1387 | function unmountResponderInstance(responderInstance) {
|
1388 | throw new Error('Not yet implemented.');
|
1389 | }
|
1390 | function getFundamentalComponentInstance(fundamentalInstance) {
|
1391 | throw new Error('Not yet implemented.');
|
1392 | }
|
1393 | function mountFundamentalComponent(fundamentalInstance) {
|
1394 | throw new Error('Not yet implemented.');
|
1395 | }
|
1396 | function shouldUpdateFundamentalComponent(fundamentalInstance) {
|
1397 | throw new Error('Not yet implemented.');
|
1398 | }
|
1399 | function updateFundamentalComponent(fundamentalInstance) {
|
1400 | throw new Error('Not yet implemented.');
|
1401 | }
|
1402 | function unmountFundamentalComponent(fundamentalInstance) {
|
1403 | throw new Error('Not yet implemented.');
|
1404 | }
|
1405 | function getInstanceFromNode(node) {
|
1406 | throw new Error('Not yet implemented.');
|
1407 | }
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 | var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
1419 |
|
1420 | var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 | var printWarning = function() {};
|
1432 |
|
1433 | {
|
1434 | var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
1435 | var loggedTypeFailures = {};
|
1436 | var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
1437 |
|
1438 | printWarning = function(text) {
|
1439 | var message = 'Warning: ' + text;
|
1440 | if (typeof console !== 'undefined') {
|
1441 | console.error(message);
|
1442 | }
|
1443 | try {
|
1444 |
|
1445 |
|
1446 |
|
1447 | throw new Error(message);
|
1448 | } catch (x) {}
|
1449 | };
|
1450 | }
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
1464 | {
|
1465 | for (var typeSpecName in typeSpecs) {
|
1466 | if (has$1(typeSpecs, typeSpecName)) {
|
1467 | var error;
|
1468 |
|
1469 |
|
1470 |
|
1471 | try {
|
1472 |
|
1473 |
|
1474 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
1475 | var err = Error(
|
1476 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
1477 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
1478 | );
|
1479 | err.name = 'Invariant Violation';
|
1480 | throw err;
|
1481 | }
|
1482 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
1483 | } catch (ex) {
|
1484 | error = ex;
|
1485 | }
|
1486 | if (error && !(error instanceof Error)) {
|
1487 | printWarning(
|
1488 | (componentName || 'React class') + ': type specification of ' +
|
1489 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
1490 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
1491 | 'You may have forgotten to pass an argument to the type checker ' +
|
1492 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
1493 | 'shape all require an argument).'
|
1494 | );
|
1495 | }
|
1496 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
1497 |
|
1498 |
|
1499 | loggedTypeFailures[error.message] = true;
|
1500 |
|
1501 | var stack = getStack ? getStack() : '';
|
1502 |
|
1503 | printWarning(
|
1504 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
1505 | );
|
1506 | }
|
1507 | }
|
1508 | }
|
1509 | }
|
1510 | }
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 | checkPropTypes.resetWarningCache = function() {
|
1518 | {
|
1519 | loggedTypeFailures = {};
|
1520 | }
|
1521 | };
|
1522 |
|
1523 | var checkPropTypes_1 = checkPropTypes;
|
1524 |
|
1525 | var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
1526 | var describeComponentFrame = function (name, source, ownerName) {
|
1527 | var sourceInfo = '';
|
1528 |
|
1529 | if (source) {
|
1530 | var path = source.fileName;
|
1531 | var fileName = path.replace(BEFORE_SLASH_RE, '');
|
1532 |
|
1533 | {
|
1534 |
|
1535 |
|
1536 | if (/^index\./.test(fileName)) {
|
1537 | var match = path.match(BEFORE_SLASH_RE);
|
1538 |
|
1539 | if (match) {
|
1540 | var pathBeforeSlash = match[1];
|
1541 |
|
1542 | if (pathBeforeSlash) {
|
1543 | var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
1544 | fileName = folderName + '/' + fileName;
|
1545 | }
|
1546 | }
|
1547 | }
|
1548 | }
|
1549 |
|
1550 | sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
1551 | } else if (ownerName) {
|
1552 | sourceInfo = ' (created by ' + ownerName + ')';
|
1553 | }
|
1554 |
|
1555 | return '\n in ' + (name || 'Unknown') + sourceInfo;
|
1556 | };
|
1557 |
|
1558 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
1559 |
|
1560 | function describeFiber(fiber) {
|
1561 | switch (fiber.tag) {
|
1562 | case HostRoot:
|
1563 | case HostPortal:
|
1564 | case HostText:
|
1565 | case Fragment:
|
1566 | case ContextProvider:
|
1567 | case ContextConsumer:
|
1568 | return '';
|
1569 |
|
1570 | default:
|
1571 | var owner = fiber._debugOwner;
|
1572 | var source = fiber._debugSource;
|
1573 | var name = getComponentName(fiber.type);
|
1574 | var ownerName = null;
|
1575 |
|
1576 | if (owner) {
|
1577 | ownerName = getComponentName(owner.type);
|
1578 | }
|
1579 |
|
1580 | return describeComponentFrame(name, source, ownerName);
|
1581 | }
|
1582 | }
|
1583 |
|
1584 | function getStackByFiberInDevAndProd(workInProgress) {
|
1585 | var info = '';
|
1586 | var node = workInProgress;
|
1587 |
|
1588 | do {
|
1589 | info += describeFiber(node);
|
1590 | node = node.return;
|
1591 | } while (node);
|
1592 |
|
1593 | return info;
|
1594 | }
|
1595 | var current$1 = null;
|
1596 | var phase = null;
|
1597 | function getCurrentFiberOwnerNameInDevOrNull() {
|
1598 | {
|
1599 | if (current$1 === null) {
|
1600 | return null;
|
1601 | }
|
1602 |
|
1603 | var owner = current$1._debugOwner;
|
1604 |
|
1605 | if (owner !== null && typeof owner !== 'undefined') {
|
1606 | return getComponentName(owner.type);
|
1607 | }
|
1608 | }
|
1609 |
|
1610 | return null;
|
1611 | }
|
1612 | function getCurrentFiberStackInDev() {
|
1613 | {
|
1614 | if (current$1 === null) {
|
1615 | return '';
|
1616 | }
|
1617 |
|
1618 |
|
1619 |
|
1620 | return getStackByFiberInDevAndProd(current$1);
|
1621 | }
|
1622 |
|
1623 | return '';
|
1624 | }
|
1625 | function resetCurrentFiber() {
|
1626 | {
|
1627 | ReactDebugCurrentFrame.getCurrentStack = null;
|
1628 | current$1 = null;
|
1629 | phase = null;
|
1630 | }
|
1631 | }
|
1632 | function setCurrentFiber(fiber) {
|
1633 | {
|
1634 | ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
|
1635 | current$1 = fiber;
|
1636 | phase = null;
|
1637 | }
|
1638 | }
|
1639 | function setCurrentPhase(lifeCyclePhase) {
|
1640 | {
|
1641 | phase = lifeCyclePhase;
|
1642 | }
|
1643 | }
|
1644 |
|
1645 |
|
1646 |
|
1647 | var reactEmoji = "\u269B";
|
1648 | var warningEmoji = "\u26D4";
|
1649 | var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
|
1650 |
|
1651 |
|
1652 | var currentFiber = null;
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 | var currentPhase = null;
|
1658 | var currentPhaseFiber = null;
|
1659 |
|
1660 |
|
1661 |
|
1662 | var isCommitting = false;
|
1663 | var hasScheduledUpdateInCurrentCommit = false;
|
1664 | var hasScheduledUpdateInCurrentPhase = false;
|
1665 | var commitCountInCurrentWorkLoop = 0;
|
1666 | var effectCountInCurrentCommit = 0;
|
1667 |
|
1668 |
|
1669 | var labelsInCurrentCommit = new Set();
|
1670 |
|
1671 | var formatMarkName = function (markName) {
|
1672 | return reactEmoji + " " + markName;
|
1673 | };
|
1674 |
|
1675 | var formatLabel = function (label, warning) {
|
1676 | var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
|
1677 | var suffix = warning ? " Warning: " + warning : '';
|
1678 | return "" + prefix + label + suffix;
|
1679 | };
|
1680 |
|
1681 | var beginMark = function (markName) {
|
1682 | performance.mark(formatMarkName(markName));
|
1683 | };
|
1684 |
|
1685 | var clearMark = function (markName) {
|
1686 | performance.clearMarks(formatMarkName(markName));
|
1687 | };
|
1688 |
|
1689 | var endMark = function (label, markName, warning) {
|
1690 | var formattedMarkName = formatMarkName(markName);
|
1691 | var formattedLabel = formatLabel(label, warning);
|
1692 |
|
1693 | try {
|
1694 | performance.measure(formattedLabel, formattedMarkName);
|
1695 | } catch (err) {}
|
1696 |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 | performance.clearMarks(formattedMarkName);
|
1702 | performance.clearMeasures(formattedLabel);
|
1703 | };
|
1704 |
|
1705 | var getFiberMarkName = function (label, debugID) {
|
1706 | return label + " (#" + debugID + ")";
|
1707 | };
|
1708 |
|
1709 | var getFiberLabel = function (componentName, isMounted, phase) {
|
1710 | if (phase === null) {
|
1711 |
|
1712 | return componentName + " [" + (isMounted ? 'update' : 'mount') + "]";
|
1713 | } else {
|
1714 |
|
1715 | return componentName + "." + phase;
|
1716 | }
|
1717 | };
|
1718 |
|
1719 | var beginFiberMark = function (fiber, phase) {
|
1720 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1721 | var debugID = fiber._debugID;
|
1722 | var isMounted = fiber.alternate !== null;
|
1723 | var label = getFiberLabel(componentName, isMounted, phase);
|
1724 |
|
1725 | if (isCommitting && labelsInCurrentCommit.has(label)) {
|
1726 |
|
1727 |
|
1728 |
|
1729 | return false;
|
1730 | }
|
1731 |
|
1732 | labelsInCurrentCommit.add(label);
|
1733 | var markName = getFiberMarkName(label, debugID);
|
1734 | beginMark(markName);
|
1735 | return true;
|
1736 | };
|
1737 |
|
1738 | var clearFiberMark = function (fiber, phase) {
|
1739 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1740 | var debugID = fiber._debugID;
|
1741 | var isMounted = fiber.alternate !== null;
|
1742 | var label = getFiberLabel(componentName, isMounted, phase);
|
1743 | var markName = getFiberMarkName(label, debugID);
|
1744 | clearMark(markName);
|
1745 | };
|
1746 |
|
1747 | var endFiberMark = function (fiber, phase, warning) {
|
1748 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1749 | var debugID = fiber._debugID;
|
1750 | var isMounted = fiber.alternate !== null;
|
1751 | var label = getFiberLabel(componentName, isMounted, phase);
|
1752 | var markName = getFiberMarkName(label, debugID);
|
1753 | endMark(label, markName, warning);
|
1754 | };
|
1755 |
|
1756 | var shouldIgnoreFiber = function (fiber) {
|
1757 |
|
1758 |
|
1759 | switch (fiber.tag) {
|
1760 | case HostRoot:
|
1761 | case HostComponent:
|
1762 | case HostText:
|
1763 | case HostPortal:
|
1764 | case Fragment:
|
1765 | case ContextProvider:
|
1766 | case ContextConsumer:
|
1767 | case Mode:
|
1768 | return true;
|
1769 |
|
1770 | default:
|
1771 | return false;
|
1772 | }
|
1773 | };
|
1774 |
|
1775 | var clearPendingPhaseMeasurement = function () {
|
1776 | if (currentPhase !== null && currentPhaseFiber !== null) {
|
1777 | clearFiberMark(currentPhaseFiber, currentPhase);
|
1778 | }
|
1779 |
|
1780 | currentPhaseFiber = null;
|
1781 | currentPhase = null;
|
1782 | hasScheduledUpdateInCurrentPhase = false;
|
1783 | };
|
1784 |
|
1785 | var pauseTimers = function () {
|
1786 |
|
1787 |
|
1788 | var fiber = currentFiber;
|
1789 |
|
1790 | while (fiber) {
|
1791 | if (fiber._debugIsCurrentlyTiming) {
|
1792 | endFiberMark(fiber, null, null);
|
1793 | }
|
1794 |
|
1795 | fiber = fiber.return;
|
1796 | }
|
1797 | };
|
1798 |
|
1799 | var resumeTimersRecursively = function (fiber) {
|
1800 | if (fiber.return !== null) {
|
1801 | resumeTimersRecursively(fiber.return);
|
1802 | }
|
1803 |
|
1804 | if (fiber._debugIsCurrentlyTiming) {
|
1805 | beginFiberMark(fiber, null);
|
1806 | }
|
1807 | };
|
1808 |
|
1809 | var resumeTimers = function () {
|
1810 |
|
1811 | if (currentFiber !== null) {
|
1812 | resumeTimersRecursively(currentFiber);
|
1813 | }
|
1814 | };
|
1815 |
|
1816 | function recordEffect() {
|
1817 | if (enableUserTimingAPI) {
|
1818 | effectCountInCurrentCommit++;
|
1819 | }
|
1820 | }
|
1821 | function recordScheduleUpdate() {
|
1822 | if (enableUserTimingAPI) {
|
1823 | if (isCommitting) {
|
1824 | hasScheduledUpdateInCurrentCommit = true;
|
1825 | }
|
1826 |
|
1827 | if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
|
1828 | hasScheduledUpdateInCurrentPhase = true;
|
1829 | }
|
1830 | }
|
1831 | }
|
1832 |
|
1833 |
|
1834 | function startWorkTimer(fiber) {
|
1835 | if (enableUserTimingAPI) {
|
1836 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1837 | return;
|
1838 | }
|
1839 |
|
1840 |
|
1841 | currentFiber = fiber;
|
1842 |
|
1843 | if (!beginFiberMark(fiber, null)) {
|
1844 | return;
|
1845 | }
|
1846 |
|
1847 | fiber._debugIsCurrentlyTiming = true;
|
1848 | }
|
1849 | }
|
1850 | function cancelWorkTimer(fiber) {
|
1851 | if (enableUserTimingAPI) {
|
1852 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1853 | return;
|
1854 | }
|
1855 |
|
1856 |
|
1857 |
|
1858 | fiber._debugIsCurrentlyTiming = false;
|
1859 | clearFiberMark(fiber, null);
|
1860 | }
|
1861 | }
|
1862 | function stopWorkTimer(fiber) {
|
1863 | if (enableUserTimingAPI) {
|
1864 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1865 | return;
|
1866 | }
|
1867 |
|
1868 |
|
1869 | currentFiber = fiber.return;
|
1870 |
|
1871 | if (!fiber._debugIsCurrentlyTiming) {
|
1872 | return;
|
1873 | }
|
1874 |
|
1875 | fiber._debugIsCurrentlyTiming = false;
|
1876 | endFiberMark(fiber, null, null);
|
1877 | }
|
1878 | }
|
1879 | function stopFailedWorkTimer(fiber) {
|
1880 | if (enableUserTimingAPI) {
|
1881 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1882 | return;
|
1883 | }
|
1884 |
|
1885 |
|
1886 | currentFiber = fiber.return;
|
1887 |
|
1888 | if (!fiber._debugIsCurrentlyTiming) {
|
1889 | return;
|
1890 | }
|
1891 |
|
1892 | fiber._debugIsCurrentlyTiming = false;
|
1893 | var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
|
1894 | endFiberMark(fiber, null, warning);
|
1895 | }
|
1896 | }
|
1897 | function startPhaseTimer(fiber, phase) {
|
1898 | if (enableUserTimingAPI) {
|
1899 | if (!supportsUserTiming) {
|
1900 | return;
|
1901 | }
|
1902 |
|
1903 | clearPendingPhaseMeasurement();
|
1904 |
|
1905 | if (!beginFiberMark(fiber, phase)) {
|
1906 | return;
|
1907 | }
|
1908 |
|
1909 | currentPhaseFiber = fiber;
|
1910 | currentPhase = phase;
|
1911 | }
|
1912 | }
|
1913 | function stopPhaseTimer() {
|
1914 | if (enableUserTimingAPI) {
|
1915 | if (!supportsUserTiming) {
|
1916 | return;
|
1917 | }
|
1918 |
|
1919 | if (currentPhase !== null && currentPhaseFiber !== null) {
|
1920 | var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
|
1921 | endFiberMark(currentPhaseFiber, currentPhase, warning);
|
1922 | }
|
1923 |
|
1924 | currentPhase = null;
|
1925 | currentPhaseFiber = null;
|
1926 | }
|
1927 | }
|
1928 | function startWorkLoopTimer(nextUnitOfWork) {
|
1929 | if (enableUserTimingAPI) {
|
1930 | currentFiber = nextUnitOfWork;
|
1931 |
|
1932 | if (!supportsUserTiming) {
|
1933 | return;
|
1934 | }
|
1935 |
|
1936 | commitCountInCurrentWorkLoop = 0;
|
1937 |
|
1938 |
|
1939 | beginMark('(React Tree Reconciliation)');
|
1940 |
|
1941 | resumeTimers();
|
1942 | }
|
1943 | }
|
1944 | function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
|
1945 | if (enableUserTimingAPI) {
|
1946 | if (!supportsUserTiming) {
|
1947 | return;
|
1948 | }
|
1949 |
|
1950 | var warning = null;
|
1951 |
|
1952 | if (interruptedBy !== null) {
|
1953 | if (interruptedBy.tag === HostRoot) {
|
1954 | warning = 'A top-level update interrupted the previous render';
|
1955 | } else {
|
1956 | var componentName = getComponentName(interruptedBy.type) || 'Unknown';
|
1957 | warning = "An update to " + componentName + " interrupted the previous render";
|
1958 | }
|
1959 | } else if (commitCountInCurrentWorkLoop > 1) {
|
1960 | warning = 'There were cascading updates';
|
1961 | }
|
1962 |
|
1963 | commitCountInCurrentWorkLoop = 0;
|
1964 | var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
|
1965 |
|
1966 | pauseTimers();
|
1967 | endMark(label, '(React Tree Reconciliation)', warning);
|
1968 | }
|
1969 | }
|
1970 | function startCommitTimer() {
|
1971 | if (enableUserTimingAPI) {
|
1972 | if (!supportsUserTiming) {
|
1973 | return;
|
1974 | }
|
1975 |
|
1976 | isCommitting = true;
|
1977 | hasScheduledUpdateInCurrentCommit = false;
|
1978 | labelsInCurrentCommit.clear();
|
1979 | beginMark('(Committing Changes)');
|
1980 | }
|
1981 | }
|
1982 | function stopCommitTimer() {
|
1983 | if (enableUserTimingAPI) {
|
1984 | if (!supportsUserTiming) {
|
1985 | return;
|
1986 | }
|
1987 |
|
1988 | var warning = null;
|
1989 |
|
1990 | if (hasScheduledUpdateInCurrentCommit) {
|
1991 | warning = 'Lifecycle hook scheduled a cascading update';
|
1992 | } else if (commitCountInCurrentWorkLoop > 0) {
|
1993 | warning = 'Caused by a cascading update in earlier commit';
|
1994 | }
|
1995 |
|
1996 | hasScheduledUpdateInCurrentCommit = false;
|
1997 | commitCountInCurrentWorkLoop++;
|
1998 | isCommitting = false;
|
1999 | labelsInCurrentCommit.clear();
|
2000 | endMark('(Committing Changes)', '(Committing Changes)', warning);
|
2001 | }
|
2002 | }
|
2003 | function startCommitSnapshotEffectsTimer() {
|
2004 | if (enableUserTimingAPI) {
|
2005 | if (!supportsUserTiming) {
|
2006 | return;
|
2007 | }
|
2008 |
|
2009 | effectCountInCurrentCommit = 0;
|
2010 | beginMark('(Committing Snapshot Effects)');
|
2011 | }
|
2012 | }
|
2013 | function stopCommitSnapshotEffectsTimer() {
|
2014 | if (enableUserTimingAPI) {
|
2015 | if (!supportsUserTiming) {
|
2016 | return;
|
2017 | }
|
2018 |
|
2019 | var count = effectCountInCurrentCommit;
|
2020 | effectCountInCurrentCommit = 0;
|
2021 | endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null);
|
2022 | }
|
2023 | }
|
2024 | function startCommitHostEffectsTimer() {
|
2025 | if (enableUserTimingAPI) {
|
2026 | if (!supportsUserTiming) {
|
2027 | return;
|
2028 | }
|
2029 |
|
2030 | effectCountInCurrentCommit = 0;
|
2031 | beginMark('(Committing Host Effects)');
|
2032 | }
|
2033 | }
|
2034 | function stopCommitHostEffectsTimer() {
|
2035 | if (enableUserTimingAPI) {
|
2036 | if (!supportsUserTiming) {
|
2037 | return;
|
2038 | }
|
2039 |
|
2040 | var count = effectCountInCurrentCommit;
|
2041 | effectCountInCurrentCommit = 0;
|
2042 | endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null);
|
2043 | }
|
2044 | }
|
2045 | function startCommitLifeCyclesTimer() {
|
2046 | if (enableUserTimingAPI) {
|
2047 | if (!supportsUserTiming) {
|
2048 | return;
|
2049 | }
|
2050 |
|
2051 | effectCountInCurrentCommit = 0;
|
2052 | beginMark('(Calling Lifecycle Methods)');
|
2053 | }
|
2054 | }
|
2055 | function stopCommitLifeCyclesTimer() {
|
2056 | if (enableUserTimingAPI) {
|
2057 | if (!supportsUserTiming) {
|
2058 | return;
|
2059 | }
|
2060 |
|
2061 | var count = effectCountInCurrentCommit;
|
2062 | effectCountInCurrentCommit = 0;
|
2063 | endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null);
|
2064 | }
|
2065 | }
|
2066 |
|
2067 | var valueStack = [];
|
2068 | var fiberStack;
|
2069 |
|
2070 | {
|
2071 | fiberStack = [];
|
2072 | }
|
2073 |
|
2074 | var index = -1;
|
2075 |
|
2076 | function createCursor(defaultValue) {
|
2077 | return {
|
2078 | current: defaultValue
|
2079 | };
|
2080 | }
|
2081 |
|
2082 | function pop(cursor, fiber) {
|
2083 | if (index < 0) {
|
2084 | {
|
2085 | warningWithoutStack$1(false, 'Unexpected pop.');
|
2086 | }
|
2087 |
|
2088 | return;
|
2089 | }
|
2090 |
|
2091 | {
|
2092 | if (fiber !== fiberStack[index]) {
|
2093 | warningWithoutStack$1(false, 'Unexpected Fiber popped.');
|
2094 | }
|
2095 | }
|
2096 |
|
2097 | cursor.current = valueStack[index];
|
2098 | valueStack[index] = null;
|
2099 |
|
2100 | {
|
2101 | fiberStack[index] = null;
|
2102 | }
|
2103 |
|
2104 | index--;
|
2105 | }
|
2106 |
|
2107 | function push(cursor, value, fiber) {
|
2108 | index++;
|
2109 | valueStack[index] = cursor.current;
|
2110 |
|
2111 | {
|
2112 | fiberStack[index] = fiber;
|
2113 | }
|
2114 |
|
2115 | cursor.current = value;
|
2116 | }
|
2117 |
|
2118 | var warnedAboutMissingGetChildContext;
|
2119 |
|
2120 | {
|
2121 | warnedAboutMissingGetChildContext = {};
|
2122 | }
|
2123 |
|
2124 | var emptyContextObject = {};
|
2125 |
|
2126 | {
|
2127 | Object.freeze(emptyContextObject);
|
2128 | }
|
2129 |
|
2130 |
|
2131 | var contextStackCursor = createCursor(emptyContextObject);
|
2132 |
|
2133 | var didPerformWorkStackCursor = createCursor(false);
|
2134 |
|
2135 |
|
2136 |
|
2137 | var previousContext = emptyContextObject;
|
2138 |
|
2139 | function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
|
2140 | if (disableLegacyContext) {
|
2141 | return emptyContextObject;
|
2142 | } else {
|
2143 | if (didPushOwnContextIfProvider && isContextProvider(Component)) {
|
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 | return previousContext;
|
2149 | }
|
2150 |
|
2151 | return contextStackCursor.current;
|
2152 | }
|
2153 | }
|
2154 |
|
2155 | function cacheContext(workInProgress, unmaskedContext, maskedContext) {
|
2156 | if (disableLegacyContext) {
|
2157 | return;
|
2158 | } else {
|
2159 | var instance = workInProgress.stateNode;
|
2160 | instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
2161 | instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
2162 | }
|
2163 | }
|
2164 |
|
2165 | function getMaskedContext(workInProgress, unmaskedContext) {
|
2166 | if (disableLegacyContext) {
|
2167 | return emptyContextObject;
|
2168 | } else {
|
2169 | var type = workInProgress.type;
|
2170 | var contextTypes = type.contextTypes;
|
2171 |
|
2172 | if (!contextTypes) {
|
2173 | return emptyContextObject;
|
2174 | }
|
2175 |
|
2176 |
|
2177 |
|
2178 |
|
2179 | var instance = workInProgress.stateNode;
|
2180 |
|
2181 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
|
2182 | return instance.__reactInternalMemoizedMaskedChildContext;
|
2183 | }
|
2184 |
|
2185 | var context = {};
|
2186 |
|
2187 | for (var key in contextTypes) {
|
2188 | context[key] = unmaskedContext[key];
|
2189 | }
|
2190 |
|
2191 | {
|
2192 | var name = getComponentName(type) || 'Unknown';
|
2193 | checkPropTypes_1(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
|
2194 | }
|
2195 |
|
2196 |
|
2197 |
|
2198 | if (instance) {
|
2199 | cacheContext(workInProgress, unmaskedContext, context);
|
2200 | }
|
2201 |
|
2202 | return context;
|
2203 | }
|
2204 | }
|
2205 |
|
2206 | function hasContextChanged() {
|
2207 | if (disableLegacyContext) {
|
2208 | return false;
|
2209 | } else {
|
2210 | return didPerformWorkStackCursor.current;
|
2211 | }
|
2212 | }
|
2213 |
|
2214 | function isContextProvider(type) {
|
2215 | if (disableLegacyContext) {
|
2216 | return false;
|
2217 | } else {
|
2218 | var childContextTypes = type.childContextTypes;
|
2219 | return childContextTypes !== null && childContextTypes !== undefined;
|
2220 | }
|
2221 | }
|
2222 |
|
2223 | function popContext(fiber) {
|
2224 | if (disableLegacyContext) {
|
2225 | return;
|
2226 | } else {
|
2227 | pop(didPerformWorkStackCursor, fiber);
|
2228 | pop(contextStackCursor, fiber);
|
2229 | }
|
2230 | }
|
2231 |
|
2232 | function popTopLevelContextObject(fiber) {
|
2233 | if (disableLegacyContext) {
|
2234 | return;
|
2235 | } else {
|
2236 | pop(didPerformWorkStackCursor, fiber);
|
2237 | pop(contextStackCursor, fiber);
|
2238 | }
|
2239 | }
|
2240 |
|
2241 | function pushTopLevelContextObject(fiber, context, didChange) {
|
2242 | if (disableLegacyContext) {
|
2243 | return;
|
2244 | } else {
|
2245 | if (!(contextStackCursor.current === emptyContextObject)) {
|
2246 | {
|
2247 | throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");
|
2248 | }
|
2249 | }
|
2250 |
|
2251 | push(contextStackCursor, context, fiber);
|
2252 | push(didPerformWorkStackCursor, didChange, fiber);
|
2253 | }
|
2254 | }
|
2255 |
|
2256 | function processChildContext(fiber, type, parentContext) {
|
2257 | if (disableLegacyContext) {
|
2258 | return parentContext;
|
2259 | } else {
|
2260 | var instance = fiber.stateNode;
|
2261 | var childContextTypes = type.childContextTypes;
|
2262 |
|
2263 |
|
2264 | if (typeof instance.getChildContext !== 'function') {
|
2265 | {
|
2266 | var componentName = getComponentName(type) || 'Unknown';
|
2267 |
|
2268 | if (!warnedAboutMissingGetChildContext[componentName]) {
|
2269 | warnedAboutMissingGetChildContext[componentName] = true;
|
2270 | warningWithoutStack$1(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
|
2271 | }
|
2272 | }
|
2273 |
|
2274 | return parentContext;
|
2275 | }
|
2276 |
|
2277 | var childContext;
|
2278 |
|
2279 | {
|
2280 | setCurrentPhase('getChildContext');
|
2281 | }
|
2282 |
|
2283 | startPhaseTimer(fiber, 'getChildContext');
|
2284 | childContext = instance.getChildContext();
|
2285 | stopPhaseTimer();
|
2286 |
|
2287 | {
|
2288 | setCurrentPhase(null);
|
2289 | }
|
2290 |
|
2291 | for (var contextKey in childContext) {
|
2292 | if (!(contextKey in childContextTypes)) {
|
2293 | {
|
2294 | throw Error((getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes.");
|
2295 | }
|
2296 | }
|
2297 | }
|
2298 |
|
2299 | {
|
2300 | var name = getComponentName(type) || 'Unknown';
|
2301 | checkPropTypes_1(childContextTypes, childContext, 'child context', name,
|
2302 |
|
2303 |
|
2304 |
|
2305 |
|
2306 | getCurrentFiberStackInDev);
|
2307 | }
|
2308 |
|
2309 | return _assign({}, parentContext, {}, childContext);
|
2310 | }
|
2311 | }
|
2312 |
|
2313 | function pushContextProvider(workInProgress) {
|
2314 | if (disableLegacyContext) {
|
2315 | return false;
|
2316 | } else {
|
2317 | var instance = workInProgress.stateNode;
|
2318 |
|
2319 |
|
2320 |
|
2321 | var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
|
2322 |
|
2323 |
|
2324 | previousContext = contextStackCursor.current;
|
2325 | push(contextStackCursor, memoizedMergedChildContext, workInProgress);
|
2326 | push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
|
2327 | return true;
|
2328 | }
|
2329 | }
|
2330 |
|
2331 | function invalidateContextProvider(workInProgress, type, didChange) {
|
2332 | if (disableLegacyContext) {
|
2333 | return;
|
2334 | } else {
|
2335 | var instance = workInProgress.stateNode;
|
2336 |
|
2337 | if (!instance) {
|
2338 | {
|
2339 | throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");
|
2340 | }
|
2341 | }
|
2342 |
|
2343 | if (didChange) {
|
2344 |
|
2345 |
|
2346 |
|
2347 | var mergedContext = processChildContext(workInProgress, type, previousContext);
|
2348 | instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
2349 |
|
2350 |
|
2351 | pop(didPerformWorkStackCursor, workInProgress);
|
2352 | pop(contextStackCursor, workInProgress);
|
2353 |
|
2354 | push(contextStackCursor, mergedContext, workInProgress);
|
2355 | push(didPerformWorkStackCursor, didChange, workInProgress);
|
2356 | } else {
|
2357 | pop(didPerformWorkStackCursor, workInProgress);
|
2358 | push(didPerformWorkStackCursor, didChange, workInProgress);
|
2359 | }
|
2360 | }
|
2361 | }
|
2362 |
|
2363 | function findCurrentUnmaskedContext(fiber) {
|
2364 | if (disableLegacyContext) {
|
2365 | return emptyContextObject;
|
2366 | } else {
|
2367 |
|
2368 |
|
2369 | if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
|
2370 | {
|
2371 | throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");
|
2372 | }
|
2373 | }
|
2374 |
|
2375 | var node = fiber;
|
2376 |
|
2377 | do {
|
2378 | switch (node.tag) {
|
2379 | case HostRoot:
|
2380 | return node.stateNode.context;
|
2381 |
|
2382 | case ClassComponent:
|
2383 | {
|
2384 | var Component = node.type;
|
2385 |
|
2386 | if (isContextProvider(Component)) {
|
2387 | return node.stateNode.__reactInternalMemoizedMergedChildContext;
|
2388 | }
|
2389 |
|
2390 | break;
|
2391 | }
|
2392 | }
|
2393 |
|
2394 | node = node.return;
|
2395 | } while (node !== null);
|
2396 |
|
2397 | {
|
2398 | {
|
2399 | throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.");
|
2400 | }
|
2401 | }
|
2402 | }
|
2403 | }
|
2404 |
|
2405 | var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
2406 | var _ReactInternals$Sched = ReactInternals$1.Scheduler;
|
2407 | var unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback;
|
2408 | var unstable_now = _ReactInternals$Sched.unstable_now;
|
2409 | var unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback;
|
2410 | var unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield;
|
2411 | var unstable_requestPaint = _ReactInternals$Sched.unstable_requestPaint;
|
2412 | var unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode;
|
2413 | var unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority;
|
2414 | var unstable_next = _ReactInternals$Sched.unstable_next;
|
2415 | var unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution;
|
2416 | var unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution;
|
2417 | var unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel;
|
2418 | var unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority;
|
2419 | var unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority;
|
2420 | var unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority;
|
2421 | var unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority;
|
2422 | var unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority;
|
2423 | var unstable_forceFrameRate = _ReactInternals$Sched.unstable_forceFrameRate;
|
2424 | var unstable_flushAllWithoutAsserting = _ReactInternals$Sched.unstable_flushAllWithoutAsserting;
|
2425 |
|
2426 | var ReactInternals$2 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
2427 | var _ReactInternals$Sched$1 = ReactInternals$2.SchedulerTracing;
|
2428 | var __interactionsRef = _ReactInternals$Sched$1.__interactionsRef;
|
2429 | var __subscriberRef = _ReactInternals$Sched$1.__subscriberRef;
|
2430 | var unstable_clear = _ReactInternals$Sched$1.unstable_clear;
|
2431 | var unstable_getCurrent = _ReactInternals$Sched$1.unstable_getCurrent;
|
2432 | var unstable_getThreadID = _ReactInternals$Sched$1.unstable_getThreadID;
|
2433 | var unstable_subscribe = _ReactInternals$Sched$1.unstable_subscribe;
|
2434 | var unstable_trace = _ReactInternals$Sched$1.unstable_trace;
|
2435 | var unstable_unsubscribe = _ReactInternals$Sched$1.unstable_unsubscribe;
|
2436 | var unstable_wrap = _ReactInternals$Sched$1.unstable_wrap;
|
2437 |
|
2438 |
|
2439 |
|
2440 | var Scheduler_runWithPriority = unstable_runWithPriority;
|
2441 | var Scheduler_scheduleCallback = unstable_scheduleCallback;
|
2442 | var Scheduler_cancelCallback = unstable_cancelCallback;
|
2443 | var Scheduler_shouldYield = unstable_shouldYield;
|
2444 | var Scheduler_requestPaint = unstable_requestPaint;
|
2445 | var Scheduler_now = unstable_now;
|
2446 | var Scheduler_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
|
2447 | var Scheduler_ImmediatePriority = unstable_ImmediatePriority;
|
2448 | var Scheduler_UserBlockingPriority = unstable_UserBlockingPriority;
|
2449 | var Scheduler_NormalPriority = unstable_NormalPriority;
|
2450 | var Scheduler_LowPriority = unstable_LowPriority;
|
2451 | var Scheduler_IdlePriority = unstable_IdlePriority;
|
2452 |
|
2453 | if (enableSchedulerTracing) {
|
2454 |
|
2455 |
|
2456 |
|
2457 | if (!(__interactionsRef != null && __interactionsRef.current != null)) {
|
2458 | {
|
2459 | throw Error("It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling");
|
2460 | }
|
2461 | }
|
2462 | }
|
2463 |
|
2464 | var fakeCallbackNode = {};
|
2465 |
|
2466 |
|
2467 |
|
2468 | var ImmediatePriority = 99;
|
2469 | var UserBlockingPriority = 98;
|
2470 | var NormalPriority = 97;
|
2471 | var LowPriority = 96;
|
2472 | var IdlePriority = 95;
|
2473 |
|
2474 | var NoPriority = 90;
|
2475 | var shouldYield = Scheduler_shouldYield;
|
2476 | var requestPaint =
|
2477 | Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
|
2478 | var syncQueue = null;
|
2479 | var immediateQueueCallbackNode = null;
|
2480 | var isFlushingSyncQueue = false;
|
2481 | var initialTimeMs = Scheduler_now();
|
2482 |
|
2483 |
|
2484 |
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 | var now = initialTimeMs < 10000 ? Scheduler_now : function () {
|
2490 | return Scheduler_now() - initialTimeMs;
|
2491 | };
|
2492 | function getCurrentPriorityLevel() {
|
2493 | switch (Scheduler_getCurrentPriorityLevel()) {
|
2494 | case Scheduler_ImmediatePriority:
|
2495 | return ImmediatePriority;
|
2496 |
|
2497 | case Scheduler_UserBlockingPriority:
|
2498 | return UserBlockingPriority;
|
2499 |
|
2500 | case Scheduler_NormalPriority:
|
2501 | return NormalPriority;
|
2502 |
|
2503 | case Scheduler_LowPriority:
|
2504 | return LowPriority;
|
2505 |
|
2506 | case Scheduler_IdlePriority:
|
2507 | return IdlePriority;
|
2508 |
|
2509 | default:
|
2510 | {
|
2511 | {
|
2512 | throw Error("Unknown priority level.");
|
2513 | }
|
2514 | }
|
2515 |
|
2516 | }
|
2517 | }
|
2518 |
|
2519 | function reactPriorityToSchedulerPriority(reactPriorityLevel) {
|
2520 | switch (reactPriorityLevel) {
|
2521 | case ImmediatePriority:
|
2522 | return Scheduler_ImmediatePriority;
|
2523 |
|
2524 | case UserBlockingPriority:
|
2525 | return Scheduler_UserBlockingPriority;
|
2526 |
|
2527 | case NormalPriority:
|
2528 | return Scheduler_NormalPriority;
|
2529 |
|
2530 | case LowPriority:
|
2531 | return Scheduler_LowPriority;
|
2532 |
|
2533 | case IdlePriority:
|
2534 | return Scheduler_IdlePriority;
|
2535 |
|
2536 | default:
|
2537 | {
|
2538 | {
|
2539 | throw Error("Unknown priority level.");
|
2540 | }
|
2541 | }
|
2542 |
|
2543 | }
|
2544 | }
|
2545 |
|
2546 | function runWithPriority(reactPriorityLevel, fn) {
|
2547 | var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
|
2548 | return Scheduler_runWithPriority(priorityLevel, fn);
|
2549 | }
|
2550 | function scheduleCallback(reactPriorityLevel, callback, options) {
|
2551 | var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
|
2552 | return Scheduler_scheduleCallback(priorityLevel, callback, options);
|
2553 | }
|
2554 | function scheduleSyncCallback(callback) {
|
2555 |
|
2556 |
|
2557 | if (syncQueue === null) {
|
2558 | syncQueue = [callback];
|
2559 |
|
2560 | immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
|
2561 | } else {
|
2562 |
|
2563 |
|
2564 | syncQueue.push(callback);
|
2565 | }
|
2566 |
|
2567 | return fakeCallbackNode;
|
2568 | }
|
2569 | function cancelCallback(callbackNode) {
|
2570 | if (callbackNode !== fakeCallbackNode) {
|
2571 | Scheduler_cancelCallback(callbackNode);
|
2572 | }
|
2573 | }
|
2574 | function flushSyncCallbackQueue() {
|
2575 | if (immediateQueueCallbackNode !== null) {
|
2576 | var node = immediateQueueCallbackNode;
|
2577 | immediateQueueCallbackNode = null;
|
2578 | Scheduler_cancelCallback(node);
|
2579 | }
|
2580 |
|
2581 | flushSyncCallbackQueueImpl();
|
2582 | }
|
2583 |
|
2584 | function flushSyncCallbackQueueImpl() {
|
2585 | if (!isFlushingSyncQueue && syncQueue !== null) {
|
2586 |
|
2587 | isFlushingSyncQueue = true;
|
2588 | var i = 0;
|
2589 |
|
2590 | try {
|
2591 | var _isSync = true;
|
2592 | var queue = syncQueue;
|
2593 | runWithPriority(ImmediatePriority, function () {
|
2594 | for (; i < queue.length; i++) {
|
2595 | var callback = queue[i];
|
2596 |
|
2597 | do {
|
2598 | callback = callback(_isSync);
|
2599 | } while (callback !== null);
|
2600 | }
|
2601 | });
|
2602 | syncQueue = null;
|
2603 | } catch (error) {
|
2604 |
|
2605 | if (syncQueue !== null) {
|
2606 | syncQueue = syncQueue.slice(i + 1);
|
2607 | }
|
2608 |
|
2609 |
|
2610 | Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
|
2611 | throw error;
|
2612 | } finally {
|
2613 | isFlushingSyncQueue = false;
|
2614 | }
|
2615 | }
|
2616 | }
|
2617 |
|
2618 | var NoMode = 0;
|
2619 | var StrictMode = 1;
|
2620 |
|
2621 |
|
2622 | var BatchedMode = 2;
|
2623 | var ConcurrentMode = 4;
|
2624 | var ProfileMode = 8;
|
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 | var MAX_SIGNED_31_BIT_INT = 1073741823;
|
2630 |
|
2631 | var NoWork = 0;
|
2632 |
|
2633 |
|
2634 |
|
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 | var Never = 1;
|
2640 |
|
2641 |
|
2642 | var Idle = 2;
|
2643 | var Sync = MAX_SIGNED_31_BIT_INT;
|
2644 | var Batched = Sync - 1;
|
2645 | var UNIT_SIZE = 10;
|
2646 | var MAGIC_NUMBER_OFFSET = Batched - 1;
|
2647 |
|
2648 | function msToExpirationTime(ms) {
|
2649 |
|
2650 | return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
|
2651 | }
|
2652 | function expirationTimeToMs(expirationTime) {
|
2653 | return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
|
2654 | }
|
2655 |
|
2656 | function ceiling(num, precision) {
|
2657 | return ((num / precision | 0) + 1) * precision;
|
2658 | }
|
2659 |
|
2660 | function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
|
2661 | return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
|
2662 | }
|
2663 |
|
2664 |
|
2665 |
|
2666 | var LOW_PRIORITY_EXPIRATION = 5000;
|
2667 | var LOW_PRIORITY_BATCH_SIZE = 250;
|
2668 | function computeAsyncExpiration(currentTime) {
|
2669 | return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
|
2670 | }
|
2671 | function computeSuspenseExpiration(currentTime, timeoutMs) {
|
2672 |
|
2673 | return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
|
2674 | }
|
2675 |
|
2676 |
|
2677 |
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 | var HIGH_PRIORITY_EXPIRATION = 500;
|
2687 | var HIGH_PRIORITY_BATCH_SIZE = 100;
|
2688 | function computeInteractiveExpiration(currentTime) {
|
2689 | return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
|
2690 | }
|
2691 |
|
2692 | function inferPriorityFromExpirationTime(currentTime, expirationTime) {
|
2693 | if (expirationTime === Sync) {
|
2694 | return ImmediatePriority;
|
2695 | }
|
2696 |
|
2697 | if (expirationTime === Never || expirationTime === Idle) {
|
2698 | return IdlePriority;
|
2699 | }
|
2700 |
|
2701 | var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
|
2702 |
|
2703 | if (msUntil <= 0) {
|
2704 | return ImmediatePriority;
|
2705 | }
|
2706 |
|
2707 | if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
|
2708 | return UserBlockingPriority;
|
2709 | }
|
2710 |
|
2711 | if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
|
2712 | return NormalPriority;
|
2713 | }
|
2714 |
|
2715 |
|
2716 |
|
2717 | return IdlePriority;
|
2718 | }
|
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 | function is(x, y) {
|
2725 | return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y
|
2726 | ;
|
2727 | }
|
2728 |
|
2729 | var is$1 = typeof Object.is === 'function' ? Object.is : is;
|
2730 |
|
2731 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
2732 |
|
2733 |
|
2734 |
|
2735 |
|
2736 |
|
2737 |
|
2738 | function shallowEqual(objA, objB) {
|
2739 | if (is$1(objA, objB)) {
|
2740 | return true;
|
2741 | }
|
2742 |
|
2743 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
2744 | return false;
|
2745 | }
|
2746 |
|
2747 | var keysA = Object.keys(objA);
|
2748 | var keysB = Object.keys(objB);
|
2749 |
|
2750 | if (keysA.length !== keysB.length) {
|
2751 | return false;
|
2752 | }
|
2753 |
|
2754 |
|
2755 | for (var i = 0; i < keysA.length; i++) {
|
2756 | if (!hasOwnProperty.call(objB, keysA[i]) || !is$1(objA[keysA[i]], objB[keysA[i]])) {
|
2757 | return false;
|
2758 | }
|
2759 | }
|
2760 |
|
2761 | return true;
|
2762 | }
|
2763 |
|
2764 |
|
2765 |
|
2766 |
|
2767 |
|
2768 |
|
2769 |
|
2770 |
|
2771 |
|
2772 |
|
2773 |
|
2774 |
|
2775 |
|
2776 |
|
2777 | var lowPriorityWarningWithoutStack = function () {};
|
2778 |
|
2779 | {
|
2780 | var printWarning$1 = function (format) {
|
2781 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
2782 | args[_key - 1] = arguments[_key];
|
2783 | }
|
2784 |
|
2785 | var argIndex = 0;
|
2786 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
2787 | return args[argIndex++];
|
2788 | });
|
2789 |
|
2790 | if (typeof console !== 'undefined') {
|
2791 | console.warn(message);
|
2792 | }
|
2793 |
|
2794 | try {
|
2795 |
|
2796 |
|
2797 |
|
2798 | throw new Error(message);
|
2799 | } catch (x) {}
|
2800 | };
|
2801 |
|
2802 | lowPriorityWarningWithoutStack = function (condition, format) {
|
2803 | if (format === undefined) {
|
2804 | throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
2805 | }
|
2806 |
|
2807 | if (!condition) {
|
2808 | for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
2809 | args[_key2 - 2] = arguments[_key2];
|
2810 | }
|
2811 |
|
2812 | printWarning$1.apply(void 0, [format].concat(args));
|
2813 | }
|
2814 | };
|
2815 | }
|
2816 |
|
2817 | var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
|
2818 |
|
2819 | var ReactStrictModeWarnings = {
|
2820 | recordUnsafeLifecycleWarnings: function (fiber, instance) {},
|
2821 | flushPendingUnsafeLifecycleWarnings: function () {},
|
2822 | recordLegacyContextWarning: function (fiber, instance) {},
|
2823 | flushLegacyContextWarning: function () {},
|
2824 | discardPendingWarnings: function () {}
|
2825 | };
|
2826 |
|
2827 | {
|
2828 | var findStrictRoot = function (fiber) {
|
2829 | var maybeStrictRoot = null;
|
2830 | var node = fiber;
|
2831 |
|
2832 | while (node !== null) {
|
2833 | if (node.mode & StrictMode) {
|
2834 | maybeStrictRoot = node;
|
2835 | }
|
2836 |
|
2837 | node = node.return;
|
2838 | }
|
2839 |
|
2840 | return maybeStrictRoot;
|
2841 | };
|
2842 |
|
2843 | var setToSortedString = function (set) {
|
2844 | var array = [];
|
2845 | set.forEach(function (value) {
|
2846 | array.push(value);
|
2847 | });
|
2848 | return array.sort().join(', ');
|
2849 | };
|
2850 |
|
2851 | var pendingComponentWillMountWarnings = [];
|
2852 | var pendingUNSAFE_ComponentWillMountWarnings = [];
|
2853 | var pendingComponentWillReceivePropsWarnings = [];
|
2854 | var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
2855 | var pendingComponentWillUpdateWarnings = [];
|
2856 | var pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
2857 |
|
2858 | var didWarnAboutUnsafeLifecycles = new Set();
|
2859 |
|
2860 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
|
2861 |
|
2862 | if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
|
2863 | return;
|
2864 | }
|
2865 |
|
2866 | if (typeof instance.componentWillMount === 'function' &&
|
2867 | instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
2868 | pendingComponentWillMountWarnings.push(fiber);
|
2869 | }
|
2870 |
|
2871 | if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
|
2872 | pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
|
2873 | }
|
2874 |
|
2875 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
2876 | pendingComponentWillReceivePropsWarnings.push(fiber);
|
2877 | }
|
2878 |
|
2879 | if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
2880 | pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
|
2881 | }
|
2882 |
|
2883 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
2884 | pendingComponentWillUpdateWarnings.push(fiber);
|
2885 | }
|
2886 |
|
2887 | if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
2888 | pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
|
2889 | }
|
2890 | };
|
2891 |
|
2892 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
|
2893 |
|
2894 | var componentWillMountUniqueNames = new Set();
|
2895 |
|
2896 | if (pendingComponentWillMountWarnings.length > 0) {
|
2897 | pendingComponentWillMountWarnings.forEach(function (fiber) {
|
2898 | componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2899 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2900 | });
|
2901 | pendingComponentWillMountWarnings = [];
|
2902 | }
|
2903 |
|
2904 | var UNSAFE_componentWillMountUniqueNames = new Set();
|
2905 |
|
2906 | if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
|
2907 | pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
|
2908 | UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2909 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2910 | });
|
2911 | pendingUNSAFE_ComponentWillMountWarnings = [];
|
2912 | }
|
2913 |
|
2914 | var componentWillReceivePropsUniqueNames = new Set();
|
2915 |
|
2916 | if (pendingComponentWillReceivePropsWarnings.length > 0) {
|
2917 | pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
|
2918 | componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2919 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2920 | });
|
2921 | pendingComponentWillReceivePropsWarnings = [];
|
2922 | }
|
2923 |
|
2924 | var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
|
2925 |
|
2926 | if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
|
2927 | pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
|
2928 | UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2929 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2930 | });
|
2931 | pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
2932 | }
|
2933 |
|
2934 | var componentWillUpdateUniqueNames = new Set();
|
2935 |
|
2936 | if (pendingComponentWillUpdateWarnings.length > 0) {
|
2937 | pendingComponentWillUpdateWarnings.forEach(function (fiber) {
|
2938 | componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2939 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2940 | });
|
2941 | pendingComponentWillUpdateWarnings = [];
|
2942 | }
|
2943 |
|
2944 | var UNSAFE_componentWillUpdateUniqueNames = new Set();
|
2945 |
|
2946 | if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
|
2947 | pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
|
2948 | UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
|
2949 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
2950 | });
|
2951 | pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
2952 | }
|
2953 |
|
2954 |
|
2955 |
|
2956 | if (UNSAFE_componentWillMountUniqueNames.size > 0) {
|
2957 | var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
|
2958 | warningWithoutStack$1(false, 'Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames);
|
2959 | }
|
2960 |
|
2961 | if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
|
2962 | var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
|
2963 |
|
2964 | warningWithoutStack$1(false, 'Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
|
2965 | }
|
2966 |
|
2967 | if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
|
2968 | var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
|
2969 |
|
2970 | warningWithoutStack$1(false, 'Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
|
2971 | }
|
2972 |
|
2973 | if (componentWillMountUniqueNames.size > 0) {
|
2974 | var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
|
2975 |
|
2976 | lowPriorityWarningWithoutStack$1(false, 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3);
|
2977 | }
|
2978 |
|
2979 | if (componentWillReceivePropsUniqueNames.size > 0) {
|
2980 | var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
|
2981 |
|
2982 | lowPriorityWarningWithoutStack$1(false, 'componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4);
|
2983 | }
|
2984 |
|
2985 | if (componentWillUpdateUniqueNames.size > 0) {
|
2986 | var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
|
2987 |
|
2988 | lowPriorityWarningWithoutStack$1(false, 'componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5);
|
2989 | }
|
2990 | };
|
2991 |
|
2992 | var pendingLegacyContextWarning = new Map();
|
2993 |
|
2994 | var didWarnAboutLegacyContext = new Set();
|
2995 |
|
2996 | ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
|
2997 | var strictRoot = findStrictRoot(fiber);
|
2998 |
|
2999 | if (strictRoot === null) {
|
3000 | warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3001 | return;
|
3002 | }
|
3003 |
|
3004 |
|
3005 | if (didWarnAboutLegacyContext.has(fiber.type)) {
|
3006 | return;
|
3007 | }
|
3008 |
|
3009 | var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
|
3010 |
|
3011 | if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
|
3012 | if (warningsForRoot === undefined) {
|
3013 | warningsForRoot = [];
|
3014 | pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
|
3015 | }
|
3016 |
|
3017 | warningsForRoot.push(fiber);
|
3018 | }
|
3019 | };
|
3020 |
|
3021 | ReactStrictModeWarnings.flushLegacyContextWarning = function () {
|
3022 | pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
|
3023 | var uniqueNames = new Set();
|
3024 | fiberArray.forEach(function (fiber) {
|
3025 | uniqueNames.add(getComponentName(fiber.type) || 'Component');
|
3026 | didWarnAboutLegacyContext.add(fiber.type);
|
3027 | });
|
3028 | var sortedNames = setToSortedString(uniqueNames);
|
3029 | var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
|
3030 | warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, strictRootComponentStack);
|
3031 | });
|
3032 | };
|
3033 |
|
3034 | ReactStrictModeWarnings.discardPendingWarnings = function () {
|
3035 | pendingComponentWillMountWarnings = [];
|
3036 | pendingUNSAFE_ComponentWillMountWarnings = [];
|
3037 | pendingComponentWillReceivePropsWarnings = [];
|
3038 | pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
3039 | pendingComponentWillUpdateWarnings = [];
|
3040 | pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
3041 | pendingLegacyContextWarning = new Map();
|
3042 | };
|
3043 | }
|
3044 |
|
3045 | var resolveFamily = null;
|
3046 |
|
3047 | var failedBoundaries = null;
|
3048 | var setRefreshHandler = function (handler) {
|
3049 | {
|
3050 | resolveFamily = handler;
|
3051 | }
|
3052 | };
|
3053 | function resolveFunctionForHotReloading(type) {
|
3054 | {
|
3055 | if (resolveFamily === null) {
|
3056 |
|
3057 | return type;
|
3058 | }
|
3059 |
|
3060 | var family = resolveFamily(type);
|
3061 |
|
3062 | if (family === undefined) {
|
3063 | return type;
|
3064 | }
|
3065 |
|
3066 |
|
3067 | return family.current;
|
3068 | }
|
3069 | }
|
3070 | function resolveClassForHotReloading(type) {
|
3071 |
|
3072 | return resolveFunctionForHotReloading(type);
|
3073 | }
|
3074 | function resolveForwardRefForHotReloading(type) {
|
3075 | {
|
3076 | if (resolveFamily === null) {
|
3077 |
|
3078 | return type;
|
3079 | }
|
3080 |
|
3081 | var family = resolveFamily(type);
|
3082 |
|
3083 | if (family === undefined) {
|
3084 |
|
3085 | if (type !== null && type !== undefined && typeof type.render === 'function') {
|
3086 |
|
3087 |
|
3088 |
|
3089 | var currentRender = resolveFunctionForHotReloading(type.render);
|
3090 |
|
3091 | if (type.render !== currentRender) {
|
3092 | var syntheticType = {
|
3093 | $$typeof: REACT_FORWARD_REF_TYPE,
|
3094 | render: currentRender
|
3095 | };
|
3096 |
|
3097 | if (type.displayName !== undefined) {
|
3098 | syntheticType.displayName = type.displayName;
|
3099 | }
|
3100 |
|
3101 | return syntheticType;
|
3102 | }
|
3103 | }
|
3104 |
|
3105 | return type;
|
3106 | }
|
3107 |
|
3108 |
|
3109 | return family.current;
|
3110 | }
|
3111 | }
|
3112 | function isCompatibleFamilyForHotReloading(fiber, element) {
|
3113 | {
|
3114 | if (resolveFamily === null) {
|
3115 |
|
3116 | return false;
|
3117 | }
|
3118 |
|
3119 | var prevType = fiber.elementType;
|
3120 | var nextType = element.type;
|
3121 |
|
3122 | var needsCompareFamilies = false;
|
3123 | var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
|
3124 |
|
3125 | switch (fiber.tag) {
|
3126 | case ClassComponent:
|
3127 | {
|
3128 | if (typeof nextType === 'function') {
|
3129 | needsCompareFamilies = true;
|
3130 | }
|
3131 |
|
3132 | break;
|
3133 | }
|
3134 |
|
3135 | case FunctionComponent:
|
3136 | {
|
3137 | if (typeof nextType === 'function') {
|
3138 | needsCompareFamilies = true;
|
3139 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
3140 |
|
3141 |
|
3142 |
|
3143 |
|
3144 | needsCompareFamilies = true;
|
3145 | }
|
3146 |
|
3147 | break;
|
3148 | }
|
3149 |
|
3150 | case ForwardRef:
|
3151 | {
|
3152 | if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
|
3153 | needsCompareFamilies = true;
|
3154 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
3155 | needsCompareFamilies = true;
|
3156 | }
|
3157 |
|
3158 | break;
|
3159 | }
|
3160 |
|
3161 | case MemoComponent:
|
3162 | case SimpleMemoComponent:
|
3163 | {
|
3164 | if ($$typeofNextType === REACT_MEMO_TYPE) {
|
3165 |
|
3166 |
|
3167 | needsCompareFamilies = true;
|
3168 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
3169 | needsCompareFamilies = true;
|
3170 | }
|
3171 |
|
3172 | break;
|
3173 | }
|
3174 |
|
3175 | default:
|
3176 | return false;
|
3177 | }
|
3178 |
|
3179 |
|
3180 | if (needsCompareFamilies) {
|
3181 |
|
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 | var prevFamily = resolveFamily(prevType);
|
3187 |
|
3188 | if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
|
3189 | return true;
|
3190 | }
|
3191 | }
|
3192 |
|
3193 | return false;
|
3194 | }
|
3195 | }
|
3196 | function markFailedErrorBoundaryForHotReloading(fiber) {
|
3197 | {
|
3198 | if (resolveFamily === null) {
|
3199 |
|
3200 | return;
|
3201 | }
|
3202 |
|
3203 | if (typeof WeakSet !== 'function') {
|
3204 | return;
|
3205 | }
|
3206 |
|
3207 | if (failedBoundaries === null) {
|
3208 | failedBoundaries = new WeakSet();
|
3209 | }
|
3210 |
|
3211 | failedBoundaries.add(fiber);
|
3212 | }
|
3213 | }
|
3214 | var scheduleRefresh = function (root, update) {
|
3215 | {
|
3216 | if (resolveFamily === null) {
|
3217 |
|
3218 | return;
|
3219 | }
|
3220 |
|
3221 | var staleFamilies = update.staleFamilies,
|
3222 | updatedFamilies = update.updatedFamilies;
|
3223 | flushPassiveEffects();
|
3224 | flushSync(function () {
|
3225 | scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
|
3226 | });
|
3227 | }
|
3228 | };
|
3229 | var scheduleRoot = function (root, element) {
|
3230 | {
|
3231 | if (root.context !== emptyContextObject) {
|
3232 |
|
3233 |
|
3234 |
|
3235 | return;
|
3236 | }
|
3237 |
|
3238 | flushPassiveEffects();
|
3239 | syncUpdates(function () {
|
3240 | updateContainer(element, root, null, null);
|
3241 | });
|
3242 | }
|
3243 | };
|
3244 |
|
3245 | function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
|
3246 | {
|
3247 | var alternate = fiber.alternate,
|
3248 | child = fiber.child,
|
3249 | sibling = fiber.sibling,
|
3250 | tag = fiber.tag,
|
3251 | type = fiber.type;
|
3252 | var candidateType = null;
|
3253 |
|
3254 | switch (tag) {
|
3255 | case FunctionComponent:
|
3256 | case SimpleMemoComponent:
|
3257 | case ClassComponent:
|
3258 | candidateType = type;
|
3259 | break;
|
3260 |
|
3261 | case ForwardRef:
|
3262 | candidateType = type.render;
|
3263 | break;
|
3264 |
|
3265 | default:
|
3266 | break;
|
3267 | }
|
3268 |
|
3269 | if (resolveFamily === null) {
|
3270 | throw new Error('Expected resolveFamily to be set during hot reload.');
|
3271 | }
|
3272 |
|
3273 | var needsRender = false;
|
3274 | var needsRemount = false;
|
3275 |
|
3276 | if (candidateType !== null) {
|
3277 | var family = resolveFamily(candidateType);
|
3278 |
|
3279 | if (family !== undefined) {
|
3280 | if (staleFamilies.has(family)) {
|
3281 | needsRemount = true;
|
3282 | } else if (updatedFamilies.has(family)) {
|
3283 | if (tag === ClassComponent) {
|
3284 | needsRemount = true;
|
3285 | } else {
|
3286 | needsRender = true;
|
3287 | }
|
3288 | }
|
3289 | }
|
3290 | }
|
3291 |
|
3292 | if (failedBoundaries !== null) {
|
3293 | if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
|
3294 | needsRemount = true;
|
3295 | }
|
3296 | }
|
3297 |
|
3298 | if (needsRemount) {
|
3299 | fiber._debugNeedsRemount = true;
|
3300 | }
|
3301 |
|
3302 | if (needsRemount || needsRender) {
|
3303 | scheduleWork(fiber, Sync);
|
3304 | }
|
3305 |
|
3306 | if (child !== null && !needsRemount) {
|
3307 | scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
|
3308 | }
|
3309 |
|
3310 | if (sibling !== null) {
|
3311 | scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
|
3312 | }
|
3313 | }
|
3314 | }
|
3315 |
|
3316 | var findHostInstancesForRefresh = function (root, families) {
|
3317 | {
|
3318 | var hostInstances = new Set();
|
3319 | var types = new Set(families.map(function (family) {
|
3320 | return family.current;
|
3321 | }));
|
3322 | findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
|
3323 | return hostInstances;
|
3324 | }
|
3325 | };
|
3326 |
|
3327 | function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
|
3328 | {
|
3329 | var child = fiber.child,
|
3330 | sibling = fiber.sibling,
|
3331 | tag = fiber.tag,
|
3332 | type = fiber.type;
|
3333 | var candidateType = null;
|
3334 |
|
3335 | switch (tag) {
|
3336 | case FunctionComponent:
|
3337 | case SimpleMemoComponent:
|
3338 | case ClassComponent:
|
3339 | candidateType = type;
|
3340 | break;
|
3341 |
|
3342 | case ForwardRef:
|
3343 | candidateType = type.render;
|
3344 | break;
|
3345 |
|
3346 | default:
|
3347 | break;
|
3348 | }
|
3349 |
|
3350 | var didMatch = false;
|
3351 |
|
3352 | if (candidateType !== null) {
|
3353 | if (types.has(candidateType)) {
|
3354 | didMatch = true;
|
3355 | }
|
3356 | }
|
3357 |
|
3358 | if (didMatch) {
|
3359 |
|
3360 |
|
3361 |
|
3362 | findHostInstancesForFiberShallowly(fiber, hostInstances);
|
3363 | } else {
|
3364 |
|
3365 | if (child !== null) {
|
3366 | findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
|
3367 | }
|
3368 | }
|
3369 |
|
3370 | if (sibling !== null) {
|
3371 | findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
|
3372 | }
|
3373 | }
|
3374 | }
|
3375 |
|
3376 | function findHostInstancesForFiberShallowly(fiber, hostInstances) {
|
3377 | {
|
3378 | var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
|
3379 |
|
3380 | if (foundHostInstances) {
|
3381 | return;
|
3382 | }
|
3383 |
|
3384 |
|
3385 | var node = fiber;
|
3386 |
|
3387 | while (true) {
|
3388 | switch (node.tag) {
|
3389 | case HostComponent:
|
3390 | hostInstances.add(node.stateNode);
|
3391 | return;
|
3392 |
|
3393 | case HostPortal:
|
3394 | hostInstances.add(node.stateNode.containerInfo);
|
3395 | return;
|
3396 |
|
3397 | case HostRoot:
|
3398 | hostInstances.add(node.stateNode.containerInfo);
|
3399 | return;
|
3400 | }
|
3401 |
|
3402 | if (node.return === null) {
|
3403 | throw new Error('Expected to reach root first.');
|
3404 | }
|
3405 |
|
3406 | node = node.return;
|
3407 | }
|
3408 | }
|
3409 | }
|
3410 |
|
3411 | function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
|
3412 | {
|
3413 | var node = fiber;
|
3414 | var foundHostInstances = false;
|
3415 |
|
3416 | while (true) {
|
3417 | if (node.tag === HostComponent) {
|
3418 |
|
3419 | foundHostInstances = true;
|
3420 | hostInstances.add(node.stateNode);
|
3421 | } else if (node.child !== null) {
|
3422 | node.child.return = node;
|
3423 | node = node.child;
|
3424 | continue;
|
3425 | }
|
3426 |
|
3427 | if (node === fiber) {
|
3428 | return foundHostInstances;
|
3429 | }
|
3430 |
|
3431 | while (node.sibling === null) {
|
3432 | if (node.return === null || node.return === fiber) {
|
3433 | return foundHostInstances;
|
3434 | }
|
3435 |
|
3436 | node = node.return;
|
3437 | }
|
3438 |
|
3439 | node.sibling.return = node.return;
|
3440 | node = node.sibling;
|
3441 | }
|
3442 | }
|
3443 |
|
3444 | return false;
|
3445 | }
|
3446 |
|
3447 | function resolveDefaultProps(Component, baseProps) {
|
3448 | if (Component && Component.defaultProps) {
|
3449 |
|
3450 | var props = _assign({}, baseProps);
|
3451 |
|
3452 | var defaultProps = Component.defaultProps;
|
3453 |
|
3454 | for (var propName in defaultProps) {
|
3455 | if (props[propName] === undefined) {
|
3456 | props[propName] = defaultProps[propName];
|
3457 | }
|
3458 | }
|
3459 |
|
3460 | return props;
|
3461 | }
|
3462 |
|
3463 | return baseProps;
|
3464 | }
|
3465 | function readLazyComponentType(lazyComponent) {
|
3466 | initializeLazyComponentType(lazyComponent);
|
3467 |
|
3468 | if (lazyComponent._status !== Resolved) {
|
3469 | throw lazyComponent._result;
|
3470 | }
|
3471 |
|
3472 | return lazyComponent._result;
|
3473 | }
|
3474 |
|
3475 | var valueCursor = createCursor(null);
|
3476 | var rendererSigil;
|
3477 |
|
3478 | {
|
3479 |
|
3480 | rendererSigil = {};
|
3481 | }
|
3482 |
|
3483 | var currentlyRenderingFiber = null;
|
3484 | var lastContextDependency = null;
|
3485 | var lastContextWithAllBitsObserved = null;
|
3486 | var isDisallowedContextReadInDEV = false;
|
3487 | function resetContextDependencies() {
|
3488 |
|
3489 |
|
3490 | currentlyRenderingFiber = null;
|
3491 | lastContextDependency = null;
|
3492 | lastContextWithAllBitsObserved = null;
|
3493 |
|
3494 | {
|
3495 | isDisallowedContextReadInDEV = false;
|
3496 | }
|
3497 | }
|
3498 | function enterDisallowedContextReadInDEV() {
|
3499 | {
|
3500 | isDisallowedContextReadInDEV = true;
|
3501 | }
|
3502 | }
|
3503 | function exitDisallowedContextReadInDEV() {
|
3504 | {
|
3505 | isDisallowedContextReadInDEV = false;
|
3506 | }
|
3507 | }
|
3508 | function pushProvider(providerFiber, nextValue) {
|
3509 | var context = providerFiber.type._context;
|
3510 |
|
3511 | if (isPrimaryRenderer) {
|
3512 | push(valueCursor, context._currentValue, providerFiber);
|
3513 | context._currentValue = nextValue;
|
3514 |
|
3515 | {
|
3516 | !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
|
3517 | context._currentRenderer = rendererSigil;
|
3518 | }
|
3519 | } else {
|
3520 | push(valueCursor, context._currentValue2, providerFiber);
|
3521 | context._currentValue2 = nextValue;
|
3522 |
|
3523 | {
|
3524 | !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
|
3525 | context._currentRenderer2 = rendererSigil;
|
3526 | }
|
3527 | }
|
3528 | }
|
3529 | function popProvider(providerFiber) {
|
3530 | var currentValue = valueCursor.current;
|
3531 | pop(valueCursor, providerFiber);
|
3532 | var context = providerFiber.type._context;
|
3533 |
|
3534 | if (isPrimaryRenderer) {
|
3535 | context._currentValue = currentValue;
|
3536 | } else {
|
3537 | context._currentValue2 = currentValue;
|
3538 | }
|
3539 | }
|
3540 | function calculateChangedBits(context, newValue, oldValue) {
|
3541 | if (is$1(oldValue, newValue)) {
|
3542 |
|
3543 | return 0;
|
3544 | } else {
|
3545 | var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
|
3546 |
|
3547 | {
|
3548 | !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
|
3549 | }
|
3550 |
|
3551 | return changedBits | 0;
|
3552 | }
|
3553 | }
|
3554 | function scheduleWorkOnParentPath(parent, renderExpirationTime) {
|
3555 |
|
3556 |
|
3557 | var node = parent;
|
3558 |
|
3559 | while (node !== null) {
|
3560 | var alternate = node.alternate;
|
3561 |
|
3562 | if (node.childExpirationTime < renderExpirationTime) {
|
3563 | node.childExpirationTime = renderExpirationTime;
|
3564 |
|
3565 | if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
3566 | alternate.childExpirationTime = renderExpirationTime;
|
3567 | }
|
3568 | } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
3569 | alternate.childExpirationTime = renderExpirationTime;
|
3570 | } else {
|
3571 |
|
3572 |
|
3573 | break;
|
3574 | }
|
3575 |
|
3576 | node = node.return;
|
3577 | }
|
3578 | }
|
3579 | function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
|
3580 | var fiber = workInProgress.child;
|
3581 |
|
3582 | if (fiber !== null) {
|
3583 |
|
3584 | fiber.return = workInProgress;
|
3585 | }
|
3586 |
|
3587 | while (fiber !== null) {
|
3588 | var nextFiber = void 0;
|
3589 |
|
3590 | var list = fiber.dependencies;
|
3591 |
|
3592 | if (list !== null) {
|
3593 | nextFiber = fiber.child;
|
3594 | var dependency = list.firstContext;
|
3595 |
|
3596 | while (dependency !== null) {
|
3597 |
|
3598 | if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
|
3599 |
|
3600 | if (fiber.tag === ClassComponent) {
|
3601 |
|
3602 | var update = createUpdate(renderExpirationTime, null);
|
3603 | update.tag = ForceUpdate;
|
3604 |
|
3605 |
|
3606 |
|
3607 |
|
3608 | enqueueUpdate(fiber, update);
|
3609 | }
|
3610 |
|
3611 | if (fiber.expirationTime < renderExpirationTime) {
|
3612 | fiber.expirationTime = renderExpirationTime;
|
3613 | }
|
3614 |
|
3615 | var alternate = fiber.alternate;
|
3616 |
|
3617 | if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
|
3618 | alternate.expirationTime = renderExpirationTime;
|
3619 | }
|
3620 |
|
3621 | scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
|
3622 |
|
3623 | if (list.expirationTime < renderExpirationTime) {
|
3624 | list.expirationTime = renderExpirationTime;
|
3625 | }
|
3626 |
|
3627 |
|
3628 |
|
3629 | break;
|
3630 | }
|
3631 |
|
3632 | dependency = dependency.next;
|
3633 | }
|
3634 | } else if (fiber.tag === ContextProvider) {
|
3635 |
|
3636 | nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
|
3637 | } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedFragment) {
|
3638 |
|
3639 |
|
3640 |
|
3641 | var parentSuspense = fiber.return;
|
3642 |
|
3643 | if (!(parentSuspense !== null)) {
|
3644 | {
|
3645 | throw Error("We just came from a parent so we must have had a parent. This is a bug in React.");
|
3646 | }
|
3647 | }
|
3648 |
|
3649 | if (parentSuspense.expirationTime < renderExpirationTime) {
|
3650 | parentSuspense.expirationTime = renderExpirationTime;
|
3651 | }
|
3652 |
|
3653 | var _alternate = parentSuspense.alternate;
|
3654 |
|
3655 | if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
|
3656 | _alternate.expirationTime = renderExpirationTime;
|
3657 | }
|
3658 |
|
3659 |
|
3660 |
|
3661 |
|
3662 |
|
3663 | scheduleWorkOnParentPath(parentSuspense, renderExpirationTime);
|
3664 | nextFiber = fiber.sibling;
|
3665 | } else {
|
3666 |
|
3667 | nextFiber = fiber.child;
|
3668 | }
|
3669 |
|
3670 | if (nextFiber !== null) {
|
3671 |
|
3672 | nextFiber.return = fiber;
|
3673 | } else {
|
3674 |
|
3675 | nextFiber = fiber;
|
3676 |
|
3677 | while (nextFiber !== null) {
|
3678 | if (nextFiber === workInProgress) {
|
3679 |
|
3680 | nextFiber = null;
|
3681 | break;
|
3682 | }
|
3683 |
|
3684 | var sibling = nextFiber.sibling;
|
3685 |
|
3686 | if (sibling !== null) {
|
3687 |
|
3688 | sibling.return = nextFiber.return;
|
3689 | nextFiber = sibling;
|
3690 | break;
|
3691 | }
|
3692 |
|
3693 |
|
3694 | nextFiber = nextFiber.return;
|
3695 | }
|
3696 | }
|
3697 |
|
3698 | fiber = nextFiber;
|
3699 | }
|
3700 | }
|
3701 | function prepareToReadContext(workInProgress, renderExpirationTime) {
|
3702 | currentlyRenderingFiber = workInProgress;
|
3703 | lastContextDependency = null;
|
3704 | lastContextWithAllBitsObserved = null;
|
3705 | var dependencies = workInProgress.dependencies;
|
3706 |
|
3707 | if (dependencies !== null) {
|
3708 | var firstContext = dependencies.firstContext;
|
3709 |
|
3710 | if (firstContext !== null) {
|
3711 | if (dependencies.expirationTime >= renderExpirationTime) {
|
3712 |
|
3713 | markWorkInProgressReceivedUpdate();
|
3714 | }
|
3715 |
|
3716 |
|
3717 | dependencies.firstContext = null;
|
3718 | }
|
3719 | }
|
3720 | }
|
3721 | function readContext(context, observedBits) {
|
3722 | {
|
3723 |
|
3724 |
|
3725 | !!isDisallowedContextReadInDEV ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
|
3726 | }
|
3727 |
|
3728 | if (lastContextWithAllBitsObserved === context) {
|
3729 | } else if (observedBits === false || observedBits === 0) {
|
3730 | } else {
|
3731 | var resolvedObservedBits;
|
3732 |
|
3733 | if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
|
3734 |
|
3735 | lastContextWithAllBitsObserved = context;
|
3736 | resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
|
3737 | } else {
|
3738 | resolvedObservedBits = observedBits;
|
3739 | }
|
3740 |
|
3741 | var contextItem = {
|
3742 | context: context,
|
3743 | observedBits: resolvedObservedBits,
|
3744 | next: null
|
3745 | };
|
3746 |
|
3747 | if (lastContextDependency === null) {
|
3748 | if (!(currentlyRenderingFiber !== null)) {
|
3749 | {
|
3750 | throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
|
3751 | }
|
3752 | }
|
3753 |
|
3754 |
|
3755 | lastContextDependency = contextItem;
|
3756 | currentlyRenderingFiber.dependencies = {
|
3757 | expirationTime: NoWork,
|
3758 | firstContext: contextItem,
|
3759 | responders: null
|
3760 | };
|
3761 | } else {
|
3762 |
|
3763 | lastContextDependency = lastContextDependency.next = contextItem;
|
3764 | }
|
3765 | }
|
3766 |
|
3767 | return isPrimaryRenderer ? context._currentValue : context._currentValue2;
|
3768 | }
|
3769 |
|
3770 |
|
3771 |
|
3772 |
|
3773 |
|
3774 |
|
3775 |
|
3776 |
|
3777 |
|
3778 |
|
3779 |
|
3780 |
|
3781 |
|
3782 |
|
3783 |
|
3784 |
|
3785 |
|
3786 |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 |
|
3792 |
|
3793 |
|
3794 |
|
3795 |
|
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 |
|
3801 |
|
3802 |
|
3803 |
|
3804 |
|
3805 |
|
3806 |
|
3807 |
|
3808 |
|
3809 |
|
3810 |
|
3811 |
|
3812 |
|
3813 |
|
3814 |
|
3815 |
|
3816 |
|
3817 |
|
3818 |
|
3819 |
|
3820 |
|
3821 |
|
3822 |
|
3823 |
|
3824 |
|
3825 |
|
3826 |
|
3827 |
|
3828 |
|
3829 |
|
3830 |
|
3831 |
|
3832 |
|
3833 |
|
3834 |
|
3835 |
|
3836 |
|
3837 |
|
3838 |
|
3839 |
|
3840 |
|
3841 |
|
3842 |
|
3843 |
|
3844 |
|
3845 |
|
3846 | var UpdateState = 0;
|
3847 | var ReplaceState = 1;
|
3848 | var ForceUpdate = 2;
|
3849 | var CaptureUpdate = 3;
|
3850 |
|
3851 |
|
3852 |
|
3853 | var hasForceUpdate = false;
|
3854 | var didWarnUpdateInsideUpdate;
|
3855 | var currentlyProcessingQueue;
|
3856 |
|
3857 |
|
3858 | {
|
3859 | didWarnUpdateInsideUpdate = false;
|
3860 | currentlyProcessingQueue = null;
|
3861 |
|
3862 |
|
3863 | }
|
3864 |
|
3865 | function createUpdateQueue(baseState) {
|
3866 | var queue = {
|
3867 | baseState: baseState,
|
3868 | firstUpdate: null,
|
3869 | lastUpdate: null,
|
3870 | firstCapturedUpdate: null,
|
3871 | lastCapturedUpdate: null,
|
3872 | firstEffect: null,
|
3873 | lastEffect: null,
|
3874 | firstCapturedEffect: null,
|
3875 | lastCapturedEffect: null
|
3876 | };
|
3877 | return queue;
|
3878 | }
|
3879 |
|
3880 | function cloneUpdateQueue(currentQueue) {
|
3881 | var queue = {
|
3882 | baseState: currentQueue.baseState,
|
3883 | firstUpdate: currentQueue.firstUpdate,
|
3884 | lastUpdate: currentQueue.lastUpdate,
|
3885 |
|
3886 |
|
3887 | firstCapturedUpdate: null,
|
3888 | lastCapturedUpdate: null,
|
3889 | firstEffect: null,
|
3890 | lastEffect: null,
|
3891 | firstCapturedEffect: null,
|
3892 | lastCapturedEffect: null
|
3893 | };
|
3894 | return queue;
|
3895 | }
|
3896 |
|
3897 | function createUpdate(expirationTime, suspenseConfig) {
|
3898 | var update = {
|
3899 | expirationTime: expirationTime,
|
3900 | suspenseConfig: suspenseConfig,
|
3901 | tag: UpdateState,
|
3902 | payload: null,
|
3903 | callback: null,
|
3904 | next: null,
|
3905 | nextEffect: null
|
3906 | };
|
3907 |
|
3908 | {
|
3909 | update.priority = getCurrentPriorityLevel();
|
3910 | }
|
3911 |
|
3912 | return update;
|
3913 | }
|
3914 |
|
3915 | function appendUpdateToQueue(queue, update) {
|
3916 |
|
3917 | if (queue.lastUpdate === null) {
|
3918 |
|
3919 | queue.firstUpdate = queue.lastUpdate = update;
|
3920 | } else {
|
3921 | queue.lastUpdate.next = update;
|
3922 | queue.lastUpdate = update;
|
3923 | }
|
3924 | }
|
3925 |
|
3926 | function enqueueUpdate(fiber, update) {
|
3927 |
|
3928 | var alternate = fiber.alternate;
|
3929 | var queue1;
|
3930 | var queue2;
|
3931 |
|
3932 | if (alternate === null) {
|
3933 |
|
3934 | queue1 = fiber.updateQueue;
|
3935 | queue2 = null;
|
3936 |
|
3937 | if (queue1 === null) {
|
3938 | queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
|
3939 | }
|
3940 | } else {
|
3941 |
|
3942 | queue1 = fiber.updateQueue;
|
3943 | queue2 = alternate.updateQueue;
|
3944 |
|
3945 | if (queue1 === null) {
|
3946 | if (queue2 === null) {
|
3947 |
|
3948 | queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
|
3949 | queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
|
3950 | } else {
|
3951 |
|
3952 | queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
|
3953 | }
|
3954 | } else {
|
3955 | if (queue2 === null) {
|
3956 |
|
3957 | queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
|
3958 | } else {
|
3959 | }
|
3960 | }
|
3961 | }
|
3962 |
|
3963 | if (queue2 === null || queue1 === queue2) {
|
3964 |
|
3965 | appendUpdateToQueue(queue1, update);
|
3966 | } else {
|
3967 |
|
3968 |
|
3969 |
|
3970 | if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
|
3971 |
|
3972 | appendUpdateToQueue(queue1, update);
|
3973 | appendUpdateToQueue(queue2, update);
|
3974 | } else {
|
3975 |
|
3976 |
|
3977 | appendUpdateToQueue(queue1, update);
|
3978 |
|
3979 | queue2.lastUpdate = update;
|
3980 | }
|
3981 | }
|
3982 |
|
3983 | {
|
3984 | if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
|
3985 | warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
|
3986 | didWarnUpdateInsideUpdate = true;
|
3987 | }
|
3988 | }
|
3989 | }
|
3990 | function enqueueCapturedUpdate(workInProgress, update) {
|
3991 |
|
3992 |
|
3993 | var workInProgressQueue = workInProgress.updateQueue;
|
3994 |
|
3995 | if (workInProgressQueue === null) {
|
3996 | workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
|
3997 | } else {
|
3998 |
|
3999 |
|
4000 |
|
4001 | workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
|
4002 | }
|
4003 |
|
4004 |
|
4005 | if (workInProgressQueue.lastCapturedUpdate === null) {
|
4006 |
|
4007 | workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
|
4008 | } else {
|
4009 | workInProgressQueue.lastCapturedUpdate.next = update;
|
4010 | workInProgressQueue.lastCapturedUpdate = update;
|
4011 | }
|
4012 | }
|
4013 |
|
4014 | function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
|
4015 | var current = workInProgress.alternate;
|
4016 |
|
4017 | if (current !== null) {
|
4018 |
|
4019 |
|
4020 | if (queue === current.updateQueue) {
|
4021 | queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
|
4022 | }
|
4023 | }
|
4024 |
|
4025 | return queue;
|
4026 | }
|
4027 |
|
4028 | function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
|
4029 | switch (update.tag) {
|
4030 | case ReplaceState:
|
4031 | {
|
4032 | var payload = update.payload;
|
4033 |
|
4034 | if (typeof payload === 'function') {
|
4035 |
|
4036 | {
|
4037 | enterDisallowedContextReadInDEV();
|
4038 |
|
4039 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
4040 | payload.call(instance, prevState, nextProps);
|
4041 | }
|
4042 | }
|
4043 |
|
4044 | var nextState = payload.call(instance, prevState, nextProps);
|
4045 |
|
4046 | {
|
4047 | exitDisallowedContextReadInDEV();
|
4048 | }
|
4049 |
|
4050 | return nextState;
|
4051 | }
|
4052 |
|
4053 |
|
4054 | return payload;
|
4055 | }
|
4056 |
|
4057 | case CaptureUpdate:
|
4058 | {
|
4059 | workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
|
4060 | }
|
4061 |
|
4062 |
|
4063 | case UpdateState:
|
4064 | {
|
4065 | var _payload = update.payload;
|
4066 | var partialState;
|
4067 |
|
4068 | if (typeof _payload === 'function') {
|
4069 |
|
4070 | {
|
4071 | enterDisallowedContextReadInDEV();
|
4072 |
|
4073 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
4074 | _payload.call(instance, prevState, nextProps);
|
4075 | }
|
4076 | }
|
4077 |
|
4078 | partialState = _payload.call(instance, prevState, nextProps);
|
4079 |
|
4080 | {
|
4081 | exitDisallowedContextReadInDEV();
|
4082 | }
|
4083 | } else {
|
4084 |
|
4085 | partialState = _payload;
|
4086 | }
|
4087 |
|
4088 | if (partialState === null || partialState === undefined) {
|
4089 |
|
4090 | return prevState;
|
4091 | }
|
4092 |
|
4093 |
|
4094 | return _assign({}, prevState, partialState);
|
4095 | }
|
4096 |
|
4097 | case ForceUpdate:
|
4098 | {
|
4099 | hasForceUpdate = true;
|
4100 | return prevState;
|
4101 | }
|
4102 | }
|
4103 |
|
4104 | return prevState;
|
4105 | }
|
4106 |
|
4107 | function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
|
4108 | hasForceUpdate = false;
|
4109 | queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
|
4110 |
|
4111 | {
|
4112 | currentlyProcessingQueue = queue;
|
4113 | }
|
4114 |
|
4115 |
|
4116 | var newBaseState = queue.baseState;
|
4117 | var newFirstUpdate = null;
|
4118 | var newExpirationTime = NoWork;
|
4119 |
|
4120 | var update = queue.firstUpdate;
|
4121 | var resultState = newBaseState;
|
4122 |
|
4123 | while (update !== null) {
|
4124 | var updateExpirationTime = update.expirationTime;
|
4125 |
|
4126 | if (updateExpirationTime < renderExpirationTime) {
|
4127 |
|
4128 | if (newFirstUpdate === null) {
|
4129 |
|
4130 |
|
4131 | newFirstUpdate = update;
|
4132 |
|
4133 |
|
4134 | newBaseState = resultState;
|
4135 | }
|
4136 |
|
4137 |
|
4138 |
|
4139 | if (newExpirationTime < updateExpirationTime) {
|
4140 | newExpirationTime = updateExpirationTime;
|
4141 | }
|
4142 | } else {
|
4143 |
|
4144 |
|
4145 |
|
4146 |
|
4147 |
|
4148 |
|
4149 |
|
4150 | markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig);
|
4151 |
|
4152 | resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
|
4153 | var callback = update.callback;
|
4154 |
|
4155 | if (callback !== null) {
|
4156 | workInProgress.effectTag |= Callback;
|
4157 |
|
4158 | update.nextEffect = null;
|
4159 |
|
4160 | if (queue.lastEffect === null) {
|
4161 | queue.firstEffect = queue.lastEffect = update;
|
4162 | } else {
|
4163 | queue.lastEffect.nextEffect = update;
|
4164 | queue.lastEffect = update;
|
4165 | }
|
4166 | }
|
4167 | }
|
4168 |
|
4169 |
|
4170 | update = update.next;
|
4171 | }
|
4172 |
|
4173 |
|
4174 | var newFirstCapturedUpdate = null;
|
4175 | update = queue.firstCapturedUpdate;
|
4176 |
|
4177 | while (update !== null) {
|
4178 | var _updateExpirationTime = update.expirationTime;
|
4179 |
|
4180 | if (_updateExpirationTime < renderExpirationTime) {
|
4181 |
|
4182 | if (newFirstCapturedUpdate === null) {
|
4183 |
|
4184 |
|
4185 | newFirstCapturedUpdate = update;
|
4186 |
|
4187 |
|
4188 | if (newFirstUpdate === null) {
|
4189 | newBaseState = resultState;
|
4190 | }
|
4191 | }
|
4192 |
|
4193 |
|
4194 |
|
4195 | if (newExpirationTime < _updateExpirationTime) {
|
4196 | newExpirationTime = _updateExpirationTime;
|
4197 | }
|
4198 | } else {
|
4199 |
|
4200 |
|
4201 | resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
|
4202 | var _callback = update.callback;
|
4203 |
|
4204 | if (_callback !== null) {
|
4205 | workInProgress.effectTag |= Callback;
|
4206 |
|
4207 | update.nextEffect = null;
|
4208 |
|
4209 | if (queue.lastCapturedEffect === null) {
|
4210 | queue.firstCapturedEffect = queue.lastCapturedEffect = update;
|
4211 | } else {
|
4212 | queue.lastCapturedEffect.nextEffect = update;
|
4213 | queue.lastCapturedEffect = update;
|
4214 | }
|
4215 | }
|
4216 | }
|
4217 |
|
4218 | update = update.next;
|
4219 | }
|
4220 |
|
4221 | if (newFirstUpdate === null) {
|
4222 | queue.lastUpdate = null;
|
4223 | }
|
4224 |
|
4225 | if (newFirstCapturedUpdate === null) {
|
4226 | queue.lastCapturedUpdate = null;
|
4227 | } else {
|
4228 | workInProgress.effectTag |= Callback;
|
4229 | }
|
4230 |
|
4231 | if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
|
4232 |
|
4233 |
|
4234 | newBaseState = resultState;
|
4235 | }
|
4236 |
|
4237 | queue.baseState = newBaseState;
|
4238 | queue.firstUpdate = newFirstUpdate;
|
4239 | queue.firstCapturedUpdate = newFirstCapturedUpdate;
|
4240 |
|
4241 |
|
4242 |
|
4243 |
|
4244 |
|
4245 |
|
4246 |
|
4247 | markUnprocessedUpdateTime(newExpirationTime);
|
4248 | workInProgress.expirationTime = newExpirationTime;
|
4249 | workInProgress.memoizedState = resultState;
|
4250 |
|
4251 | {
|
4252 | currentlyProcessingQueue = null;
|
4253 | }
|
4254 | }
|
4255 |
|
4256 | function callCallback(callback, context) {
|
4257 | if (!(typeof callback === 'function')) {
|
4258 | {
|
4259 | throw Error("Invalid argument passed as callback. Expected a function. Instead received: " + callback);
|
4260 | }
|
4261 | }
|
4262 |
|
4263 | callback.call(context);
|
4264 | }
|
4265 |
|
4266 | function resetHasForceUpdateBeforeProcessing() {
|
4267 | hasForceUpdate = false;
|
4268 | }
|
4269 | function checkHasForceUpdateAfterProcessing() {
|
4270 | return hasForceUpdate;
|
4271 | }
|
4272 | function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 | if (finishedQueue.firstCapturedUpdate !== null) {
|
4278 |
|
4279 | if (finishedQueue.lastUpdate !== null) {
|
4280 | finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
|
4281 | finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
|
4282 | }
|
4283 |
|
4284 |
|
4285 | finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
|
4286 | }
|
4287 |
|
4288 |
|
4289 | commitUpdateEffects(finishedQueue.firstEffect, instance);
|
4290 | finishedQueue.firstEffect = finishedQueue.lastEffect = null;
|
4291 | commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
|
4292 | finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
|
4293 | }
|
4294 |
|
4295 | function commitUpdateEffects(effect, instance) {
|
4296 | while (effect !== null) {
|
4297 | var callback = effect.callback;
|
4298 |
|
4299 | if (callback !== null) {
|
4300 | effect.callback = null;
|
4301 | callCallback(callback, instance);
|
4302 | }
|
4303 |
|
4304 | effect = effect.nextEffect;
|
4305 | }
|
4306 | }
|
4307 |
|
4308 | var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
|
4309 | function requestCurrentSuspenseConfig() {
|
4310 | return ReactCurrentBatchConfig.suspense;
|
4311 | }
|
4312 |
|
4313 | var fakeInternalInstance = {};
|
4314 | var isArray$1 = Array.isArray;
|
4315 |
|
4316 |
|
4317 | var emptyRefsObject = new React.Component().refs;
|
4318 | var didWarnAboutStateAssignmentForComponent;
|
4319 | var didWarnAboutUninitializedState;
|
4320 | var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
|
4321 | var didWarnAboutLegacyLifecyclesAndDerivedState;
|
4322 | var didWarnAboutUndefinedDerivedState;
|
4323 | var warnOnUndefinedDerivedState;
|
4324 | var warnOnInvalidCallback;
|
4325 | var didWarnAboutDirectlyAssigningPropsToState;
|
4326 | var didWarnAboutContextTypeAndContextTypes;
|
4327 | var didWarnAboutInvalidateContextType;
|
4328 |
|
4329 | {
|
4330 | didWarnAboutStateAssignmentForComponent = new Set();
|
4331 | didWarnAboutUninitializedState = new Set();
|
4332 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
|
4333 | didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
|
4334 | didWarnAboutDirectlyAssigningPropsToState = new Set();
|
4335 | didWarnAboutUndefinedDerivedState = new Set();
|
4336 | didWarnAboutContextTypeAndContextTypes = new Set();
|
4337 | didWarnAboutInvalidateContextType = new Set();
|
4338 | var didWarnOnInvalidCallback = new Set();
|
4339 |
|
4340 | warnOnInvalidCallback = function (callback, callerName) {
|
4341 | if (callback === null || typeof callback === 'function') {
|
4342 | return;
|
4343 | }
|
4344 |
|
4345 | var key = callerName + "_" + callback;
|
4346 |
|
4347 | if (!didWarnOnInvalidCallback.has(key)) {
|
4348 | didWarnOnInvalidCallback.add(key);
|
4349 | warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
|
4350 | }
|
4351 | };
|
4352 |
|
4353 | warnOnUndefinedDerivedState = function (type, partialState) {
|
4354 | if (partialState === undefined) {
|
4355 | var componentName = getComponentName(type) || 'Component';
|
4356 |
|
4357 | if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
|
4358 | didWarnAboutUndefinedDerivedState.add(componentName);
|
4359 | warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
|
4360 | }
|
4361 | }
|
4362 | };
|
4363 |
|
4364 |
|
4365 |
|
4366 |
|
4367 |
|
4368 |
|
4369 | Object.defineProperty(fakeInternalInstance, '_processChildContext', {
|
4370 | enumerable: false,
|
4371 | value: function () {
|
4372 | {
|
4373 | {
|
4374 | throw Error("_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).");
|
4375 | }
|
4376 | }
|
4377 | }
|
4378 | });
|
4379 | Object.freeze(fakeInternalInstance);
|
4380 | }
|
4381 |
|
4382 | function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
|
4383 | var prevState = workInProgress.memoizedState;
|
4384 |
|
4385 | {
|
4386 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
4387 |
|
4388 | getDerivedStateFromProps(nextProps, prevState);
|
4389 | }
|
4390 | }
|
4391 |
|
4392 | var partialState = getDerivedStateFromProps(nextProps, prevState);
|
4393 |
|
4394 | {
|
4395 | warnOnUndefinedDerivedState(ctor, partialState);
|
4396 | }
|
4397 |
|
4398 |
|
4399 | var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
|
4400 | workInProgress.memoizedState = memoizedState;
|
4401 |
|
4402 |
|
4403 | var updateQueue = workInProgress.updateQueue;
|
4404 |
|
4405 | if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
|
4406 | updateQueue.baseState = memoizedState;
|
4407 | }
|
4408 | }
|
4409 | var classComponentUpdater = {
|
4410 | isMounted: isMounted,
|
4411 | enqueueSetState: function (inst, payload, callback) {
|
4412 | var fiber = get(inst);
|
4413 | var currentTime = requestCurrentTimeForUpdate();
|
4414 | var suspenseConfig = requestCurrentSuspenseConfig();
|
4415 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
4416 | var update = createUpdate(expirationTime, suspenseConfig);
|
4417 | update.payload = payload;
|
4418 |
|
4419 | if (callback !== undefined && callback !== null) {
|
4420 | {
|
4421 | warnOnInvalidCallback(callback, 'setState');
|
4422 | }
|
4423 |
|
4424 | update.callback = callback;
|
4425 | }
|
4426 |
|
4427 | enqueueUpdate(fiber, update);
|
4428 | scheduleWork(fiber, expirationTime);
|
4429 | },
|
4430 | enqueueReplaceState: function (inst, payload, callback) {
|
4431 | var fiber = get(inst);
|
4432 | var currentTime = requestCurrentTimeForUpdate();
|
4433 | var suspenseConfig = requestCurrentSuspenseConfig();
|
4434 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
4435 | var update = createUpdate(expirationTime, suspenseConfig);
|
4436 | update.tag = ReplaceState;
|
4437 | update.payload = payload;
|
4438 |
|
4439 | if (callback !== undefined && callback !== null) {
|
4440 | {
|
4441 | warnOnInvalidCallback(callback, 'replaceState');
|
4442 | }
|
4443 |
|
4444 | update.callback = callback;
|
4445 | }
|
4446 |
|
4447 | enqueueUpdate(fiber, update);
|
4448 | scheduleWork(fiber, expirationTime);
|
4449 | },
|
4450 | enqueueForceUpdate: function (inst, callback) {
|
4451 | var fiber = get(inst);
|
4452 | var currentTime = requestCurrentTimeForUpdate();
|
4453 | var suspenseConfig = requestCurrentSuspenseConfig();
|
4454 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
4455 | var update = createUpdate(expirationTime, suspenseConfig);
|
4456 | update.tag = ForceUpdate;
|
4457 |
|
4458 | if (callback !== undefined && callback !== null) {
|
4459 | {
|
4460 | warnOnInvalidCallback(callback, 'forceUpdate');
|
4461 | }
|
4462 |
|
4463 | update.callback = callback;
|
4464 | }
|
4465 |
|
4466 | enqueueUpdate(fiber, update);
|
4467 | scheduleWork(fiber, expirationTime);
|
4468 | }
|
4469 | };
|
4470 |
|
4471 | function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
|
4472 | var instance = workInProgress.stateNode;
|
4473 |
|
4474 | if (typeof instance.shouldComponentUpdate === 'function') {
|
4475 | startPhaseTimer(workInProgress, 'shouldComponentUpdate');
|
4476 | var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
4477 | stopPhaseTimer();
|
4478 |
|
4479 | {
|
4480 | !(shouldUpdate !== undefined) ? warningWithoutStack$1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component') : void 0;
|
4481 | }
|
4482 |
|
4483 | return shouldUpdate;
|
4484 | }
|
4485 |
|
4486 | if (ctor.prototype && ctor.prototype.isPureReactComponent) {
|
4487 | return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
|
4488 | }
|
4489 |
|
4490 | return true;
|
4491 | }
|
4492 |
|
4493 | function checkClassInstance(workInProgress, ctor, newProps) {
|
4494 | var instance = workInProgress.stateNode;
|
4495 |
|
4496 | {
|
4497 | var name = getComponentName(ctor) || 'Component';
|
4498 | var renderPresent = instance.render;
|
4499 |
|
4500 | if (!renderPresent) {
|
4501 | if (ctor.prototype && typeof ctor.prototype.render === 'function') {
|
4502 | warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
|
4503 | } else {
|
4504 | warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
|
4505 | }
|
4506 | }
|
4507 |
|
4508 | var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
|
4509 | !noGetInitialStateOnES6 ? warningWithoutStack$1(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
|
4510 | var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
|
4511 | !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
|
4512 | var noInstancePropTypes = !instance.propTypes;
|
4513 | !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
|
4514 | var noInstanceContextType = !instance.contextType;
|
4515 | !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
|
4516 |
|
4517 | if (disableLegacyContext) {
|
4518 | if (ctor.childContextTypes) {
|
4519 | warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', name);
|
4520 | }
|
4521 |
|
4522 | if (ctor.contextTypes) {
|
4523 | warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', name);
|
4524 | }
|
4525 | } else {
|
4526 | var noInstanceContextTypes = !instance.contextTypes;
|
4527 | !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
|
4528 |
|
4529 | if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
|
4530 | didWarnAboutContextTypeAndContextTypes.add(ctor);
|
4531 | warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
|
4532 | }
|
4533 | }
|
4534 |
|
4535 | var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
|
4536 | !noComponentShouldUpdate ? warningWithoutStack$1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
|
4537 |
|
4538 | if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
|
4539 | warningWithoutStack$1(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
|
4540 | }
|
4541 |
|
4542 | var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
|
4543 | !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
|
4544 | var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
|
4545 | !noComponentDidReceiveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
|
4546 | var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
|
4547 | !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
|
4548 | var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
|
4549 | !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
|
4550 | var hasMutatedProps = instance.props !== newProps;
|
4551 | !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
|
4552 | var noInstanceDefaultProps = !instance.defaultProps;
|
4553 | !noInstanceDefaultProps ? warningWithoutStack$1(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
|
4554 |
|
4555 | if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
|
4556 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
|
4557 | warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
|
4558 | }
|
4559 |
|
4560 | var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
|
4561 | !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
|
4562 | var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
|
4563 | !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
|
4564 | var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
|
4565 | !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
|
4566 | var _state = instance.state;
|
4567 |
|
4568 | if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
|
4569 | warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
|
4570 | }
|
4571 |
|
4572 | if (typeof instance.getChildContext === 'function') {
|
4573 | !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
|
4574 | }
|
4575 | }
|
4576 | }
|
4577 |
|
4578 | function adoptClassInstance(workInProgress, instance) {
|
4579 | instance.updater = classComponentUpdater;
|
4580 | workInProgress.stateNode = instance;
|
4581 |
|
4582 | set$1(instance, workInProgress);
|
4583 |
|
4584 | {
|
4585 | instance._reactInternalInstance = fakeInternalInstance;
|
4586 | }
|
4587 | }
|
4588 |
|
4589 | function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
|
4590 | var isLegacyContextConsumer = false;
|
4591 | var unmaskedContext = emptyContextObject;
|
4592 | var context = emptyContextObject;
|
4593 | var contextType = ctor.contextType;
|
4594 |
|
4595 | {
|
4596 | if ('contextType' in ctor) {
|
4597 | var isValid =
|
4598 | contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined;
|
4599 |
|
4600 | if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
|
4601 | didWarnAboutInvalidateContextType.add(ctor);
|
4602 | var addendum = '';
|
4603 |
|
4604 | if (contextType === undefined) {
|
4605 | addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
|
4606 | } else if (typeof contextType !== 'object') {
|
4607 | addendum = ' However, it is set to a ' + typeof contextType + '.';
|
4608 | } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
|
4609 | addendum = ' Did you accidentally pass the Context.Provider instead?';
|
4610 | } else if (contextType._context !== undefined) {
|
4611 |
|
4612 | addendum = ' Did you accidentally pass the Context.Consumer instead?';
|
4613 | } else {
|
4614 | addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
|
4615 | }
|
4616 |
|
4617 | warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
|
4618 | }
|
4619 | }
|
4620 | }
|
4621 |
|
4622 | if (typeof contextType === 'object' && contextType !== null) {
|
4623 | context = readContext(contextType);
|
4624 | } else if (!disableLegacyContext) {
|
4625 | unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4626 | var contextTypes = ctor.contextTypes;
|
4627 | isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
|
4628 | context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
|
4629 | }
|
4630 |
|
4631 |
|
4632 | {
|
4633 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
4634 | new ctor(props, context);
|
4635 | }
|
4636 | }
|
4637 |
|
4638 | var instance = new ctor(props, context);
|
4639 | var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
|
4640 | adoptClassInstance(workInProgress, instance);
|
4641 |
|
4642 | {
|
4643 | if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
|
4644 | var componentName = getComponentName(ctor) || 'Component';
|
4645 |
|
4646 | if (!didWarnAboutUninitializedState.has(componentName)) {
|
4647 | didWarnAboutUninitializedState.add(componentName);
|
4648 | warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
|
4649 | }
|
4650 | }
|
4651 |
|
4652 |
|
4653 |
|
4654 |
|
4655 | if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4656 | var foundWillMountName = null;
|
4657 | var foundWillReceivePropsName = null;
|
4658 | var foundWillUpdateName = null;
|
4659 |
|
4660 | if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
4661 | foundWillMountName = 'componentWillMount';
|
4662 | } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
4663 | foundWillMountName = 'UNSAFE_componentWillMount';
|
4664 | }
|
4665 |
|
4666 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
4667 | foundWillReceivePropsName = 'componentWillReceiveProps';
|
4668 | } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
4669 | foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
|
4670 | }
|
4671 |
|
4672 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
4673 | foundWillUpdateName = 'componentWillUpdate';
|
4674 | } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
4675 | foundWillUpdateName = 'UNSAFE_componentWillUpdate';
|
4676 | }
|
4677 |
|
4678 | if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
|
4679 | var _componentName = getComponentName(ctor) || 'Component';
|
4680 |
|
4681 | var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
|
4682 |
|
4683 | if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
|
4684 | didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
|
4685 | warningWithoutStack$1(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
|
4686 | }
|
4687 | }
|
4688 | }
|
4689 | }
|
4690 |
|
4691 |
|
4692 |
|
4693 | if (isLegacyContextConsumer) {
|
4694 | cacheContext(workInProgress, unmaskedContext, context);
|
4695 | }
|
4696 |
|
4697 | return instance;
|
4698 | }
|
4699 |
|
4700 | function callComponentWillMount(workInProgress, instance) {
|
4701 | startPhaseTimer(workInProgress, 'componentWillMount');
|
4702 | var oldState = instance.state;
|
4703 |
|
4704 | if (typeof instance.componentWillMount === 'function') {
|
4705 | instance.componentWillMount();
|
4706 | }
|
4707 |
|
4708 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
4709 | instance.UNSAFE_componentWillMount();
|
4710 | }
|
4711 |
|
4712 | stopPhaseTimer();
|
4713 |
|
4714 | if (oldState !== instance.state) {
|
4715 | {
|
4716 | warningWithoutStack$1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
|
4717 | }
|
4718 |
|
4719 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
4720 | }
|
4721 | }
|
4722 |
|
4723 | function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
|
4724 | var oldState = instance.state;
|
4725 | startPhaseTimer(workInProgress, 'componentWillReceiveProps');
|
4726 |
|
4727 | if (typeof instance.componentWillReceiveProps === 'function') {
|
4728 | instance.componentWillReceiveProps(newProps, nextContext);
|
4729 | }
|
4730 |
|
4731 | if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
4732 | instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
|
4733 | }
|
4734 |
|
4735 | stopPhaseTimer();
|
4736 |
|
4737 | if (instance.state !== oldState) {
|
4738 | {
|
4739 | var componentName = getComponentName(workInProgress.type) || 'Component';
|
4740 |
|
4741 | if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
|
4742 | didWarnAboutStateAssignmentForComponent.add(componentName);
|
4743 | warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
|
4744 | }
|
4745 | }
|
4746 |
|
4747 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
4748 | }
|
4749 | }
|
4750 |
|
4751 |
|
4752 | function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
|
4753 | {
|
4754 | checkClassInstance(workInProgress, ctor, newProps);
|
4755 | }
|
4756 |
|
4757 | var instance = workInProgress.stateNode;
|
4758 | instance.props = newProps;
|
4759 | instance.state = workInProgress.memoizedState;
|
4760 | instance.refs = emptyRefsObject;
|
4761 | var contextType = ctor.contextType;
|
4762 |
|
4763 | if (typeof contextType === 'object' && contextType !== null) {
|
4764 | instance.context = readContext(contextType);
|
4765 | } else if (disableLegacyContext) {
|
4766 | instance.context = emptyContextObject;
|
4767 | } else {
|
4768 | var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4769 | instance.context = getMaskedContext(workInProgress, unmaskedContext);
|
4770 | }
|
4771 |
|
4772 | {
|
4773 | if (instance.state === newProps) {
|
4774 | var componentName = getComponentName(ctor) || 'Component';
|
4775 |
|
4776 | if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
|
4777 | didWarnAboutDirectlyAssigningPropsToState.add(componentName);
|
4778 | warningWithoutStack$1(false, '%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
|
4779 | }
|
4780 | }
|
4781 |
|
4782 | if (workInProgress.mode & StrictMode) {
|
4783 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
|
4784 | }
|
4785 |
|
4786 | if (warnAboutDeprecatedLifecycles) {
|
4787 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
|
4788 | }
|
4789 | }
|
4790 |
|
4791 | var updateQueue = workInProgress.updateQueue;
|
4792 |
|
4793 | if (updateQueue !== null) {
|
4794 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4795 | instance.state = workInProgress.memoizedState;
|
4796 | }
|
4797 |
|
4798 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
4799 |
|
4800 | if (typeof getDerivedStateFromProps === 'function') {
|
4801 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
4802 | instance.state = workInProgress.memoizedState;
|
4803 | }
|
4804 |
|
4805 |
|
4806 |
|
4807 | if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
4808 | callComponentWillMount(workInProgress, instance);
|
4809 |
|
4810 |
|
4811 | updateQueue = workInProgress.updateQueue;
|
4812 |
|
4813 | if (updateQueue !== null) {
|
4814 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4815 | instance.state = workInProgress.memoizedState;
|
4816 | }
|
4817 | }
|
4818 |
|
4819 | if (typeof instance.componentDidMount === 'function') {
|
4820 | workInProgress.effectTag |= Update;
|
4821 | }
|
4822 | }
|
4823 |
|
4824 | function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
|
4825 | var instance = workInProgress.stateNode;
|
4826 | var oldProps = workInProgress.memoizedProps;
|
4827 | instance.props = oldProps;
|
4828 | var oldContext = instance.context;
|
4829 | var contextType = ctor.contextType;
|
4830 | var nextContext = emptyContextObject;
|
4831 |
|
4832 | if (typeof contextType === 'object' && contextType !== null) {
|
4833 | nextContext = readContext(contextType);
|
4834 | } else if (!disableLegacyContext) {
|
4835 | var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4836 | nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
|
4837 | }
|
4838 |
|
4839 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
4840 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
4841 |
|
4842 |
|
4843 |
|
4844 |
|
4845 |
|
4846 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
4847 | if (oldProps !== newProps || oldContext !== nextContext) {
|
4848 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
4849 | }
|
4850 | }
|
4851 |
|
4852 | resetHasForceUpdateBeforeProcessing();
|
4853 | var oldState = workInProgress.memoizedState;
|
4854 | var newState = instance.state = oldState;
|
4855 | var updateQueue = workInProgress.updateQueue;
|
4856 |
|
4857 | if (updateQueue !== null) {
|
4858 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4859 | newState = workInProgress.memoizedState;
|
4860 | }
|
4861 |
|
4862 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
4863 |
|
4864 |
|
4865 | if (typeof instance.componentDidMount === 'function') {
|
4866 | workInProgress.effectTag |= Update;
|
4867 | }
|
4868 |
|
4869 | return false;
|
4870 | }
|
4871 |
|
4872 | if (typeof getDerivedStateFromProps === 'function') {
|
4873 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
4874 | newState = workInProgress.memoizedState;
|
4875 | }
|
4876 |
|
4877 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
|
4878 |
|
4879 | if (shouldUpdate) {
|
4880 |
|
4881 |
|
4882 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
4883 | startPhaseTimer(workInProgress, 'componentWillMount');
|
4884 |
|
4885 | if (typeof instance.componentWillMount === 'function') {
|
4886 | instance.componentWillMount();
|
4887 | }
|
4888 |
|
4889 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
4890 | instance.UNSAFE_componentWillMount();
|
4891 | }
|
4892 |
|
4893 | stopPhaseTimer();
|
4894 | }
|
4895 |
|
4896 | if (typeof instance.componentDidMount === 'function') {
|
4897 | workInProgress.effectTag |= Update;
|
4898 | }
|
4899 | } else {
|
4900 |
|
4901 |
|
4902 | if (typeof instance.componentDidMount === 'function') {
|
4903 | workInProgress.effectTag |= Update;
|
4904 | }
|
4905 |
|
4906 |
|
4907 |
|
4908 | workInProgress.memoizedProps = newProps;
|
4909 | workInProgress.memoizedState = newState;
|
4910 | }
|
4911 |
|
4912 |
|
4913 |
|
4914 | instance.props = newProps;
|
4915 | instance.state = newState;
|
4916 | instance.context = nextContext;
|
4917 | return shouldUpdate;
|
4918 | }
|
4919 |
|
4920 |
|
4921 | function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
|
4922 | var instance = workInProgress.stateNode;
|
4923 | var oldProps = workInProgress.memoizedProps;
|
4924 | instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
|
4925 | var oldContext = instance.context;
|
4926 | var contextType = ctor.contextType;
|
4927 | var nextContext = emptyContextObject;
|
4928 |
|
4929 | if (typeof contextType === 'object' && contextType !== null) {
|
4930 | nextContext = readContext(contextType);
|
4931 | } else if (!disableLegacyContext) {
|
4932 | var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4933 | nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
|
4934 | }
|
4935 |
|
4936 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
4937 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
4938 |
|
4939 |
|
4940 |
|
4941 |
|
4942 |
|
4943 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
4944 | if (oldProps !== newProps || oldContext !== nextContext) {
|
4945 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
4946 | }
|
4947 | }
|
4948 |
|
4949 | resetHasForceUpdateBeforeProcessing();
|
4950 | var oldState = workInProgress.memoizedState;
|
4951 | var newState = instance.state = oldState;
|
4952 | var updateQueue = workInProgress.updateQueue;
|
4953 |
|
4954 | if (updateQueue !== null) {
|
4955 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4956 | newState = workInProgress.memoizedState;
|
4957 | }
|
4958 |
|
4959 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
4960 |
|
4961 |
|
4962 | if (typeof instance.componentDidUpdate === 'function') {
|
4963 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4964 | workInProgress.effectTag |= Update;
|
4965 | }
|
4966 | }
|
4967 |
|
4968 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4969 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4970 | workInProgress.effectTag |= Snapshot;
|
4971 | }
|
4972 | }
|
4973 |
|
4974 | return false;
|
4975 | }
|
4976 |
|
4977 | if (typeof getDerivedStateFromProps === 'function') {
|
4978 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
4979 | newState = workInProgress.memoizedState;
|
4980 | }
|
4981 |
|
4982 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
|
4983 |
|
4984 | if (shouldUpdate) {
|
4985 |
|
4986 |
|
4987 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
|
4988 | startPhaseTimer(workInProgress, 'componentWillUpdate');
|
4989 |
|
4990 | if (typeof instance.componentWillUpdate === 'function') {
|
4991 | instance.componentWillUpdate(newProps, newState, nextContext);
|
4992 | }
|
4993 |
|
4994 | if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
4995 | instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
|
4996 | }
|
4997 |
|
4998 | stopPhaseTimer();
|
4999 | }
|
5000 |
|
5001 | if (typeof instance.componentDidUpdate === 'function') {
|
5002 | workInProgress.effectTag |= Update;
|
5003 | }
|
5004 |
|
5005 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
5006 | workInProgress.effectTag |= Snapshot;
|
5007 | }
|
5008 | } else {
|
5009 |
|
5010 |
|
5011 | if (typeof instance.componentDidUpdate === 'function') {
|
5012 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
5013 | workInProgress.effectTag |= Update;
|
5014 | }
|
5015 | }
|
5016 |
|
5017 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
5018 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
5019 | workInProgress.effectTag |= Snapshot;
|
5020 | }
|
5021 | }
|
5022 |
|
5023 |
|
5024 |
|
5025 | workInProgress.memoizedProps = newProps;
|
5026 | workInProgress.memoizedState = newState;
|
5027 | }
|
5028 |
|
5029 |
|
5030 |
|
5031 | instance.props = newProps;
|
5032 | instance.state = newState;
|
5033 | instance.context = nextContext;
|
5034 | return shouldUpdate;
|
5035 | }
|
5036 |
|
5037 | var didWarnAboutMaps;
|
5038 | var didWarnAboutGenerators;
|
5039 | var didWarnAboutStringRefs;
|
5040 | var ownerHasKeyUseWarning;
|
5041 | var ownerHasFunctionTypeWarning;
|
5042 |
|
5043 | var warnForMissingKey = function (child) {};
|
5044 |
|
5045 | {
|
5046 | didWarnAboutMaps = false;
|
5047 | didWarnAboutGenerators = false;
|
5048 | didWarnAboutStringRefs = {};
|
5049 | |
5050 |
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 | ownerHasKeyUseWarning = {};
|
5056 | ownerHasFunctionTypeWarning = {};
|
5057 |
|
5058 | warnForMissingKey = function (child) {
|
5059 | if (child === null || typeof child !== 'object') {
|
5060 | return;
|
5061 | }
|
5062 |
|
5063 | if (!child._store || child._store.validated || child.key != null) {
|
5064 | return;
|
5065 | }
|
5066 |
|
5067 | if (!(typeof child._store === 'object')) {
|
5068 | {
|
5069 | throw Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.");
|
5070 | }
|
5071 | }
|
5072 |
|
5073 | child._store.validated = true;
|
5074 | var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
|
5075 |
|
5076 | if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
5077 | return;
|
5078 | }
|
5079 |
|
5080 | ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
5081 | warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
|
5082 | };
|
5083 | }
|
5084 |
|
5085 | var isArray = Array.isArray;
|
5086 |
|
5087 | function coerceRef(returnFiber, current, element) {
|
5088 | var mixedRef = element.ref;
|
5089 |
|
5090 | if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
|
5091 | {
|
5092 |
|
5093 |
|
5094 | if (returnFiber.mode & StrictMode || warnAboutStringRefs) {
|
5095 | var componentName = getComponentName(returnFiber.type) || 'Component';
|
5096 |
|
5097 | if (!didWarnAboutStringRefs[componentName]) {
|
5098 | if (warnAboutStringRefs) {
|
5099 | warningWithoutStack$1(false, 'Component "%s" contains the string ref "%s". Support for string refs ' + 'will be removed in a future major release. We recommend using ' + 'useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', componentName, mixedRef, getStackByFiberInDevAndProd(returnFiber));
|
5100 | } else {
|
5101 | warningWithoutStack$1(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber));
|
5102 | }
|
5103 |
|
5104 | didWarnAboutStringRefs[componentName] = true;
|
5105 | }
|
5106 | }
|
5107 | }
|
5108 |
|
5109 | if (element._owner) {
|
5110 | var owner = element._owner;
|
5111 | var inst;
|
5112 |
|
5113 | if (owner) {
|
5114 | var ownerFiber = owner;
|
5115 |
|
5116 | if (!(ownerFiber.tag === ClassComponent)) {
|
5117 | {
|
5118 | throw Error("Function components cannot have refs. Did you mean to use React.forwardRef()?");
|
5119 | }
|
5120 | }
|
5121 |
|
5122 | inst = ownerFiber.stateNode;
|
5123 | }
|
5124 |
|
5125 | if (!inst) {
|
5126 | {
|
5127 | throw Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue.");
|
5128 | }
|
5129 | }
|
5130 |
|
5131 | var stringRef = '' + mixedRef;
|
5132 |
|
5133 | if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) {
|
5134 | return current.ref;
|
5135 | }
|
5136 |
|
5137 | var ref = function (value) {
|
5138 | var refs = inst.refs;
|
5139 |
|
5140 | if (refs === emptyRefsObject) {
|
5141 |
|
5142 | refs = inst.refs = {};
|
5143 | }
|
5144 |
|
5145 | if (value === null) {
|
5146 | delete refs[stringRef];
|
5147 | } else {
|
5148 | refs[stringRef] = value;
|
5149 | }
|
5150 | };
|
5151 |
|
5152 | ref._stringRef = stringRef;
|
5153 | return ref;
|
5154 | } else {
|
5155 | if (!(typeof mixedRef === 'string')) {
|
5156 | {
|
5157 | throw Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");
|
5158 | }
|
5159 | }
|
5160 |
|
5161 | if (!element._owner) {
|
5162 | {
|
5163 | throw Error("Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.");
|
5164 | }
|
5165 | }
|
5166 | }
|
5167 | }
|
5168 |
|
5169 | return mixedRef;
|
5170 | }
|
5171 |
|
5172 | function throwOnInvalidObjectType(returnFiber, newChild) {
|
5173 | if (returnFiber.type !== 'textarea') {
|
5174 | var addendum = '';
|
5175 |
|
5176 | {
|
5177 | addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
|
5178 | }
|
5179 |
|
5180 | {
|
5181 | {
|
5182 | throw Error("Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum);
|
5183 | }
|
5184 | }
|
5185 | }
|
5186 | }
|
5187 |
|
5188 | function warnOnFunctionType() {
|
5189 | var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev();
|
5190 |
|
5191 | if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
|
5192 | return;
|
5193 | }
|
5194 |
|
5195 | ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
|
5196 | warning$1(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
|
5197 | }
|
5198 |
|
5199 |
|
5200 |
|
5201 |
|
5202 |
|
5203 | function ChildReconciler(shouldTrackSideEffects) {
|
5204 | function deleteChild(returnFiber, childToDelete) {
|
5205 | if (!shouldTrackSideEffects) {
|
5206 |
|
5207 | return;
|
5208 | }
|
5209 |
|
5210 |
|
5211 |
|
5212 |
|
5213 |
|
5214 |
|
5215 | var last = returnFiber.lastEffect;
|
5216 |
|
5217 | if (last !== null) {
|
5218 | last.nextEffect = childToDelete;
|
5219 | returnFiber.lastEffect = childToDelete;
|
5220 | } else {
|
5221 | returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
5222 | }
|
5223 |
|
5224 | childToDelete.nextEffect = null;
|
5225 | childToDelete.effectTag = Deletion;
|
5226 | }
|
5227 |
|
5228 | function deleteRemainingChildren(returnFiber, currentFirstChild) {
|
5229 | if (!shouldTrackSideEffects) {
|
5230 |
|
5231 | return null;
|
5232 | }
|
5233 |
|
5234 |
|
5235 |
|
5236 | var childToDelete = currentFirstChild;
|
5237 |
|
5238 | while (childToDelete !== null) {
|
5239 | deleteChild(returnFiber, childToDelete);
|
5240 | childToDelete = childToDelete.sibling;
|
5241 | }
|
5242 |
|
5243 | return null;
|
5244 | }
|
5245 |
|
5246 | function mapRemainingChildren(returnFiber, currentFirstChild) {
|
5247 |
|
5248 |
|
5249 |
|
5250 | var existingChildren = new Map();
|
5251 | var existingChild = currentFirstChild;
|
5252 |
|
5253 | while (existingChild !== null) {
|
5254 | if (existingChild.key !== null) {
|
5255 | existingChildren.set(existingChild.key, existingChild);
|
5256 | } else {
|
5257 | existingChildren.set(existingChild.index, existingChild);
|
5258 | }
|
5259 |
|
5260 | existingChild = existingChild.sibling;
|
5261 | }
|
5262 |
|
5263 | return existingChildren;
|
5264 | }
|
5265 |
|
5266 | function useFiber(fiber, pendingProps, expirationTime) {
|
5267 |
|
5268 |
|
5269 | var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
|
5270 | clone.index = 0;
|
5271 | clone.sibling = null;
|
5272 | return clone;
|
5273 | }
|
5274 |
|
5275 | function placeChild(newFiber, lastPlacedIndex, newIndex) {
|
5276 | newFiber.index = newIndex;
|
5277 |
|
5278 | if (!shouldTrackSideEffects) {
|
5279 |
|
5280 | return lastPlacedIndex;
|
5281 | }
|
5282 |
|
5283 | var current = newFiber.alternate;
|
5284 |
|
5285 | if (current !== null) {
|
5286 | var oldIndex = current.index;
|
5287 |
|
5288 | if (oldIndex < lastPlacedIndex) {
|
5289 |
|
5290 | newFiber.effectTag = Placement;
|
5291 | return lastPlacedIndex;
|
5292 | } else {
|
5293 |
|
5294 | return oldIndex;
|
5295 | }
|
5296 | } else {
|
5297 |
|
5298 | newFiber.effectTag = Placement;
|
5299 | return lastPlacedIndex;
|
5300 | }
|
5301 | }
|
5302 |
|
5303 | function placeSingleChild(newFiber) {
|
5304 |
|
5305 |
|
5306 | if (shouldTrackSideEffects && newFiber.alternate === null) {
|
5307 | newFiber.effectTag = Placement;
|
5308 | }
|
5309 |
|
5310 | return newFiber;
|
5311 | }
|
5312 |
|
5313 | function updateTextNode(returnFiber, current, textContent, expirationTime) {
|
5314 | if (current === null || current.tag !== HostText) {
|
5315 |
|
5316 | var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
|
5317 | created.return = returnFiber;
|
5318 | return created;
|
5319 | } else {
|
5320 |
|
5321 | var existing = useFiber(current, textContent, expirationTime);
|
5322 | existing.return = returnFiber;
|
5323 | return existing;
|
5324 | }
|
5325 | }
|
5326 |
|
5327 | function updateElement(returnFiber, current, element, expirationTime) {
|
5328 | if (current !== null && (current.elementType === element.type || (
|
5329 | isCompatibleFamilyForHotReloading(current, element)))) {
|
5330 |
|
5331 | var existing = useFiber(current, element.props, expirationTime);
|
5332 | existing.ref = coerceRef(returnFiber, current, element);
|
5333 | existing.return = returnFiber;
|
5334 |
|
5335 | {
|
5336 | existing._debugSource = element._source;
|
5337 | existing._debugOwner = element._owner;
|
5338 | }
|
5339 |
|
5340 | return existing;
|
5341 | } else {
|
5342 |
|
5343 | var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
|
5344 | created.ref = coerceRef(returnFiber, current, element);
|
5345 | created.return = returnFiber;
|
5346 | return created;
|
5347 | }
|
5348 | }
|
5349 |
|
5350 | function updatePortal(returnFiber, current, portal, expirationTime) {
|
5351 | if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {
|
5352 |
|
5353 | var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
|
5354 | created.return = returnFiber;
|
5355 | return created;
|
5356 | } else {
|
5357 |
|
5358 | var existing = useFiber(current, portal.children || [], expirationTime);
|
5359 | existing.return = returnFiber;
|
5360 | return existing;
|
5361 | }
|
5362 | }
|
5363 |
|
5364 | function updateFragment(returnFiber, current, fragment, expirationTime, key) {
|
5365 | if (current === null || current.tag !== Fragment) {
|
5366 |
|
5367 | var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
|
5368 | created.return = returnFiber;
|
5369 | return created;
|
5370 | } else {
|
5371 |
|
5372 | var existing = useFiber(current, fragment, expirationTime);
|
5373 | existing.return = returnFiber;
|
5374 | return existing;
|
5375 | }
|
5376 | }
|
5377 |
|
5378 | function createChild(returnFiber, newChild, expirationTime) {
|
5379 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
5380 |
|
5381 |
|
5382 |
|
5383 | var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
|
5384 | created.return = returnFiber;
|
5385 | return created;
|
5386 | }
|
5387 |
|
5388 | if (typeof newChild === 'object' && newChild !== null) {
|
5389 | switch (newChild.$$typeof) {
|
5390 | case REACT_ELEMENT_TYPE$1:
|
5391 | {
|
5392 | var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
|
5393 |
|
5394 | _created.ref = coerceRef(returnFiber, null, newChild);
|
5395 | _created.return = returnFiber;
|
5396 | return _created;
|
5397 | }
|
5398 |
|
5399 | case REACT_PORTAL_TYPE:
|
5400 | {
|
5401 | var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
|
5402 |
|
5403 | _created2.return = returnFiber;
|
5404 | return _created2;
|
5405 | }
|
5406 | }
|
5407 |
|
5408 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
5409 | var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
|
5410 |
|
5411 | _created3.return = returnFiber;
|
5412 | return _created3;
|
5413 | }
|
5414 |
|
5415 | throwOnInvalidObjectType(returnFiber, newChild);
|
5416 | }
|
5417 |
|
5418 | {
|
5419 | if (typeof newChild === 'function') {
|
5420 | warnOnFunctionType();
|
5421 | }
|
5422 | }
|
5423 |
|
5424 | return null;
|
5425 | }
|
5426 |
|
5427 | function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
|
5428 |
|
5429 | var key = oldFiber !== null ? oldFiber.key : null;
|
5430 |
|
5431 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
5432 |
|
5433 |
|
5434 |
|
5435 | if (key !== null) {
|
5436 | return null;
|
5437 | }
|
5438 |
|
5439 | return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
|
5440 | }
|
5441 |
|
5442 | if (typeof newChild === 'object' && newChild !== null) {
|
5443 | switch (newChild.$$typeof) {
|
5444 | case REACT_ELEMENT_TYPE$1:
|
5445 | {
|
5446 | if (newChild.key === key) {
|
5447 | if (newChild.type === REACT_FRAGMENT_TYPE) {
|
5448 | return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
|
5449 | }
|
5450 |
|
5451 | return updateElement(returnFiber, oldFiber, newChild, expirationTime);
|
5452 | } else {
|
5453 | return null;
|
5454 | }
|
5455 | }
|
5456 |
|
5457 | case REACT_PORTAL_TYPE:
|
5458 | {
|
5459 | if (newChild.key === key) {
|
5460 | return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
|
5461 | } else {
|
5462 | return null;
|
5463 | }
|
5464 | }
|
5465 | }
|
5466 |
|
5467 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
5468 | if (key !== null) {
|
5469 | return null;
|
5470 | }
|
5471 |
|
5472 | return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
|
5473 | }
|
5474 |
|
5475 | throwOnInvalidObjectType(returnFiber, newChild);
|
5476 | }
|
5477 |
|
5478 | {
|
5479 | if (typeof newChild === 'function') {
|
5480 | warnOnFunctionType();
|
5481 | }
|
5482 | }
|
5483 |
|
5484 | return null;
|
5485 | }
|
5486 |
|
5487 | function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
|
5488 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
5489 |
|
5490 |
|
5491 | var matchedFiber = existingChildren.get(newIdx) || null;
|
5492 | return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
|
5493 | }
|
5494 |
|
5495 | if (typeof newChild === 'object' && newChild !== null) {
|
5496 | switch (newChild.$$typeof) {
|
5497 | case REACT_ELEMENT_TYPE$1:
|
5498 | {
|
5499 | var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
5500 |
|
5501 | if (newChild.type === REACT_FRAGMENT_TYPE) {
|
5502 | return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
|
5503 | }
|
5504 |
|
5505 | return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
|
5506 | }
|
5507 |
|
5508 | case REACT_PORTAL_TYPE:
|
5509 | {
|
5510 | var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
5511 |
|
5512 | return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
|
5513 | }
|
5514 | }
|
5515 |
|
5516 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
5517 | var _matchedFiber3 = existingChildren.get(newIdx) || null;
|
5518 |
|
5519 | return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
|
5520 | }
|
5521 |
|
5522 | throwOnInvalidObjectType(returnFiber, newChild);
|
5523 | }
|
5524 |
|
5525 | {
|
5526 | if (typeof newChild === 'function') {
|
5527 | warnOnFunctionType();
|
5528 | }
|
5529 | }
|
5530 |
|
5531 | return null;
|
5532 | }
|
5533 | |
5534 |
|
5535 |
|
5536 |
|
5537 |
|
5538 | function warnOnInvalidKey(child, knownKeys) {
|
5539 | {
|
5540 | if (typeof child !== 'object' || child === null) {
|
5541 | return knownKeys;
|
5542 | }
|
5543 |
|
5544 | switch (child.$$typeof) {
|
5545 | case REACT_ELEMENT_TYPE$1:
|
5546 | case REACT_PORTAL_TYPE:
|
5547 | warnForMissingKey(child);
|
5548 | var key = child.key;
|
5549 |
|
5550 | if (typeof key !== 'string') {
|
5551 | break;
|
5552 | }
|
5553 |
|
5554 | if (knownKeys === null) {
|
5555 | knownKeys = new Set();
|
5556 | knownKeys.add(key);
|
5557 | break;
|
5558 | }
|
5559 |
|
5560 | if (!knownKeys.has(key)) {
|
5561 | knownKeys.add(key);
|
5562 | break;
|
5563 | }
|
5564 |
|
5565 | warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);
|
5566 | break;
|
5567 |
|
5568 | default:
|
5569 | break;
|
5570 | }
|
5571 | }
|
5572 |
|
5573 | return knownKeys;
|
5574 | }
|
5575 |
|
5576 | function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
|
5577 |
|
5578 |
|
5579 |
|
5580 |
|
5581 |
|
5582 |
|
5583 |
|
5584 |
|
5585 |
|
5586 |
|
5587 |
|
5588 |
|
5589 |
|
5590 |
|
5591 |
|
5592 | {
|
5593 |
|
5594 | var knownKeys = null;
|
5595 |
|
5596 | for (var i = 0; i < newChildren.length; i++) {
|
5597 | var child = newChildren[i];
|
5598 | knownKeys = warnOnInvalidKey(child, knownKeys);
|
5599 | }
|
5600 | }
|
5601 |
|
5602 | var resultingFirstChild = null;
|
5603 | var previousNewFiber = null;
|
5604 | var oldFiber = currentFirstChild;
|
5605 | var lastPlacedIndex = 0;
|
5606 | var newIdx = 0;
|
5607 | var nextOldFiber = null;
|
5608 |
|
5609 | for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
|
5610 | if (oldFiber.index > newIdx) {
|
5611 | nextOldFiber = oldFiber;
|
5612 | oldFiber = null;
|
5613 | } else {
|
5614 | nextOldFiber = oldFiber.sibling;
|
5615 | }
|
5616 |
|
5617 | var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
|
5618 |
|
5619 | if (newFiber === null) {
|
5620 |
|
5621 |
|
5622 |
|
5623 |
|
5624 | if (oldFiber === null) {
|
5625 | oldFiber = nextOldFiber;
|
5626 | }
|
5627 |
|
5628 | break;
|
5629 | }
|
5630 |
|
5631 | if (shouldTrackSideEffects) {
|
5632 | if (oldFiber && newFiber.alternate === null) {
|
5633 |
|
5634 |
|
5635 | deleteChild(returnFiber, oldFiber);
|
5636 | }
|
5637 | }
|
5638 |
|
5639 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
5640 |
|
5641 | if (previousNewFiber === null) {
|
5642 |
|
5643 | resultingFirstChild = newFiber;
|
5644 | } else {
|
5645 |
|
5646 |
|
5647 |
|
5648 |
|
5649 | previousNewFiber.sibling = newFiber;
|
5650 | }
|
5651 |
|
5652 | previousNewFiber = newFiber;
|
5653 | oldFiber = nextOldFiber;
|
5654 | }
|
5655 |
|
5656 | if (newIdx === newChildren.length) {
|
5657 |
|
5658 | deleteRemainingChildren(returnFiber, oldFiber);
|
5659 | return resultingFirstChild;
|
5660 | }
|
5661 |
|
5662 | if (oldFiber === null) {
|
5663 |
|
5664 |
|
5665 | for (; newIdx < newChildren.length; newIdx++) {
|
5666 | var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
|
5667 |
|
5668 | if (_newFiber === null) {
|
5669 | continue;
|
5670 | }
|
5671 |
|
5672 | lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
|
5673 |
|
5674 | if (previousNewFiber === null) {
|
5675 |
|
5676 | resultingFirstChild = _newFiber;
|
5677 | } else {
|
5678 | previousNewFiber.sibling = _newFiber;
|
5679 | }
|
5680 |
|
5681 | previousNewFiber = _newFiber;
|
5682 | }
|
5683 |
|
5684 | return resultingFirstChild;
|
5685 | }
|
5686 |
|
5687 |
|
5688 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
5689 |
|
5690 | for (; newIdx < newChildren.length; newIdx++) {
|
5691 | var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
|
5692 |
|
5693 | if (_newFiber2 !== null) {
|
5694 | if (shouldTrackSideEffects) {
|
5695 | if (_newFiber2.alternate !== null) {
|
5696 |
|
5697 |
|
5698 |
|
5699 |
|
5700 | existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
|
5701 | }
|
5702 | }
|
5703 |
|
5704 | lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
|
5705 |
|
5706 | if (previousNewFiber === null) {
|
5707 | resultingFirstChild = _newFiber2;
|
5708 | } else {
|
5709 | previousNewFiber.sibling = _newFiber2;
|
5710 | }
|
5711 |
|
5712 | previousNewFiber = _newFiber2;
|
5713 | }
|
5714 | }
|
5715 |
|
5716 | if (shouldTrackSideEffects) {
|
5717 |
|
5718 |
|
5719 | existingChildren.forEach(function (child) {
|
5720 | return deleteChild(returnFiber, child);
|
5721 | });
|
5722 | }
|
5723 |
|
5724 | return resultingFirstChild;
|
5725 | }
|
5726 |
|
5727 | function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
|
5728 |
|
5729 |
|
5730 | var iteratorFn = getIteratorFn(newChildrenIterable);
|
5731 |
|
5732 | if (!(typeof iteratorFn === 'function')) {
|
5733 | {
|
5734 | throw Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");
|
5735 | }
|
5736 | }
|
5737 |
|
5738 | {
|
5739 |
|
5740 |
|
5741 | if (typeof Symbol === 'function' &&
|
5742 | newChildrenIterable[Symbol.toStringTag] === 'Generator') {
|
5743 | !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;
|
5744 | didWarnAboutGenerators = true;
|
5745 | }
|
5746 |
|
5747 |
|
5748 | if (newChildrenIterable.entries === iteratorFn) {
|
5749 | !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;
|
5750 | didWarnAboutMaps = true;
|
5751 | }
|
5752 |
|
5753 |
|
5754 |
|
5755 | var _newChildren = iteratorFn.call(newChildrenIterable);
|
5756 |
|
5757 | if (_newChildren) {
|
5758 | var knownKeys = null;
|
5759 |
|
5760 | var _step = _newChildren.next();
|
5761 |
|
5762 | for (; !_step.done; _step = _newChildren.next()) {
|
5763 | var child = _step.value;
|
5764 | knownKeys = warnOnInvalidKey(child, knownKeys);
|
5765 | }
|
5766 | }
|
5767 | }
|
5768 |
|
5769 | var newChildren = iteratorFn.call(newChildrenIterable);
|
5770 |
|
5771 | if (!(newChildren != null)) {
|
5772 | {
|
5773 | throw Error("An iterable object provided no iterator.");
|
5774 | }
|
5775 | }
|
5776 |
|
5777 | var resultingFirstChild = null;
|
5778 | var previousNewFiber = null;
|
5779 | var oldFiber = currentFirstChild;
|
5780 | var lastPlacedIndex = 0;
|
5781 | var newIdx = 0;
|
5782 | var nextOldFiber = null;
|
5783 | var step = newChildren.next();
|
5784 |
|
5785 | for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
|
5786 | if (oldFiber.index > newIdx) {
|
5787 | nextOldFiber = oldFiber;
|
5788 | oldFiber = null;
|
5789 | } else {
|
5790 | nextOldFiber = oldFiber.sibling;
|
5791 | }
|
5792 |
|
5793 | var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
|
5794 |
|
5795 | if (newFiber === null) {
|
5796 |
|
5797 |
|
5798 |
|
5799 |
|
5800 | if (oldFiber === null) {
|
5801 | oldFiber = nextOldFiber;
|
5802 | }
|
5803 |
|
5804 | break;
|
5805 | }
|
5806 |
|
5807 | if (shouldTrackSideEffects) {
|
5808 | if (oldFiber && newFiber.alternate === null) {
|
5809 |
|
5810 |
|
5811 | deleteChild(returnFiber, oldFiber);
|
5812 | }
|
5813 | }
|
5814 |
|
5815 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
5816 |
|
5817 | if (previousNewFiber === null) {
|
5818 |
|
5819 | resultingFirstChild = newFiber;
|
5820 | } else {
|
5821 |
|
5822 |
|
5823 |
|
5824 |
|
5825 | previousNewFiber.sibling = newFiber;
|
5826 | }
|
5827 |
|
5828 | previousNewFiber = newFiber;
|
5829 | oldFiber = nextOldFiber;
|
5830 | }
|
5831 |
|
5832 | if (step.done) {
|
5833 |
|
5834 | deleteRemainingChildren(returnFiber, oldFiber);
|
5835 | return resultingFirstChild;
|
5836 | }
|
5837 |
|
5838 | if (oldFiber === null) {
|
5839 |
|
5840 |
|
5841 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
5842 | var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
|
5843 |
|
5844 | if (_newFiber3 === null) {
|
5845 | continue;
|
5846 | }
|
5847 |
|
5848 | lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
|
5849 |
|
5850 | if (previousNewFiber === null) {
|
5851 |
|
5852 | resultingFirstChild = _newFiber3;
|
5853 | } else {
|
5854 | previousNewFiber.sibling = _newFiber3;
|
5855 | }
|
5856 |
|
5857 | previousNewFiber = _newFiber3;
|
5858 | }
|
5859 |
|
5860 | return resultingFirstChild;
|
5861 | }
|
5862 |
|
5863 |
|
5864 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
5865 |
|
5866 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
5867 | var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
|
5868 |
|
5869 | if (_newFiber4 !== null) {
|
5870 | if (shouldTrackSideEffects) {
|
5871 | if (_newFiber4.alternate !== null) {
|
5872 |
|
5873 |
|
5874 |
|
5875 |
|
5876 | existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
|
5877 | }
|
5878 | }
|
5879 |
|
5880 | lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
|
5881 |
|
5882 | if (previousNewFiber === null) {
|
5883 | resultingFirstChild = _newFiber4;
|
5884 | } else {
|
5885 | previousNewFiber.sibling = _newFiber4;
|
5886 | }
|
5887 |
|
5888 | previousNewFiber = _newFiber4;
|
5889 | }
|
5890 | }
|
5891 |
|
5892 | if (shouldTrackSideEffects) {
|
5893 |
|
5894 |
|
5895 | existingChildren.forEach(function (child) {
|
5896 | return deleteChild(returnFiber, child);
|
5897 | });
|
5898 | }
|
5899 |
|
5900 | return resultingFirstChild;
|
5901 | }
|
5902 |
|
5903 | function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
|
5904 |
|
5905 |
|
5906 | if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
|
5907 |
|
5908 |
|
5909 | deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
|
5910 | var existing = useFiber(currentFirstChild, textContent, expirationTime);
|
5911 | existing.return = returnFiber;
|
5912 | return existing;
|
5913 | }
|
5914 |
|
5915 |
|
5916 |
|
5917 | deleteRemainingChildren(returnFiber, currentFirstChild);
|
5918 | var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
|
5919 | created.return = returnFiber;
|
5920 | return created;
|
5921 | }
|
5922 |
|
5923 | function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
|
5924 | var key = element.key;
|
5925 | var child = currentFirstChild;
|
5926 |
|
5927 | while (child !== null) {
|
5928 |
|
5929 |
|
5930 | if (child.key === key) {
|
5931 | if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || (
|
5932 | isCompatibleFamilyForHotReloading(child, element))) {
|
5933 | deleteRemainingChildren(returnFiber, child.sibling);
|
5934 | var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
|
5935 | existing.ref = coerceRef(returnFiber, child, element);
|
5936 | existing.return = returnFiber;
|
5937 |
|
5938 | {
|
5939 | existing._debugSource = element._source;
|
5940 | existing._debugOwner = element._owner;
|
5941 | }
|
5942 |
|
5943 | return existing;
|
5944 | } else {
|
5945 | deleteRemainingChildren(returnFiber, child);
|
5946 | break;
|
5947 | }
|
5948 | } else {
|
5949 | deleteChild(returnFiber, child);
|
5950 | }
|
5951 |
|
5952 | child = child.sibling;
|
5953 | }
|
5954 |
|
5955 | if (element.type === REACT_FRAGMENT_TYPE) {
|
5956 | var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
|
5957 | created.return = returnFiber;
|
5958 | return created;
|
5959 | } else {
|
5960 | var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
|
5961 |
|
5962 | _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
|
5963 | _created4.return = returnFiber;
|
5964 | return _created4;
|
5965 | }
|
5966 | }
|
5967 |
|
5968 | function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
|
5969 | var key = portal.key;
|
5970 | var child = currentFirstChild;
|
5971 |
|
5972 | while (child !== null) {
|
5973 |
|
5974 |
|
5975 | if (child.key === key) {
|
5976 | if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
|
5977 | deleteRemainingChildren(returnFiber, child.sibling);
|
5978 | var existing = useFiber(child, portal.children || [], expirationTime);
|
5979 | existing.return = returnFiber;
|
5980 | return existing;
|
5981 | } else {
|
5982 | deleteRemainingChildren(returnFiber, child);
|
5983 | break;
|
5984 | }
|
5985 | } else {
|
5986 | deleteChild(returnFiber, child);
|
5987 | }
|
5988 |
|
5989 | child = child.sibling;
|
5990 | }
|
5991 |
|
5992 | var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
|
5993 | created.return = returnFiber;
|
5994 | return created;
|
5995 | }
|
5996 |
|
5997 |
|
5998 |
|
5999 |
|
6000 | function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
|
6001 |
|
6002 |
|
6003 |
|
6004 |
|
6005 |
|
6006 |
|
6007 |
|
6008 | var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
6009 |
|
6010 | if (isUnkeyedTopLevelFragment) {
|
6011 | newChild = newChild.props.children;
|
6012 | }
|
6013 |
|
6014 |
|
6015 | var isObject = typeof newChild === 'object' && newChild !== null;
|
6016 |
|
6017 | if (isObject) {
|
6018 | switch (newChild.$$typeof) {
|
6019 | case REACT_ELEMENT_TYPE$1:
|
6020 | return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
|
6021 |
|
6022 | case REACT_PORTAL_TYPE:
|
6023 | return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
|
6024 | }
|
6025 | }
|
6026 |
|
6027 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
6028 | return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
|
6029 | }
|
6030 |
|
6031 | if (isArray(newChild)) {
|
6032 | return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
|
6033 | }
|
6034 |
|
6035 | if (getIteratorFn(newChild)) {
|
6036 | return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
|
6037 | }
|
6038 |
|
6039 | if (isObject) {
|
6040 | throwOnInvalidObjectType(returnFiber, newChild);
|
6041 | }
|
6042 |
|
6043 | {
|
6044 | if (typeof newChild === 'function') {
|
6045 | warnOnFunctionType();
|
6046 | }
|
6047 | }
|
6048 |
|
6049 | if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
|
6050 |
|
6051 |
|
6052 |
|
6053 | switch (returnFiber.tag) {
|
6054 | case ClassComponent:
|
6055 | {
|
6056 | {
|
6057 | var instance = returnFiber.stateNode;
|
6058 |
|
6059 | if (instance.render._isMockFunction) {
|
6060 |
|
6061 | break;
|
6062 | }
|
6063 | }
|
6064 | }
|
6065 |
|
6066 |
|
6067 |
|
6068 |
|
6069 | case FunctionComponent:
|
6070 | {
|
6071 | var Component = returnFiber.type;
|
6072 |
|
6073 | {
|
6074 | {
|
6075 | throw Error((Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.");
|
6076 | }
|
6077 | }
|
6078 | }
|
6079 | }
|
6080 | }
|
6081 |
|
6082 |
|
6083 | return deleteRemainingChildren(returnFiber, currentFirstChild);
|
6084 | }
|
6085 |
|
6086 | return reconcileChildFibers;
|
6087 | }
|
6088 |
|
6089 | var reconcileChildFibers = ChildReconciler(true);
|
6090 | var mountChildFibers = ChildReconciler(false);
|
6091 | function cloneChildFibers(current, workInProgress) {
|
6092 | if (!(current === null || workInProgress.child === current.child)) {
|
6093 | {
|
6094 | throw Error("Resuming work not yet implemented.");
|
6095 | }
|
6096 | }
|
6097 |
|
6098 | if (workInProgress.child === null) {
|
6099 | return;
|
6100 | }
|
6101 |
|
6102 | var currentChild = workInProgress.child;
|
6103 | var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
|
6104 | workInProgress.child = newChild;
|
6105 | newChild.return = workInProgress;
|
6106 |
|
6107 | while (currentChild.sibling !== null) {
|
6108 | currentChild = currentChild.sibling;
|
6109 | newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
|
6110 | newChild.return = workInProgress;
|
6111 | }
|
6112 |
|
6113 | newChild.sibling = null;
|
6114 | }
|
6115 |
|
6116 | function resetChildFibers(workInProgress, renderExpirationTime) {
|
6117 | var child = workInProgress.child;
|
6118 |
|
6119 | while (child !== null) {
|
6120 | resetWorkInProgress(child, renderExpirationTime);
|
6121 | child = child.sibling;
|
6122 | }
|
6123 | }
|
6124 |
|
6125 | var NO_CONTEXT$1 = {};
|
6126 | var contextStackCursor$1 = createCursor(NO_CONTEXT$1);
|
6127 | var contextFiberStackCursor = createCursor(NO_CONTEXT$1);
|
6128 | var rootInstanceStackCursor = createCursor(NO_CONTEXT$1);
|
6129 |
|
6130 | function requiredContext(c) {
|
6131 | if (!(c !== NO_CONTEXT$1)) {
|
6132 | {
|
6133 | throw Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");
|
6134 | }
|
6135 | }
|
6136 |
|
6137 | return c;
|
6138 | }
|
6139 |
|
6140 | function getRootHostContainer() {
|
6141 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
6142 | return rootInstance;
|
6143 | }
|
6144 |
|
6145 | function pushHostContainer(fiber, nextRootInstance) {
|
6146 |
|
6147 |
|
6148 | push(rootInstanceStackCursor, nextRootInstance, fiber);
|
6149 |
|
6150 |
|
6151 | push(contextFiberStackCursor, fiber, fiber);
|
6152 |
|
6153 |
|
6154 |
|
6155 |
|
6156 |
|
6157 | push(contextStackCursor$1, NO_CONTEXT$1, fiber);
|
6158 | var nextRootContext = getRootHostContext(nextRootInstance);
|
6159 |
|
6160 | pop(contextStackCursor$1, fiber);
|
6161 | push(contextStackCursor$1, nextRootContext, fiber);
|
6162 | }
|
6163 |
|
6164 | function popHostContainer(fiber) {
|
6165 | pop(contextStackCursor$1, fiber);
|
6166 | pop(contextFiberStackCursor, fiber);
|
6167 | pop(rootInstanceStackCursor, fiber);
|
6168 | }
|
6169 |
|
6170 | function getHostContext() {
|
6171 | var context = requiredContext(contextStackCursor$1.current);
|
6172 | return context;
|
6173 | }
|
6174 |
|
6175 | function pushHostContext(fiber) {
|
6176 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
6177 | var context = requiredContext(contextStackCursor$1.current);
|
6178 | var nextContext = getChildHostContext(context, fiber.type, rootInstance);
|
6179 |
|
6180 | if (context === nextContext) {
|
6181 | return;
|
6182 | }
|
6183 |
|
6184 |
|
6185 |
|
6186 | push(contextFiberStackCursor, fiber, fiber);
|
6187 | push(contextStackCursor$1, nextContext, fiber);
|
6188 | }
|
6189 |
|
6190 | function popHostContext(fiber) {
|
6191 |
|
6192 |
|
6193 | if (contextFiberStackCursor.current !== fiber) {
|
6194 | return;
|
6195 | }
|
6196 |
|
6197 | pop(contextStackCursor$1, fiber);
|
6198 | pop(contextFiberStackCursor, fiber);
|
6199 | }
|
6200 |
|
6201 | var DefaultSuspenseContext = 0;
|
6202 |
|
6203 |
|
6204 |
|
6205 |
|
6206 | var SubtreeSuspenseContextMask = 1;
|
6207 |
|
6208 |
|
6209 |
|
6210 |
|
6211 |
|
6212 |
|
6213 |
|
6214 | var InvisibleParentSuspenseContext = 1;
|
6215 |
|
6216 |
|
6217 |
|
6218 | var ForceSuspenseFallback = 2;
|
6219 | var suspenseStackCursor = createCursor(DefaultSuspenseContext);
|
6220 | function hasSuspenseContext(parentContext, flag) {
|
6221 | return (parentContext & flag) !== 0;
|
6222 | }
|
6223 | function setDefaultShallowSuspenseContext(parentContext) {
|
6224 | return parentContext & SubtreeSuspenseContextMask;
|
6225 | }
|
6226 | function setShallowSuspenseContext(parentContext, shallowContext) {
|
6227 | return parentContext & SubtreeSuspenseContextMask | shallowContext;
|
6228 | }
|
6229 | function addSubtreeSuspenseContext(parentContext, subtreeContext) {
|
6230 | return parentContext | subtreeContext;
|
6231 | }
|
6232 | function pushSuspenseContext(fiber, newContext) {
|
6233 | push(suspenseStackCursor, newContext, fiber);
|
6234 | }
|
6235 | function popSuspenseContext(fiber) {
|
6236 | pop(suspenseStackCursor, fiber);
|
6237 | }
|
6238 |
|
6239 | function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
|
6240 |
|
6241 |
|
6242 | var nextState = workInProgress.memoizedState;
|
6243 |
|
6244 | if (nextState !== null) {
|
6245 | if (nextState.dehydrated !== null) {
|
6246 |
|
6247 | return true;
|
6248 | }
|
6249 |
|
6250 | return false;
|
6251 | }
|
6252 |
|
6253 | var props = workInProgress.memoizedProps;
|
6254 |
|
6255 | if (props.fallback === undefined) {
|
6256 | return false;
|
6257 | }
|
6258 |
|
6259 |
|
6260 | if (props.unstable_avoidThisFallback !== true) {
|
6261 | return true;
|
6262 | }
|
6263 |
|
6264 |
|
6265 |
|
6266 | if (hasInvisibleParent) {
|
6267 | return false;
|
6268 | }
|
6269 |
|
6270 |
|
6271 | return true;
|
6272 | }
|
6273 | function findFirstSuspended(row) {
|
6274 | var node = row;
|
6275 |
|
6276 | while (node !== null) {
|
6277 | if (node.tag === SuspenseComponent) {
|
6278 | var state = node.memoizedState;
|
6279 |
|
6280 | if (state !== null) {
|
6281 | var dehydrated = state.dehydrated;
|
6282 |
|
6283 | if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
|
6284 | return node;
|
6285 | }
|
6286 | }
|
6287 | } else if (node.tag === SuspenseListComponent &&
|
6288 |
|
6289 | node.memoizedProps.revealOrder !== undefined) {
|
6290 | var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
|
6291 |
|
6292 | if (didSuspend) {
|
6293 | return node;
|
6294 | }
|
6295 | } else if (node.child !== null) {
|
6296 | node.child.return = node;
|
6297 | node = node.child;
|
6298 | continue;
|
6299 | }
|
6300 |
|
6301 | if (node === row) {
|
6302 | return null;
|
6303 | }
|
6304 |
|
6305 | while (node.sibling === null) {
|
6306 | if (node.return === null || node.return === row) {
|
6307 | return null;
|
6308 | }
|
6309 |
|
6310 | node = node.return;
|
6311 | }
|
6312 |
|
6313 | node.sibling.return = node.return;
|
6314 | node = node.sibling;
|
6315 | }
|
6316 |
|
6317 | return null;
|
6318 | }
|
6319 |
|
6320 | var emptyObject = {};
|
6321 | var isArray$2 = Array.isArray;
|
6322 | function createResponderInstance(responder, responderProps, responderState, fiber) {
|
6323 | return {
|
6324 | fiber: fiber,
|
6325 | props: responderProps,
|
6326 | responder: responder,
|
6327 | rootEventTypes: null,
|
6328 | state: responderState
|
6329 | };
|
6330 | }
|
6331 |
|
6332 | function mountEventResponder(responder, responderProps, fiber, respondersMap, rootContainerInstance) {
|
6333 | var responderState = emptyObject;
|
6334 | var getInitialState = responder.getInitialState;
|
6335 |
|
6336 | if (getInitialState !== null) {
|
6337 | responderState = getInitialState(responderProps);
|
6338 | }
|
6339 |
|
6340 | var responderInstance = createResponderInstance(responder, responderProps, responderState, fiber);
|
6341 |
|
6342 | if (!rootContainerInstance) {
|
6343 | var node = fiber;
|
6344 |
|
6345 | while (node !== null) {
|
6346 | var tag = node.tag;
|
6347 |
|
6348 | if (tag === HostComponent) {
|
6349 | rootContainerInstance = node.stateNode;
|
6350 | break;
|
6351 | } else if (tag === HostRoot) {
|
6352 | rootContainerInstance = node.stateNode.containerInfo;
|
6353 | break;
|
6354 | }
|
6355 |
|
6356 | node = node.return;
|
6357 | }
|
6358 | }
|
6359 |
|
6360 | mountResponderInstance(responder, responderInstance, responderProps, responderState, rootContainerInstance);
|
6361 | respondersMap.set(responder, responderInstance);
|
6362 | }
|
6363 |
|
6364 | function updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance) {
|
6365 | var responder;
|
6366 | var props;
|
6367 |
|
6368 | if (listener) {
|
6369 | responder = listener.responder;
|
6370 | props = listener.props;
|
6371 | }
|
6372 |
|
6373 | if (!(responder && responder.$$typeof === REACT_RESPONDER_TYPE)) {
|
6374 | {
|
6375 | throw Error("An invalid value was used as an event listener. Expect one or many event listeners created via React.unstable_useResponder().");
|
6376 | }
|
6377 | }
|
6378 |
|
6379 | var listenerProps = props;
|
6380 |
|
6381 | if (visistedResponders.has(responder)) {
|
6382 |
|
6383 | {
|
6384 | warning$1(false, 'Duplicate event responder "%s" found in event listeners. ' + 'Event listeners passed to elements cannot use the same event responder more than once.', responder.displayName);
|
6385 | }
|
6386 |
|
6387 | return;
|
6388 | }
|
6389 |
|
6390 | visistedResponders.add(responder);
|
6391 | var responderInstance = respondersMap.get(responder);
|
6392 |
|
6393 | if (responderInstance === undefined) {
|
6394 |
|
6395 | mountEventResponder(responder, listenerProps, fiber, respondersMap, rootContainerInstance);
|
6396 | } else {
|
6397 |
|
6398 | responderInstance.props = listenerProps;
|
6399 | responderInstance.fiber = fiber;
|
6400 | }
|
6401 | }
|
6402 |
|
6403 | function updateEventListeners(listeners, fiber, rootContainerInstance) {
|
6404 | var visistedResponders = new Set();
|
6405 | var dependencies = fiber.dependencies;
|
6406 |
|
6407 | if (listeners != null) {
|
6408 | if (dependencies === null) {
|
6409 | dependencies = fiber.dependencies = {
|
6410 | expirationTime: NoWork,
|
6411 | firstContext: null,
|
6412 | responders: new Map()
|
6413 | };
|
6414 | }
|
6415 |
|
6416 | var respondersMap = dependencies.responders;
|
6417 |
|
6418 | if (respondersMap === null) {
|
6419 | respondersMap = new Map();
|
6420 | }
|
6421 |
|
6422 | if (isArray$2(listeners)) {
|
6423 | for (var i = 0, length = listeners.length; i < length; i++) {
|
6424 | var listener = listeners[i];
|
6425 | updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance);
|
6426 | }
|
6427 | } else {
|
6428 | updateEventListener(listeners, fiber, visistedResponders, respondersMap, rootContainerInstance);
|
6429 | }
|
6430 | }
|
6431 |
|
6432 | if (dependencies !== null) {
|
6433 | var _respondersMap = dependencies.responders;
|
6434 |
|
6435 | if (_respondersMap !== null) {
|
6436 |
|
6437 | var mountedResponders = Array.from(_respondersMap.keys());
|
6438 |
|
6439 | for (var _i = 0, _length = mountedResponders.length; _i < _length; _i++) {
|
6440 | var mountedResponder = mountedResponders[_i];
|
6441 |
|
6442 | if (!visistedResponders.has(mountedResponder)) {
|
6443 | var responderInstance = _respondersMap.get(mountedResponder);
|
6444 |
|
6445 | unmountResponderInstance(responderInstance);
|
6446 |
|
6447 | _respondersMap.delete(mountedResponder);
|
6448 | }
|
6449 | }
|
6450 | }
|
6451 | }
|
6452 | }
|
6453 | function createResponderListener(responder, props) {
|
6454 | var eventResponderListener = {
|
6455 | responder: responder,
|
6456 | props: props
|
6457 | };
|
6458 |
|
6459 | {
|
6460 | Object.freeze(eventResponderListener);
|
6461 | }
|
6462 |
|
6463 | return eventResponderListener;
|
6464 | }
|
6465 |
|
6466 | var NoEffect$1 =
|
6467 |
|
6468 | 0;
|
6469 | var UnmountSnapshot =
|
6470 |
|
6471 | 2;
|
6472 | var UnmountMutation =
|
6473 |
|
6474 | 4;
|
6475 | var MountMutation =
|
6476 |
|
6477 | 8;
|
6478 | var UnmountLayout =
|
6479 |
|
6480 | 16;
|
6481 | var MountLayout =
|
6482 |
|
6483 | 32;
|
6484 | var MountPassive =
|
6485 |
|
6486 | 64;
|
6487 | var UnmountPassive =
|
6488 |
|
6489 | 128;
|
6490 |
|
6491 | var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
|
6492 | var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
|
6493 | var didWarnAboutMismatchedHooksForComponent;
|
6494 |
|
6495 | {
|
6496 | didWarnAboutMismatchedHooksForComponent = new Set();
|
6497 | }
|
6498 |
|
6499 |
|
6500 | var renderExpirationTime$1 = NoWork;
|
6501 |
|
6502 |
|
6503 | var currentlyRenderingFiber$1 = null;
|
6504 |
|
6505 |
|
6506 |
|
6507 |
|
6508 | var currentHook = null;
|
6509 | var nextCurrentHook = null;
|
6510 | var firstWorkInProgressHook = null;
|
6511 | var workInProgressHook = null;
|
6512 | var nextWorkInProgressHook = null;
|
6513 | var remainingExpirationTime = NoWork;
|
6514 | var componentUpdateQueue = null;
|
6515 | var sideEffectTag = 0;
|
6516 |
|
6517 |
|
6518 |
|
6519 |
|
6520 |
|
6521 |
|
6522 |
|
6523 |
|
6524 | var didScheduleRenderPhaseUpdate = false;
|
6525 |
|
6526 | var renderPhaseUpdates = null;
|
6527 |
|
6528 | var numberOfReRenders = 0;
|
6529 | var RE_RENDER_LIMIT = 25;
|
6530 |
|
6531 | var currentHookNameInDev = null;
|
6532 |
|
6533 |
|
6534 |
|
6535 | var hookTypesDev = null;
|
6536 | var hookTypesUpdateIndexDev = -1;
|
6537 |
|
6538 |
|
6539 |
|
6540 | var ignorePreviousDependencies = false;
|
6541 |
|
6542 | function mountHookTypesDev() {
|
6543 | {
|
6544 | var hookName = currentHookNameInDev;
|
6545 |
|
6546 | if (hookTypesDev === null) {
|
6547 | hookTypesDev = [hookName];
|
6548 | } else {
|
6549 | hookTypesDev.push(hookName);
|
6550 | }
|
6551 | }
|
6552 | }
|
6553 |
|
6554 | function updateHookTypesDev() {
|
6555 | {
|
6556 | var hookName = currentHookNameInDev;
|
6557 |
|
6558 | if (hookTypesDev !== null) {
|
6559 | hookTypesUpdateIndexDev++;
|
6560 |
|
6561 | if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
|
6562 | warnOnHookMismatchInDev(hookName);
|
6563 | }
|
6564 | }
|
6565 | }
|
6566 | }
|
6567 |
|
6568 | function checkDepsAreArrayDev(deps) {
|
6569 | {
|
6570 | if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
|
6571 |
|
6572 |
|
6573 | warning$1(false, '%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps);
|
6574 | }
|
6575 | }
|
6576 | }
|
6577 |
|
6578 | function warnOnHookMismatchInDev(currentHookName) {
|
6579 | {
|
6580 | var componentName = getComponentName(currentlyRenderingFiber$1.type);
|
6581 |
|
6582 | if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
|
6583 | didWarnAboutMismatchedHooksForComponent.add(componentName);
|
6584 |
|
6585 | if (hookTypesDev !== null) {
|
6586 | var table = '';
|
6587 | var secondColumnStart = 30;
|
6588 |
|
6589 | for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
|
6590 | var oldHookName = hookTypesDev[i];
|
6591 | var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
|
6592 | var row = i + 1 + ". " + oldHookName;
|
6593 |
|
6594 |
|
6595 | while (row.length < secondColumnStart) {
|
6596 | row += ' ';
|
6597 | }
|
6598 |
|
6599 | row += newHookName + '\n';
|
6600 | table += row;
|
6601 | }
|
6602 |
|
6603 | warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
|
6604 | }
|
6605 | }
|
6606 | }
|
6607 | }
|
6608 |
|
6609 | function throwInvalidHookError() {
|
6610 | {
|
6611 | {
|
6612 | throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.");
|
6613 | }
|
6614 | }
|
6615 | }
|
6616 |
|
6617 | function areHookInputsEqual(nextDeps, prevDeps) {
|
6618 | {
|
6619 | if (ignorePreviousDependencies) {
|
6620 |
|
6621 | return false;
|
6622 | }
|
6623 | }
|
6624 |
|
6625 | if (prevDeps === null) {
|
6626 | {
|
6627 | warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
|
6628 | }
|
6629 |
|
6630 | return false;
|
6631 | }
|
6632 |
|
6633 | {
|
6634 |
|
6635 |
|
6636 | if (nextDeps.length !== prevDeps.length) {
|
6637 | warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]");
|
6638 | }
|
6639 | }
|
6640 |
|
6641 | for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
6642 | if (is$1(nextDeps[i], prevDeps[i])) {
|
6643 | continue;
|
6644 | }
|
6645 |
|
6646 | return false;
|
6647 | }
|
6648 |
|
6649 | return true;
|
6650 | }
|
6651 |
|
6652 | function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
|
6653 | renderExpirationTime$1 = nextRenderExpirationTime;
|
6654 | currentlyRenderingFiber$1 = workInProgress;
|
6655 | nextCurrentHook = current !== null ? current.memoizedState : null;
|
6656 |
|
6657 | {
|
6658 | hookTypesDev = current !== null ? current._debugHookTypes : null;
|
6659 | hookTypesUpdateIndexDev = -1;
|
6660 |
|
6661 | ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
|
6662 | }
|
6663 |
|
6664 |
|
6665 |
|
6666 |
|
6667 |
|
6668 |
|
6669 |
|
6670 |
|
6671 |
|
6672 |
|
6673 |
|
6674 |
|
6675 |
|
6676 |
|
6677 |
|
6678 |
|
6679 | {
|
6680 | if (nextCurrentHook !== null) {
|
6681 | ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
6682 | } else if (hookTypesDev !== null) {
|
6683 |
|
6684 |
|
6685 |
|
6686 |
|
6687 |
|
6688 | ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
|
6689 | } else {
|
6690 | ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
|
6691 | }
|
6692 | }
|
6693 |
|
6694 | var children = Component(props, refOrContext);
|
6695 |
|
6696 | if (didScheduleRenderPhaseUpdate) {
|
6697 | do {
|
6698 | didScheduleRenderPhaseUpdate = false;
|
6699 | numberOfReRenders += 1;
|
6700 |
|
6701 | {
|
6702 |
|
6703 |
|
6704 | ignorePreviousDependencies = false;
|
6705 | }
|
6706 |
|
6707 |
|
6708 | nextCurrentHook = current !== null ? current.memoizedState : null;
|
6709 | nextWorkInProgressHook = firstWorkInProgressHook;
|
6710 | currentHook = null;
|
6711 | workInProgressHook = null;
|
6712 | componentUpdateQueue = null;
|
6713 |
|
6714 | {
|
6715 |
|
6716 | hookTypesUpdateIndexDev = -1;
|
6717 | }
|
6718 |
|
6719 | ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
6720 | children = Component(props, refOrContext);
|
6721 | } while (didScheduleRenderPhaseUpdate);
|
6722 |
|
6723 | renderPhaseUpdates = null;
|
6724 | numberOfReRenders = 0;
|
6725 | }
|
6726 |
|
6727 |
|
6728 |
|
6729 | ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
6730 | var renderedWork = currentlyRenderingFiber$1;
|
6731 | renderedWork.memoizedState = firstWorkInProgressHook;
|
6732 | renderedWork.expirationTime = remainingExpirationTime;
|
6733 | renderedWork.updateQueue = componentUpdateQueue;
|
6734 | renderedWork.effectTag |= sideEffectTag;
|
6735 |
|
6736 | {
|
6737 | renderedWork._debugHookTypes = hookTypesDev;
|
6738 | }
|
6739 |
|
6740 |
|
6741 |
|
6742 | var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
|
6743 | renderExpirationTime$1 = NoWork;
|
6744 | currentlyRenderingFiber$1 = null;
|
6745 | currentHook = null;
|
6746 | nextCurrentHook = null;
|
6747 | firstWorkInProgressHook = null;
|
6748 | workInProgressHook = null;
|
6749 | nextWorkInProgressHook = null;
|
6750 |
|
6751 | {
|
6752 | currentHookNameInDev = null;
|
6753 | hookTypesDev = null;
|
6754 | hookTypesUpdateIndexDev = -1;
|
6755 | }
|
6756 |
|
6757 | remainingExpirationTime = NoWork;
|
6758 | componentUpdateQueue = null;
|
6759 | sideEffectTag = 0;
|
6760 |
|
6761 |
|
6762 |
|
6763 |
|
6764 | if (!!didRenderTooFewHooks) {
|
6765 | {
|
6766 | throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");
|
6767 | }
|
6768 | }
|
6769 |
|
6770 | return children;
|
6771 | }
|
6772 | function bailoutHooks(current, workInProgress, expirationTime) {
|
6773 | workInProgress.updateQueue = current.updateQueue;
|
6774 | workInProgress.effectTag &= ~(Passive | Update);
|
6775 |
|
6776 | if (current.expirationTime <= expirationTime) {
|
6777 | current.expirationTime = NoWork;
|
6778 | }
|
6779 | }
|
6780 | function resetHooks() {
|
6781 |
|
6782 |
|
6783 | ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
6784 |
|
6785 |
|
6786 |
|
6787 | renderExpirationTime$1 = NoWork;
|
6788 | currentlyRenderingFiber$1 = null;
|
6789 | currentHook = null;
|
6790 | nextCurrentHook = null;
|
6791 | firstWorkInProgressHook = null;
|
6792 | workInProgressHook = null;
|
6793 | nextWorkInProgressHook = null;
|
6794 |
|
6795 | {
|
6796 | hookTypesDev = null;
|
6797 | hookTypesUpdateIndexDev = -1;
|
6798 | currentHookNameInDev = null;
|
6799 | }
|
6800 |
|
6801 | remainingExpirationTime = NoWork;
|
6802 | componentUpdateQueue = null;
|
6803 | sideEffectTag = 0;
|
6804 | didScheduleRenderPhaseUpdate = false;
|
6805 | renderPhaseUpdates = null;
|
6806 | numberOfReRenders = 0;
|
6807 | }
|
6808 |
|
6809 | function mountWorkInProgressHook() {
|
6810 | var hook = {
|
6811 | memoizedState: null,
|
6812 | baseState: null,
|
6813 | queue: null,
|
6814 | baseUpdate: null,
|
6815 | next: null
|
6816 | };
|
6817 |
|
6818 | if (workInProgressHook === null) {
|
6819 |
|
6820 | firstWorkInProgressHook = workInProgressHook = hook;
|
6821 | } else {
|
6822 |
|
6823 | workInProgressHook = workInProgressHook.next = hook;
|
6824 | }
|
6825 |
|
6826 | return workInProgressHook;
|
6827 | }
|
6828 |
|
6829 | function updateWorkInProgressHook() {
|
6830 |
|
6831 |
|
6832 |
|
6833 |
|
6834 |
|
6835 | if (nextWorkInProgressHook !== null) {
|
6836 |
|
6837 | workInProgressHook = nextWorkInProgressHook;
|
6838 | nextWorkInProgressHook = workInProgressHook.next;
|
6839 | currentHook = nextCurrentHook;
|
6840 | nextCurrentHook = currentHook !== null ? currentHook.next : null;
|
6841 | } else {
|
6842 |
|
6843 | if (!(nextCurrentHook !== null)) {
|
6844 | {
|
6845 | throw Error("Rendered more hooks than during the previous render.");
|
6846 | }
|
6847 | }
|
6848 |
|
6849 | currentHook = nextCurrentHook;
|
6850 | var newHook = {
|
6851 | memoizedState: currentHook.memoizedState,
|
6852 | baseState: currentHook.baseState,
|
6853 | queue: currentHook.queue,
|
6854 | baseUpdate: currentHook.baseUpdate,
|
6855 | next: null
|
6856 | };
|
6857 |
|
6858 | if (workInProgressHook === null) {
|
6859 |
|
6860 | workInProgressHook = firstWorkInProgressHook = newHook;
|
6861 | } else {
|
6862 |
|
6863 | workInProgressHook = workInProgressHook.next = newHook;
|
6864 | }
|
6865 |
|
6866 | nextCurrentHook = currentHook.next;
|
6867 | }
|
6868 |
|
6869 | return workInProgressHook;
|
6870 | }
|
6871 |
|
6872 | function createFunctionComponentUpdateQueue() {
|
6873 | return {
|
6874 | lastEffect: null
|
6875 | };
|
6876 | }
|
6877 |
|
6878 | function basicStateReducer(state, action) {
|
6879 | return typeof action === 'function' ? action(state) : action;
|
6880 | }
|
6881 |
|
6882 | function mountReducer(reducer, initialArg, init) {
|
6883 | var hook = mountWorkInProgressHook();
|
6884 | var initialState;
|
6885 |
|
6886 | if (init !== undefined) {
|
6887 | initialState = init(initialArg);
|
6888 | } else {
|
6889 | initialState = initialArg;
|
6890 | }
|
6891 |
|
6892 | hook.memoizedState = hook.baseState = initialState;
|
6893 | var queue = hook.queue = {
|
6894 | last: null,
|
6895 | dispatch: null,
|
6896 | lastRenderedReducer: reducer,
|
6897 | lastRenderedState: initialState
|
6898 | };
|
6899 | var dispatch = queue.dispatch = dispatchAction.bind(null,
|
6900 | currentlyRenderingFiber$1, queue);
|
6901 | return [hook.memoizedState, dispatch];
|
6902 | }
|
6903 |
|
6904 | function updateReducer(reducer, initialArg, init) {
|
6905 | var hook = updateWorkInProgressHook();
|
6906 | var queue = hook.queue;
|
6907 |
|
6908 | if (!(queue !== null)) {
|
6909 | {
|
6910 | throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");
|
6911 | }
|
6912 | }
|
6913 |
|
6914 | queue.lastRenderedReducer = reducer;
|
6915 |
|
6916 | if (numberOfReRenders > 0) {
|
6917 |
|
6918 |
|
6919 | var _dispatch = queue.dispatch;
|
6920 |
|
6921 | if (renderPhaseUpdates !== null) {
|
6922 |
|
6923 | var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
|
6924 |
|
6925 | if (firstRenderPhaseUpdate !== undefined) {
|
6926 | renderPhaseUpdates.delete(queue);
|
6927 | var newState = hook.memoizedState;
|
6928 | var update = firstRenderPhaseUpdate;
|
6929 |
|
6930 | do {
|
6931 |
|
6932 |
|
6933 |
|
6934 | var action = update.action;
|
6935 | newState = reducer(newState, action);
|
6936 | update = update.next;
|
6937 | } while (update !== null);
|
6938 |
|
6939 |
|
6940 |
|
6941 | if (!is$1(newState, hook.memoizedState)) {
|
6942 | markWorkInProgressReceivedUpdate();
|
6943 | }
|
6944 |
|
6945 | hook.memoizedState = newState;
|
6946 |
|
6947 |
|
6948 |
|
6949 |
|
6950 | if (hook.baseUpdate === queue.last) {
|
6951 | hook.baseState = newState;
|
6952 | }
|
6953 |
|
6954 | queue.lastRenderedState = newState;
|
6955 | return [newState, _dispatch];
|
6956 | }
|
6957 | }
|
6958 |
|
6959 | return [hook.memoizedState, _dispatch];
|
6960 | }
|
6961 |
|
6962 |
|
6963 | var last = queue.last;
|
6964 |
|
6965 | var baseUpdate = hook.baseUpdate;
|
6966 | var baseState = hook.baseState;
|
6967 |
|
6968 | var first;
|
6969 |
|
6970 | if (baseUpdate !== null) {
|
6971 | if (last !== null) {
|
6972 |
|
6973 |
|
6974 |
|
6975 | last.next = null;
|
6976 | }
|
6977 |
|
6978 | first = baseUpdate.next;
|
6979 | } else {
|
6980 | first = last !== null ? last.next : null;
|
6981 | }
|
6982 |
|
6983 | if (first !== null) {
|
6984 | var _newState = baseState;
|
6985 | var newBaseState = null;
|
6986 | var newBaseUpdate = null;
|
6987 | var prevUpdate = baseUpdate;
|
6988 | var _update = first;
|
6989 | var didSkip = false;
|
6990 |
|
6991 | do {
|
6992 | var updateExpirationTime = _update.expirationTime;
|
6993 |
|
6994 | if (updateExpirationTime < renderExpirationTime$1) {
|
6995 |
|
6996 |
|
6997 |
|
6998 | if (!didSkip) {
|
6999 | didSkip = true;
|
7000 | newBaseUpdate = prevUpdate;
|
7001 | newBaseState = _newState;
|
7002 | }
|
7003 |
|
7004 |
|
7005 | if (updateExpirationTime > remainingExpirationTime) {
|
7006 | remainingExpirationTime = updateExpirationTime;
|
7007 | markUnprocessedUpdateTime(remainingExpirationTime);
|
7008 | }
|
7009 | } else {
|
7010 |
|
7011 |
|
7012 |
|
7013 |
|
7014 |
|
7015 |
|
7016 |
|
7017 | markRenderEventTimeAndConfig(updateExpirationTime, _update.suspenseConfig);
|
7018 |
|
7019 | if (_update.eagerReducer === reducer) {
|
7020 |
|
7021 |
|
7022 | _newState = _update.eagerState;
|
7023 | } else {
|
7024 | var _action = _update.action;
|
7025 | _newState = reducer(_newState, _action);
|
7026 | }
|
7027 | }
|
7028 |
|
7029 | prevUpdate = _update;
|
7030 | _update = _update.next;
|
7031 | } while (_update !== null && _update !== first);
|
7032 |
|
7033 | if (!didSkip) {
|
7034 | newBaseUpdate = prevUpdate;
|
7035 | newBaseState = _newState;
|
7036 | }
|
7037 |
|
7038 |
|
7039 |
|
7040 | if (!is$1(_newState, hook.memoizedState)) {
|
7041 | markWorkInProgressReceivedUpdate();
|
7042 | }
|
7043 |
|
7044 | hook.memoizedState = _newState;
|
7045 | hook.baseUpdate = newBaseUpdate;
|
7046 | hook.baseState = newBaseState;
|
7047 | queue.lastRenderedState = _newState;
|
7048 | }
|
7049 |
|
7050 | var dispatch = queue.dispatch;
|
7051 | return [hook.memoizedState, dispatch];
|
7052 | }
|
7053 |
|
7054 | function mountState(initialState) {
|
7055 | var hook = mountWorkInProgressHook();
|
7056 |
|
7057 | if (typeof initialState === 'function') {
|
7058 | initialState = initialState();
|
7059 | }
|
7060 |
|
7061 | hook.memoizedState = hook.baseState = initialState;
|
7062 | var queue = hook.queue = {
|
7063 | last: null,
|
7064 | dispatch: null,
|
7065 | lastRenderedReducer: basicStateReducer,
|
7066 | lastRenderedState: initialState
|
7067 | };
|
7068 | var dispatch = queue.dispatch = dispatchAction.bind(null,
|
7069 | currentlyRenderingFiber$1, queue);
|
7070 | return [hook.memoizedState, dispatch];
|
7071 | }
|
7072 |
|
7073 | function updateState(initialState) {
|
7074 | return updateReducer(basicStateReducer, initialState);
|
7075 | }
|
7076 |
|
7077 | function pushEffect(tag, create, destroy, deps) {
|
7078 | var effect = {
|
7079 | tag: tag,
|
7080 | create: create,
|
7081 | destroy: destroy,
|
7082 | deps: deps,
|
7083 |
|
7084 | next: null
|
7085 | };
|
7086 |
|
7087 | if (componentUpdateQueue === null) {
|
7088 | componentUpdateQueue = createFunctionComponentUpdateQueue();
|
7089 | componentUpdateQueue.lastEffect = effect.next = effect;
|
7090 | } else {
|
7091 | var lastEffect = componentUpdateQueue.lastEffect;
|
7092 |
|
7093 | if (lastEffect === null) {
|
7094 | componentUpdateQueue.lastEffect = effect.next = effect;
|
7095 | } else {
|
7096 | var firstEffect = lastEffect.next;
|
7097 | lastEffect.next = effect;
|
7098 | effect.next = firstEffect;
|
7099 | componentUpdateQueue.lastEffect = effect;
|
7100 | }
|
7101 | }
|
7102 |
|
7103 | return effect;
|
7104 | }
|
7105 |
|
7106 | function mountRef(initialValue) {
|
7107 | var hook = mountWorkInProgressHook();
|
7108 | var ref = {
|
7109 | current: initialValue
|
7110 | };
|
7111 |
|
7112 | {
|
7113 | Object.seal(ref);
|
7114 | }
|
7115 |
|
7116 | hook.memoizedState = ref;
|
7117 | return ref;
|
7118 | }
|
7119 |
|
7120 | function updateRef(initialValue) {
|
7121 | var hook = updateWorkInProgressHook();
|
7122 | return hook.memoizedState;
|
7123 | }
|
7124 |
|
7125 | function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
|
7126 | var hook = mountWorkInProgressHook();
|
7127 | var nextDeps = deps === undefined ? null : deps;
|
7128 | sideEffectTag |= fiberEffectTag;
|
7129 | hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
|
7130 | }
|
7131 |
|
7132 | function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
|
7133 | var hook = updateWorkInProgressHook();
|
7134 | var nextDeps = deps === undefined ? null : deps;
|
7135 | var destroy = undefined;
|
7136 |
|
7137 | if (currentHook !== null) {
|
7138 | var prevEffect = currentHook.memoizedState;
|
7139 | destroy = prevEffect.destroy;
|
7140 |
|
7141 | if (nextDeps !== null) {
|
7142 | var prevDeps = prevEffect.deps;
|
7143 |
|
7144 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
7145 | pushEffect(NoEffect$1, create, destroy, nextDeps);
|
7146 | return;
|
7147 | }
|
7148 | }
|
7149 | }
|
7150 |
|
7151 | sideEffectTag |= fiberEffectTag;
|
7152 | hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
|
7153 | }
|
7154 |
|
7155 | function mountEffect(create, deps) {
|
7156 | {
|
7157 |
|
7158 | if ('undefined' !== typeof jest) {
|
7159 | warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
|
7160 | }
|
7161 | }
|
7162 |
|
7163 | return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
|
7164 | }
|
7165 |
|
7166 | function updateEffect(create, deps) {
|
7167 | {
|
7168 |
|
7169 | if ('undefined' !== typeof jest) {
|
7170 | warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
|
7171 | }
|
7172 | }
|
7173 |
|
7174 | return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
|
7175 | }
|
7176 |
|
7177 | function mountLayoutEffect(create, deps) {
|
7178 | return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
|
7179 | }
|
7180 |
|
7181 | function updateLayoutEffect(create, deps) {
|
7182 | return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
|
7183 | }
|
7184 |
|
7185 | function imperativeHandleEffect(create, ref) {
|
7186 | if (typeof ref === 'function') {
|
7187 | var refCallback = ref;
|
7188 |
|
7189 | var _inst = create();
|
7190 |
|
7191 | refCallback(_inst);
|
7192 | return function () {
|
7193 | refCallback(null);
|
7194 | };
|
7195 | } else if (ref !== null && ref !== undefined) {
|
7196 | var refObject = ref;
|
7197 |
|
7198 | {
|
7199 | !refObject.hasOwnProperty('current') ? warning$1(false, 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}') : void 0;
|
7200 | }
|
7201 |
|
7202 | var _inst2 = create();
|
7203 |
|
7204 | refObject.current = _inst2;
|
7205 | return function () {
|
7206 | refObject.current = null;
|
7207 | };
|
7208 | }
|
7209 | }
|
7210 |
|
7211 | function mountImperativeHandle(ref, create, deps) {
|
7212 | {
|
7213 | !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
|
7214 | }
|
7215 |
|
7216 |
|
7217 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
7218 | return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
7219 | }
|
7220 |
|
7221 | function updateImperativeHandle(ref, create, deps) {
|
7222 | {
|
7223 | !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
|
7224 | }
|
7225 |
|
7226 |
|
7227 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
7228 | return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
7229 | }
|
7230 |
|
7231 | function mountDebugValue(value, formatterFn) {
|
7232 |
|
7233 |
|
7234 | }
|
7235 |
|
7236 | var updateDebugValue = mountDebugValue;
|
7237 |
|
7238 | function mountCallback(callback, deps) {
|
7239 | var hook = mountWorkInProgressHook();
|
7240 | var nextDeps = deps === undefined ? null : deps;
|
7241 | hook.memoizedState = [callback, nextDeps];
|
7242 | return callback;
|
7243 | }
|
7244 |
|
7245 | function updateCallback(callback, deps) {
|
7246 | var hook = updateWorkInProgressHook();
|
7247 | var nextDeps = deps === undefined ? null : deps;
|
7248 | var prevState = hook.memoizedState;
|
7249 |
|
7250 | if (prevState !== null) {
|
7251 | if (nextDeps !== null) {
|
7252 | var prevDeps = prevState[1];
|
7253 |
|
7254 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
7255 | return prevState[0];
|
7256 | }
|
7257 | }
|
7258 | }
|
7259 |
|
7260 | hook.memoizedState = [callback, nextDeps];
|
7261 | return callback;
|
7262 | }
|
7263 |
|
7264 | function mountMemo(nextCreate, deps) {
|
7265 | var hook = mountWorkInProgressHook();
|
7266 | var nextDeps = deps === undefined ? null : deps;
|
7267 | var nextValue = nextCreate();
|
7268 | hook.memoizedState = [nextValue, nextDeps];
|
7269 | return nextValue;
|
7270 | }
|
7271 |
|
7272 | function updateMemo(nextCreate, deps) {
|
7273 | var hook = updateWorkInProgressHook();
|
7274 | var nextDeps = deps === undefined ? null : deps;
|
7275 | var prevState = hook.memoizedState;
|
7276 |
|
7277 | if (prevState !== null) {
|
7278 |
|
7279 | if (nextDeps !== null) {
|
7280 | var prevDeps = prevState[1];
|
7281 |
|
7282 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
7283 | return prevState[0];
|
7284 | }
|
7285 | }
|
7286 | }
|
7287 |
|
7288 | var nextValue = nextCreate();
|
7289 | hook.memoizedState = [nextValue, nextDeps];
|
7290 | return nextValue;
|
7291 | }
|
7292 |
|
7293 | function mountDeferredValue(value, config) {
|
7294 | var _mountState = mountState(value),
|
7295 | prevValue = _mountState[0],
|
7296 | setValue = _mountState[1];
|
7297 |
|
7298 | mountEffect(function () {
|
7299 | unstable_next(function () {
|
7300 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
7301 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
7302 |
|
7303 | try {
|
7304 | setValue(value);
|
7305 | } finally {
|
7306 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
7307 | }
|
7308 | });
|
7309 | }, [value, config]);
|
7310 | return prevValue;
|
7311 | }
|
7312 |
|
7313 | function updateDeferredValue(value, config) {
|
7314 | var _updateState = updateState(value),
|
7315 | prevValue = _updateState[0],
|
7316 | setValue = _updateState[1];
|
7317 |
|
7318 | updateEffect(function () {
|
7319 | unstable_next(function () {
|
7320 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
7321 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
7322 |
|
7323 | try {
|
7324 | setValue(value);
|
7325 | } finally {
|
7326 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
7327 | }
|
7328 | });
|
7329 | }, [value, config]);
|
7330 | return prevValue;
|
7331 | }
|
7332 |
|
7333 | function mountTransition(config) {
|
7334 | var _mountState2 = mountState(false),
|
7335 | isPending = _mountState2[0],
|
7336 | setPending = _mountState2[1];
|
7337 |
|
7338 | var startTransition = mountCallback(function (callback) {
|
7339 | setPending(true);
|
7340 | unstable_next(function () {
|
7341 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
7342 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
7343 |
|
7344 | try {
|
7345 | setPending(false);
|
7346 | callback();
|
7347 | } finally {
|
7348 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
7349 | }
|
7350 | });
|
7351 | }, [config, isPending]);
|
7352 | return [startTransition, isPending];
|
7353 | }
|
7354 |
|
7355 | function updateTransition(config) {
|
7356 | var _updateState2 = updateState(false),
|
7357 | isPending = _updateState2[0],
|
7358 | setPending = _updateState2[1];
|
7359 |
|
7360 | var startTransition = updateCallback(function (callback) {
|
7361 | setPending(true);
|
7362 | unstable_next(function () {
|
7363 | var previousConfig = ReactCurrentBatchConfig$1.suspense;
|
7364 | ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
|
7365 |
|
7366 | try {
|
7367 | setPending(false);
|
7368 | callback();
|
7369 | } finally {
|
7370 | ReactCurrentBatchConfig$1.suspense = previousConfig;
|
7371 | }
|
7372 | });
|
7373 | }, [config, isPending]);
|
7374 | return [startTransition, isPending];
|
7375 | }
|
7376 |
|
7377 | function dispatchAction(fiber, queue, action) {
|
7378 | if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
|
7379 | {
|
7380 | throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
|
7381 | }
|
7382 | }
|
7383 |
|
7384 | {
|
7385 | !(typeof arguments[3] !== 'function') ? warning$1(false, "State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().') : void 0;
|
7386 | }
|
7387 |
|
7388 | var alternate = fiber.alternate;
|
7389 |
|
7390 | if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
|
7391 |
|
7392 |
|
7393 |
|
7394 | didScheduleRenderPhaseUpdate = true;
|
7395 | var update = {
|
7396 | expirationTime: renderExpirationTime$1,
|
7397 | suspenseConfig: null,
|
7398 | action: action,
|
7399 | eagerReducer: null,
|
7400 | eagerState: null,
|
7401 | next: null
|
7402 | };
|
7403 |
|
7404 | {
|
7405 | update.priority = getCurrentPriorityLevel();
|
7406 | }
|
7407 |
|
7408 | if (renderPhaseUpdates === null) {
|
7409 | renderPhaseUpdates = new Map();
|
7410 | }
|
7411 |
|
7412 | var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
|
7413 |
|
7414 | if (firstRenderPhaseUpdate === undefined) {
|
7415 | renderPhaseUpdates.set(queue, update);
|
7416 | } else {
|
7417 |
|
7418 | var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
|
7419 |
|
7420 | while (lastRenderPhaseUpdate.next !== null) {
|
7421 | lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
7422 | }
|
7423 |
|
7424 | lastRenderPhaseUpdate.next = update;
|
7425 | }
|
7426 | } else {
|
7427 | var currentTime = requestCurrentTimeForUpdate();
|
7428 | var suspenseConfig = requestCurrentSuspenseConfig();
|
7429 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
|
7430 | var _update2 = {
|
7431 | expirationTime: expirationTime,
|
7432 | suspenseConfig: suspenseConfig,
|
7433 | action: action,
|
7434 | eagerReducer: null,
|
7435 | eagerState: null,
|
7436 | next: null
|
7437 | };
|
7438 |
|
7439 | {
|
7440 | _update2.priority = getCurrentPriorityLevel();
|
7441 | }
|
7442 |
|
7443 |
|
7444 | var last = queue.last;
|
7445 |
|
7446 | if (last === null) {
|
7447 |
|
7448 | _update2.next = _update2;
|
7449 | } else {
|
7450 | var first = last.next;
|
7451 |
|
7452 | if (first !== null) {
|
7453 |
|
7454 | _update2.next = first;
|
7455 | }
|
7456 |
|
7457 | last.next = _update2;
|
7458 | }
|
7459 |
|
7460 | queue.last = _update2;
|
7461 |
|
7462 | if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
|
7463 |
|
7464 |
|
7465 |
|
7466 | var lastRenderedReducer = queue.lastRenderedReducer;
|
7467 |
|
7468 | if (lastRenderedReducer !== null) {
|
7469 | var prevDispatcher;
|
7470 |
|
7471 | {
|
7472 | prevDispatcher = ReactCurrentDispatcher$1.current;
|
7473 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7474 | }
|
7475 |
|
7476 | try {
|
7477 | var currentState = queue.lastRenderedState;
|
7478 | var eagerState = lastRenderedReducer(currentState, action);
|
7479 |
|
7480 |
|
7481 |
|
7482 |
|
7483 | _update2.eagerReducer = lastRenderedReducer;
|
7484 | _update2.eagerState = eagerState;
|
7485 |
|
7486 | if (is$1(eagerState, currentState)) {
|
7487 |
|
7488 |
|
7489 |
|
7490 |
|
7491 | return;
|
7492 | }
|
7493 | } catch (error) {
|
7494 | } finally {
|
7495 | {
|
7496 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7497 | }
|
7498 | }
|
7499 | }
|
7500 | }
|
7501 |
|
7502 | {
|
7503 |
|
7504 | if ('undefined' !== typeof jest) {
|
7505 | warnIfNotScopedWithMatchingAct(fiber);
|
7506 | warnIfNotCurrentlyActingUpdatesInDev(fiber);
|
7507 | }
|
7508 | }
|
7509 |
|
7510 | scheduleWork(fiber, expirationTime);
|
7511 | }
|
7512 | }
|
7513 |
|
7514 | var ContextOnlyDispatcher = {
|
7515 | readContext: readContext,
|
7516 | useCallback: throwInvalidHookError,
|
7517 | useContext: throwInvalidHookError,
|
7518 | useEffect: throwInvalidHookError,
|
7519 | useImperativeHandle: throwInvalidHookError,
|
7520 | useLayoutEffect: throwInvalidHookError,
|
7521 | useMemo: throwInvalidHookError,
|
7522 | useReducer: throwInvalidHookError,
|
7523 | useRef: throwInvalidHookError,
|
7524 | useState: throwInvalidHookError,
|
7525 | useDebugValue: throwInvalidHookError,
|
7526 | useResponder: throwInvalidHookError,
|
7527 | useDeferredValue: throwInvalidHookError,
|
7528 | useTransition: throwInvalidHookError
|
7529 | };
|
7530 | var HooksDispatcherOnMountInDEV = null;
|
7531 | var HooksDispatcherOnMountWithHookTypesInDEV = null;
|
7532 | var HooksDispatcherOnUpdateInDEV = null;
|
7533 | var InvalidNestedHooksDispatcherOnMountInDEV = null;
|
7534 | var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
7535 |
|
7536 | {
|
7537 | var warnInvalidContextAccess = function () {
|
7538 | warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
|
7539 | };
|
7540 |
|
7541 | var warnInvalidHookAccess = function () {
|
7542 | warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
|
7543 | };
|
7544 |
|
7545 | HooksDispatcherOnMountInDEV = {
|
7546 | readContext: function (context, observedBits) {
|
7547 | return readContext(context, observedBits);
|
7548 | },
|
7549 | useCallback: function (callback, deps) {
|
7550 | currentHookNameInDev = 'useCallback';
|
7551 | mountHookTypesDev();
|
7552 | checkDepsAreArrayDev(deps);
|
7553 | return mountCallback(callback, deps);
|
7554 | },
|
7555 | useContext: function (context, observedBits) {
|
7556 | currentHookNameInDev = 'useContext';
|
7557 | mountHookTypesDev();
|
7558 | return readContext(context, observedBits);
|
7559 | },
|
7560 | useEffect: function (create, deps) {
|
7561 | currentHookNameInDev = 'useEffect';
|
7562 | mountHookTypesDev();
|
7563 | checkDepsAreArrayDev(deps);
|
7564 | return mountEffect(create, deps);
|
7565 | },
|
7566 | useImperativeHandle: function (ref, create, deps) {
|
7567 | currentHookNameInDev = 'useImperativeHandle';
|
7568 | mountHookTypesDev();
|
7569 | checkDepsAreArrayDev(deps);
|
7570 | return mountImperativeHandle(ref, create, deps);
|
7571 | },
|
7572 | useLayoutEffect: function (create, deps) {
|
7573 | currentHookNameInDev = 'useLayoutEffect';
|
7574 | mountHookTypesDev();
|
7575 | checkDepsAreArrayDev(deps);
|
7576 | return mountLayoutEffect(create, deps);
|
7577 | },
|
7578 | useMemo: function (create, deps) {
|
7579 | currentHookNameInDev = 'useMemo';
|
7580 | mountHookTypesDev();
|
7581 | checkDepsAreArrayDev(deps);
|
7582 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7583 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7584 |
|
7585 | try {
|
7586 | return mountMemo(create, deps);
|
7587 | } finally {
|
7588 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7589 | }
|
7590 | },
|
7591 | useReducer: function (reducer, initialArg, init) {
|
7592 | currentHookNameInDev = 'useReducer';
|
7593 | mountHookTypesDev();
|
7594 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7595 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7596 |
|
7597 | try {
|
7598 | return mountReducer(reducer, initialArg, init);
|
7599 | } finally {
|
7600 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7601 | }
|
7602 | },
|
7603 | useRef: function (initialValue) {
|
7604 | currentHookNameInDev = 'useRef';
|
7605 | mountHookTypesDev();
|
7606 | return mountRef(initialValue);
|
7607 | },
|
7608 | useState: function (initialState) {
|
7609 | currentHookNameInDev = 'useState';
|
7610 | mountHookTypesDev();
|
7611 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7612 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7613 |
|
7614 | try {
|
7615 | return mountState(initialState);
|
7616 | } finally {
|
7617 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7618 | }
|
7619 | },
|
7620 | useDebugValue: function (value, formatterFn) {
|
7621 | currentHookNameInDev = 'useDebugValue';
|
7622 | mountHookTypesDev();
|
7623 | return mountDebugValue(value, formatterFn);
|
7624 | },
|
7625 | useResponder: function (responder, props) {
|
7626 | currentHookNameInDev = 'useResponder';
|
7627 | mountHookTypesDev();
|
7628 | return createResponderListener(responder, props);
|
7629 | },
|
7630 | useDeferredValue: function (value, config) {
|
7631 | currentHookNameInDev = 'useDeferredValue';
|
7632 | mountHookTypesDev();
|
7633 | return mountDeferredValue(value, config);
|
7634 | },
|
7635 | useTransition: function (config) {
|
7636 | currentHookNameInDev = 'useTransition';
|
7637 | mountHookTypesDev();
|
7638 | return mountTransition(config);
|
7639 | }
|
7640 | };
|
7641 | HooksDispatcherOnMountWithHookTypesInDEV = {
|
7642 | readContext: function (context, observedBits) {
|
7643 | return readContext(context, observedBits);
|
7644 | },
|
7645 | useCallback: function (callback, deps) {
|
7646 | currentHookNameInDev = 'useCallback';
|
7647 | updateHookTypesDev();
|
7648 | return mountCallback(callback, deps);
|
7649 | },
|
7650 | useContext: function (context, observedBits) {
|
7651 | currentHookNameInDev = 'useContext';
|
7652 | updateHookTypesDev();
|
7653 | return readContext(context, observedBits);
|
7654 | },
|
7655 | useEffect: function (create, deps) {
|
7656 | currentHookNameInDev = 'useEffect';
|
7657 | updateHookTypesDev();
|
7658 | return mountEffect(create, deps);
|
7659 | },
|
7660 | useImperativeHandle: function (ref, create, deps) {
|
7661 | currentHookNameInDev = 'useImperativeHandle';
|
7662 | updateHookTypesDev();
|
7663 | return mountImperativeHandle(ref, create, deps);
|
7664 | },
|
7665 | useLayoutEffect: function (create, deps) {
|
7666 | currentHookNameInDev = 'useLayoutEffect';
|
7667 | updateHookTypesDev();
|
7668 | return mountLayoutEffect(create, deps);
|
7669 | },
|
7670 | useMemo: function (create, deps) {
|
7671 | currentHookNameInDev = 'useMemo';
|
7672 | updateHookTypesDev();
|
7673 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7674 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7675 |
|
7676 | try {
|
7677 | return mountMemo(create, deps);
|
7678 | } finally {
|
7679 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7680 | }
|
7681 | },
|
7682 | useReducer: function (reducer, initialArg, init) {
|
7683 | currentHookNameInDev = 'useReducer';
|
7684 | updateHookTypesDev();
|
7685 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7686 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7687 |
|
7688 | try {
|
7689 | return mountReducer(reducer, initialArg, init);
|
7690 | } finally {
|
7691 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7692 | }
|
7693 | },
|
7694 | useRef: function (initialValue) {
|
7695 | currentHookNameInDev = 'useRef';
|
7696 | updateHookTypesDev();
|
7697 | return mountRef(initialValue);
|
7698 | },
|
7699 | useState: function (initialState) {
|
7700 | currentHookNameInDev = 'useState';
|
7701 | updateHookTypesDev();
|
7702 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7703 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7704 |
|
7705 | try {
|
7706 | return mountState(initialState);
|
7707 | } finally {
|
7708 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7709 | }
|
7710 | },
|
7711 | useDebugValue: function (value, formatterFn) {
|
7712 | currentHookNameInDev = 'useDebugValue';
|
7713 | updateHookTypesDev();
|
7714 | return mountDebugValue(value, formatterFn);
|
7715 | },
|
7716 | useResponder: function (responder, props) {
|
7717 | currentHookNameInDev = 'useResponder';
|
7718 | updateHookTypesDev();
|
7719 | return createResponderListener(responder, props);
|
7720 | },
|
7721 | useDeferredValue: function (value, config) {
|
7722 | currentHookNameInDev = 'useDeferredValue';
|
7723 | updateHookTypesDev();
|
7724 | return mountDeferredValue(value, config);
|
7725 | },
|
7726 | useTransition: function (config) {
|
7727 | currentHookNameInDev = 'useTransition';
|
7728 | updateHookTypesDev();
|
7729 | return mountTransition(config);
|
7730 | }
|
7731 | };
|
7732 | HooksDispatcherOnUpdateInDEV = {
|
7733 | readContext: function (context, observedBits) {
|
7734 | return readContext(context, observedBits);
|
7735 | },
|
7736 | useCallback: function (callback, deps) {
|
7737 | currentHookNameInDev = 'useCallback';
|
7738 | updateHookTypesDev();
|
7739 | return updateCallback(callback, deps);
|
7740 | },
|
7741 | useContext: function (context, observedBits) {
|
7742 | currentHookNameInDev = 'useContext';
|
7743 | updateHookTypesDev();
|
7744 | return readContext(context, observedBits);
|
7745 | },
|
7746 | useEffect: function (create, deps) {
|
7747 | currentHookNameInDev = 'useEffect';
|
7748 | updateHookTypesDev();
|
7749 | return updateEffect(create, deps);
|
7750 | },
|
7751 | useImperativeHandle: function (ref, create, deps) {
|
7752 | currentHookNameInDev = 'useImperativeHandle';
|
7753 | updateHookTypesDev();
|
7754 | return updateImperativeHandle(ref, create, deps);
|
7755 | },
|
7756 | useLayoutEffect: function (create, deps) {
|
7757 | currentHookNameInDev = 'useLayoutEffect';
|
7758 | updateHookTypesDev();
|
7759 | return updateLayoutEffect(create, deps);
|
7760 | },
|
7761 | useMemo: function (create, deps) {
|
7762 | currentHookNameInDev = 'useMemo';
|
7763 | updateHookTypesDev();
|
7764 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7765 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7766 |
|
7767 | try {
|
7768 | return updateMemo(create, deps);
|
7769 | } finally {
|
7770 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7771 | }
|
7772 | },
|
7773 | useReducer: function (reducer, initialArg, init) {
|
7774 | currentHookNameInDev = 'useReducer';
|
7775 | updateHookTypesDev();
|
7776 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7777 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7778 |
|
7779 | try {
|
7780 | return updateReducer(reducer, initialArg, init);
|
7781 | } finally {
|
7782 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7783 | }
|
7784 | },
|
7785 | useRef: function (initialValue) {
|
7786 | currentHookNameInDev = 'useRef';
|
7787 | updateHookTypesDev();
|
7788 | return updateRef(initialValue);
|
7789 | },
|
7790 | useState: function (initialState) {
|
7791 | currentHookNameInDev = 'useState';
|
7792 | updateHookTypesDev();
|
7793 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7794 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7795 |
|
7796 | try {
|
7797 | return updateState(initialState);
|
7798 | } finally {
|
7799 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7800 | }
|
7801 | },
|
7802 | useDebugValue: function (value, formatterFn) {
|
7803 | currentHookNameInDev = 'useDebugValue';
|
7804 | updateHookTypesDev();
|
7805 | return updateDebugValue(value, formatterFn);
|
7806 | },
|
7807 | useResponder: function (responder, props) {
|
7808 | currentHookNameInDev = 'useResponder';
|
7809 | updateHookTypesDev();
|
7810 | return createResponderListener(responder, props);
|
7811 | },
|
7812 | useDeferredValue: function (value, config) {
|
7813 | currentHookNameInDev = 'useDeferredValue';
|
7814 | updateHookTypesDev();
|
7815 | return updateDeferredValue(value, config);
|
7816 | },
|
7817 | useTransition: function (config) {
|
7818 | currentHookNameInDev = 'useTransition';
|
7819 | updateHookTypesDev();
|
7820 | return updateTransition(config);
|
7821 | }
|
7822 | };
|
7823 | InvalidNestedHooksDispatcherOnMountInDEV = {
|
7824 | readContext: function (context, observedBits) {
|
7825 | warnInvalidContextAccess();
|
7826 | return readContext(context, observedBits);
|
7827 | },
|
7828 | useCallback: function (callback, deps) {
|
7829 | currentHookNameInDev = 'useCallback';
|
7830 | warnInvalidHookAccess();
|
7831 | mountHookTypesDev();
|
7832 | return mountCallback(callback, deps);
|
7833 | },
|
7834 | useContext: function (context, observedBits) {
|
7835 | currentHookNameInDev = 'useContext';
|
7836 | warnInvalidHookAccess();
|
7837 | mountHookTypesDev();
|
7838 | return readContext(context, observedBits);
|
7839 | },
|
7840 | useEffect: function (create, deps) {
|
7841 | currentHookNameInDev = 'useEffect';
|
7842 | warnInvalidHookAccess();
|
7843 | mountHookTypesDev();
|
7844 | return mountEffect(create, deps);
|
7845 | },
|
7846 | useImperativeHandle: function (ref, create, deps) {
|
7847 | currentHookNameInDev = 'useImperativeHandle';
|
7848 | warnInvalidHookAccess();
|
7849 | mountHookTypesDev();
|
7850 | return mountImperativeHandle(ref, create, deps);
|
7851 | },
|
7852 | useLayoutEffect: function (create, deps) {
|
7853 | currentHookNameInDev = 'useLayoutEffect';
|
7854 | warnInvalidHookAccess();
|
7855 | mountHookTypesDev();
|
7856 | return mountLayoutEffect(create, deps);
|
7857 | },
|
7858 | useMemo: function (create, deps) {
|
7859 | currentHookNameInDev = 'useMemo';
|
7860 | warnInvalidHookAccess();
|
7861 | mountHookTypesDev();
|
7862 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7863 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7864 |
|
7865 | try {
|
7866 | return mountMemo(create, deps);
|
7867 | } finally {
|
7868 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7869 | }
|
7870 | },
|
7871 | useReducer: function (reducer, initialArg, init) {
|
7872 | currentHookNameInDev = 'useReducer';
|
7873 | warnInvalidHookAccess();
|
7874 | mountHookTypesDev();
|
7875 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7876 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7877 |
|
7878 | try {
|
7879 | return mountReducer(reducer, initialArg, init);
|
7880 | } finally {
|
7881 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7882 | }
|
7883 | },
|
7884 | useRef: function (initialValue) {
|
7885 | currentHookNameInDev = 'useRef';
|
7886 | warnInvalidHookAccess();
|
7887 | mountHookTypesDev();
|
7888 | return mountRef(initialValue);
|
7889 | },
|
7890 | useState: function (initialState) {
|
7891 | currentHookNameInDev = 'useState';
|
7892 | warnInvalidHookAccess();
|
7893 | mountHookTypesDev();
|
7894 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7895 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
7896 |
|
7897 | try {
|
7898 | return mountState(initialState);
|
7899 | } finally {
|
7900 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7901 | }
|
7902 | },
|
7903 | useDebugValue: function (value, formatterFn) {
|
7904 | currentHookNameInDev = 'useDebugValue';
|
7905 | warnInvalidHookAccess();
|
7906 | mountHookTypesDev();
|
7907 | return mountDebugValue(value, formatterFn);
|
7908 | },
|
7909 | useResponder: function (responder, props) {
|
7910 | currentHookNameInDev = 'useResponder';
|
7911 | warnInvalidHookAccess();
|
7912 | mountHookTypesDev();
|
7913 | return createResponderListener(responder, props);
|
7914 | },
|
7915 | useDeferredValue: function (value, config) {
|
7916 | currentHookNameInDev = 'useDeferredValue';
|
7917 | warnInvalidHookAccess();
|
7918 | mountHookTypesDev();
|
7919 | return mountDeferredValue(value, config);
|
7920 | },
|
7921 | useTransition: function (config) {
|
7922 | currentHookNameInDev = 'useTransition';
|
7923 | warnInvalidHookAccess();
|
7924 | mountHookTypesDev();
|
7925 | return mountTransition(config);
|
7926 | }
|
7927 | };
|
7928 | InvalidNestedHooksDispatcherOnUpdateInDEV = {
|
7929 | readContext: function (context, observedBits) {
|
7930 | warnInvalidContextAccess();
|
7931 | return readContext(context, observedBits);
|
7932 | },
|
7933 | useCallback: function (callback, deps) {
|
7934 | currentHookNameInDev = 'useCallback';
|
7935 | warnInvalidHookAccess();
|
7936 | updateHookTypesDev();
|
7937 | return updateCallback(callback, deps);
|
7938 | },
|
7939 | useContext: function (context, observedBits) {
|
7940 | currentHookNameInDev = 'useContext';
|
7941 | warnInvalidHookAccess();
|
7942 | updateHookTypesDev();
|
7943 | return readContext(context, observedBits);
|
7944 | },
|
7945 | useEffect: function (create, deps) {
|
7946 | currentHookNameInDev = 'useEffect';
|
7947 | warnInvalidHookAccess();
|
7948 | updateHookTypesDev();
|
7949 | return updateEffect(create, deps);
|
7950 | },
|
7951 | useImperativeHandle: function (ref, create, deps) {
|
7952 | currentHookNameInDev = 'useImperativeHandle';
|
7953 | warnInvalidHookAccess();
|
7954 | updateHookTypesDev();
|
7955 | return updateImperativeHandle(ref, create, deps);
|
7956 | },
|
7957 | useLayoutEffect: function (create, deps) {
|
7958 | currentHookNameInDev = 'useLayoutEffect';
|
7959 | warnInvalidHookAccess();
|
7960 | updateHookTypesDev();
|
7961 | return updateLayoutEffect(create, deps);
|
7962 | },
|
7963 | useMemo: function (create, deps) {
|
7964 | currentHookNameInDev = 'useMemo';
|
7965 | warnInvalidHookAccess();
|
7966 | updateHookTypesDev();
|
7967 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7968 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7969 |
|
7970 | try {
|
7971 | return updateMemo(create, deps);
|
7972 | } finally {
|
7973 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7974 | }
|
7975 | },
|
7976 | useReducer: function (reducer, initialArg, init) {
|
7977 | currentHookNameInDev = 'useReducer';
|
7978 | warnInvalidHookAccess();
|
7979 | updateHookTypesDev();
|
7980 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
7981 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
7982 |
|
7983 | try {
|
7984 | return updateReducer(reducer, initialArg, init);
|
7985 | } finally {
|
7986 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
7987 | }
|
7988 | },
|
7989 | useRef: function (initialValue) {
|
7990 | currentHookNameInDev = 'useRef';
|
7991 | warnInvalidHookAccess();
|
7992 | updateHookTypesDev();
|
7993 | return updateRef(initialValue);
|
7994 | },
|
7995 | useState: function (initialState) {
|
7996 | currentHookNameInDev = 'useState';
|
7997 | warnInvalidHookAccess();
|
7998 | updateHookTypesDev();
|
7999 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8000 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
8001 |
|
8002 | try {
|
8003 | return updateState(initialState);
|
8004 | } finally {
|
8005 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8006 | }
|
8007 | },
|
8008 | useDebugValue: function (value, formatterFn) {
|
8009 | currentHookNameInDev = 'useDebugValue';
|
8010 | warnInvalidHookAccess();
|
8011 | updateHookTypesDev();
|
8012 | return updateDebugValue(value, formatterFn);
|
8013 | },
|
8014 | useResponder: function (responder, props) {
|
8015 | currentHookNameInDev = 'useResponder';
|
8016 | warnInvalidHookAccess();
|
8017 | updateHookTypesDev();
|
8018 | return createResponderListener(responder, props);
|
8019 | },
|
8020 | useDeferredValue: function (value, config) {
|
8021 | currentHookNameInDev = 'useDeferredValue';
|
8022 | warnInvalidHookAccess();
|
8023 | updateHookTypesDev();
|
8024 | return updateDeferredValue(value, config);
|
8025 | },
|
8026 | useTransition: function (config) {
|
8027 | currentHookNameInDev = 'useTransition';
|
8028 | warnInvalidHookAccess();
|
8029 | updateHookTypesDev();
|
8030 | return updateTransition(config);
|
8031 | }
|
8032 | };
|
8033 | }
|
8034 |
|
8035 |
|
8036 |
|
8037 | var now$1 = unstable_now;
|
8038 | var commitTime = 0;
|
8039 | var profilerStartTime = -1;
|
8040 |
|
8041 | function getCommitTime() {
|
8042 | return commitTime;
|
8043 | }
|
8044 |
|
8045 | function recordCommitTime() {
|
8046 | if (!enableProfilerTimer) {
|
8047 | return;
|
8048 | }
|
8049 |
|
8050 | commitTime = now$1();
|
8051 | }
|
8052 |
|
8053 | function startProfilerTimer(fiber) {
|
8054 | if (!enableProfilerTimer) {
|
8055 | return;
|
8056 | }
|
8057 |
|
8058 | profilerStartTime = now$1();
|
8059 |
|
8060 | if (fiber.actualStartTime < 0) {
|
8061 | fiber.actualStartTime = now$1();
|
8062 | }
|
8063 | }
|
8064 |
|
8065 | function stopProfilerTimerIfRunning(fiber) {
|
8066 | if (!enableProfilerTimer) {
|
8067 | return;
|
8068 | }
|
8069 |
|
8070 | profilerStartTime = -1;
|
8071 | }
|
8072 |
|
8073 | function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
|
8074 | if (!enableProfilerTimer) {
|
8075 | return;
|
8076 | }
|
8077 |
|
8078 | if (profilerStartTime >= 0) {
|
8079 | var elapsedTime = now$1() - profilerStartTime;
|
8080 | fiber.actualDuration += elapsedTime;
|
8081 |
|
8082 | if (overrideBaseTime) {
|
8083 | fiber.selfBaseDuration = elapsedTime;
|
8084 | }
|
8085 |
|
8086 | profilerStartTime = -1;
|
8087 | }
|
8088 | }
|
8089 |
|
8090 |
|
8091 |
|
8092 | var hydrationParentFiber = null;
|
8093 | var nextHydratableInstance = null;
|
8094 | var isHydrating = false;
|
8095 |
|
8096 | function warnIfHydrating() {
|
8097 | {
|
8098 | !!isHydrating ? warning$1(false, 'We should not be hydrating here. This is a bug in React. Please file a bug.') : void 0;
|
8099 | }
|
8100 | }
|
8101 |
|
8102 | function enterHydrationState(fiber) {
|
8103 | if (!supportsHydration) {
|
8104 | return false;
|
8105 | }
|
8106 |
|
8107 | var parentInstance = fiber.stateNode.containerInfo;
|
8108 | nextHydratableInstance = getFirstHydratableChild(parentInstance);
|
8109 | hydrationParentFiber = fiber;
|
8110 | isHydrating = true;
|
8111 | return true;
|
8112 | }
|
8113 |
|
8114 | function reenterHydrationStateFromDehydratedSuspenseInstance(fiber, suspenseInstance) {
|
8115 | if (!supportsHydration) {
|
8116 | return false;
|
8117 | }
|
8118 |
|
8119 | nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
|
8120 | popToNextHostParent(fiber);
|
8121 | isHydrating = true;
|
8122 | return true;
|
8123 | }
|
8124 |
|
8125 | function deleteHydratableInstance(returnFiber, instance) {
|
8126 | {
|
8127 | switch (returnFiber.tag) {
|
8128 | case HostRoot:
|
8129 | didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
|
8130 | break;
|
8131 |
|
8132 | case HostComponent:
|
8133 | didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
|
8134 | break;
|
8135 | }
|
8136 | }
|
8137 |
|
8138 | var childToDelete = createFiberFromHostInstanceForDeletion();
|
8139 | childToDelete.stateNode = instance;
|
8140 | childToDelete.return = returnFiber;
|
8141 | childToDelete.effectTag = Deletion;
|
8142 |
|
8143 |
|
8144 |
|
8145 |
|
8146 |
|
8147 | if (returnFiber.lastEffect !== null) {
|
8148 | returnFiber.lastEffect.nextEffect = childToDelete;
|
8149 | returnFiber.lastEffect = childToDelete;
|
8150 | } else {
|
8151 | returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
8152 | }
|
8153 | }
|
8154 |
|
8155 | function insertNonHydratedInstance(returnFiber, fiber) {
|
8156 | fiber.effectTag = fiber.effectTag & ~Hydrating | Placement;
|
8157 |
|
8158 | {
|
8159 | switch (returnFiber.tag) {
|
8160 | case HostRoot:
|
8161 | {
|
8162 | var parentContainer = returnFiber.stateNode.containerInfo;
|
8163 |
|
8164 | switch (fiber.tag) {
|
8165 | case HostComponent:
|
8166 | var type = fiber.type;
|
8167 | var props = fiber.pendingProps;
|
8168 | didNotFindHydratableContainerInstance(parentContainer, type, props);
|
8169 | break;
|
8170 |
|
8171 | case HostText:
|
8172 | var text = fiber.pendingProps;
|
8173 | didNotFindHydratableContainerTextInstance(parentContainer, text);
|
8174 | break;
|
8175 |
|
8176 | case SuspenseComponent:
|
8177 | didNotFindHydratableContainerSuspenseInstance(parentContainer);
|
8178 | break;
|
8179 | }
|
8180 |
|
8181 | break;
|
8182 | }
|
8183 |
|
8184 | case HostComponent:
|
8185 | {
|
8186 | var parentType = returnFiber.type;
|
8187 | var parentProps = returnFiber.memoizedProps;
|
8188 | var parentInstance = returnFiber.stateNode;
|
8189 |
|
8190 | switch (fiber.tag) {
|
8191 | case HostComponent:
|
8192 | var _type = fiber.type;
|
8193 | var _props = fiber.pendingProps;
|
8194 | didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
|
8195 | break;
|
8196 |
|
8197 | case HostText:
|
8198 | var _text = fiber.pendingProps;
|
8199 | didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
|
8200 | break;
|
8201 |
|
8202 | case SuspenseComponent:
|
8203 | didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
|
8204 | break;
|
8205 | }
|
8206 |
|
8207 | break;
|
8208 | }
|
8209 |
|
8210 | default:
|
8211 | return;
|
8212 | }
|
8213 | }
|
8214 | }
|
8215 |
|
8216 | function tryHydrate(fiber, nextInstance) {
|
8217 | switch (fiber.tag) {
|
8218 | case HostComponent:
|
8219 | {
|
8220 | var type = fiber.type;
|
8221 | var props = fiber.pendingProps;
|
8222 | var instance = canHydrateInstance(nextInstance, type, props);
|
8223 |
|
8224 | if (instance !== null) {
|
8225 | fiber.stateNode = instance;
|
8226 | return true;
|
8227 | }
|
8228 |
|
8229 | return false;
|
8230 | }
|
8231 |
|
8232 | case HostText:
|
8233 | {
|
8234 | var text = fiber.pendingProps;
|
8235 | var textInstance = canHydrateTextInstance(nextInstance, text);
|
8236 |
|
8237 | if (textInstance !== null) {
|
8238 | fiber.stateNode = textInstance;
|
8239 | return true;
|
8240 | }
|
8241 |
|
8242 | return false;
|
8243 | }
|
8244 |
|
8245 | case SuspenseComponent:
|
8246 | {
|
8247 | if (enableSuspenseServerRenderer) {
|
8248 | var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
|
8249 |
|
8250 | if (suspenseInstance !== null) {
|
8251 | var suspenseState = {
|
8252 | dehydrated: suspenseInstance,
|
8253 | retryTime: Never
|
8254 | };
|
8255 | fiber.memoizedState = suspenseState;
|
8256 |
|
8257 |
|
8258 |
|
8259 |
|
8260 | var dehydratedFragment = createFiberFromDehydratedFragment(suspenseInstance);
|
8261 | dehydratedFragment.return = fiber;
|
8262 | fiber.child = dehydratedFragment;
|
8263 | return true;
|
8264 | }
|
8265 | }
|
8266 |
|
8267 | return false;
|
8268 | }
|
8269 |
|
8270 | default:
|
8271 | return false;
|
8272 | }
|
8273 | }
|
8274 |
|
8275 | function tryToClaimNextHydratableInstance(fiber) {
|
8276 | if (!isHydrating) {
|
8277 | return;
|
8278 | }
|
8279 |
|
8280 | var nextInstance = nextHydratableInstance;
|
8281 |
|
8282 | if (!nextInstance) {
|
8283 |
|
8284 | insertNonHydratedInstance(hydrationParentFiber, fiber);
|
8285 | isHydrating = false;
|
8286 | hydrationParentFiber = fiber;
|
8287 | return;
|
8288 | }
|
8289 |
|
8290 | var firstAttemptedInstance = nextInstance;
|
8291 |
|
8292 | if (!tryHydrate(fiber, nextInstance)) {
|
8293 |
|
8294 |
|
8295 |
|
8296 | nextInstance = getNextHydratableSibling(firstAttemptedInstance);
|
8297 |
|
8298 | if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
|
8299 |
|
8300 | insertNonHydratedInstance(hydrationParentFiber, fiber);
|
8301 | isHydrating = false;
|
8302 | hydrationParentFiber = fiber;
|
8303 | return;
|
8304 | }
|
8305 |
|
8306 |
|
8307 |
|
8308 |
|
8309 |
|
8310 | deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
|
8311 | }
|
8312 |
|
8313 | hydrationParentFiber = fiber;
|
8314 | nextHydratableInstance = getFirstHydratableChild(nextInstance);
|
8315 | }
|
8316 |
|
8317 | function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
|
8318 | if (!supportsHydration) {
|
8319 | {
|
8320 | {
|
8321 | throw Error("Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
|
8322 | }
|
8323 | }
|
8324 | }
|
8325 |
|
8326 | var instance = fiber.stateNode;
|
8327 | var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
|
8328 |
|
8329 | fiber.updateQueue = updatePayload;
|
8330 |
|
8331 |
|
8332 | if (updatePayload !== null) {
|
8333 | return true;
|
8334 | }
|
8335 |
|
8336 | return false;
|
8337 | }
|
8338 |
|
8339 | function prepareToHydrateHostTextInstance(fiber) {
|
8340 | if (!supportsHydration) {
|
8341 | {
|
8342 | {
|
8343 | throw Error("Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
|
8344 | }
|
8345 | }
|
8346 | }
|
8347 |
|
8348 | var textInstance = fiber.stateNode;
|
8349 | var textContent = fiber.memoizedProps;
|
8350 | var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
|
8351 |
|
8352 | {
|
8353 | if (shouldUpdate) {
|
8354 |
|
8355 |
|
8356 | var returnFiber = hydrationParentFiber;
|
8357 |
|
8358 | if (returnFiber !== null) {
|
8359 | switch (returnFiber.tag) {
|
8360 | case HostRoot:
|
8361 | {
|
8362 | var parentContainer = returnFiber.stateNode.containerInfo;
|
8363 | didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
|
8364 | break;
|
8365 | }
|
8366 |
|
8367 | case HostComponent:
|
8368 | {
|
8369 | var parentType = returnFiber.type;
|
8370 | var parentProps = returnFiber.memoizedProps;
|
8371 | var parentInstance = returnFiber.stateNode;
|
8372 | didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
|
8373 | break;
|
8374 | }
|
8375 | }
|
8376 | }
|
8377 | }
|
8378 | }
|
8379 |
|
8380 | return shouldUpdate;
|
8381 | }
|
8382 |
|
8383 | function prepareToHydrateHostSuspenseInstance(fiber) {
|
8384 | if (!supportsHydration) {
|
8385 | {
|
8386 | {
|
8387 | throw Error("Expected prepareToHydrateHostSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
|
8388 | }
|
8389 | }
|
8390 | }
|
8391 |
|
8392 | var suspenseState = fiber.memoizedState;
|
8393 | var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
|
8394 |
|
8395 | if (!suspenseInstance) {
|
8396 | {
|
8397 | throw Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
|
8398 | }
|
8399 | }
|
8400 |
|
8401 | hydrateSuspenseInstance(suspenseInstance, fiber);
|
8402 | }
|
8403 |
|
8404 | function skipPastDehydratedSuspenseInstance(fiber) {
|
8405 | if (!supportsHydration) {
|
8406 | {
|
8407 | {
|
8408 | throw Error("Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
|
8409 | }
|
8410 | }
|
8411 | }
|
8412 |
|
8413 | var suspenseState = fiber.memoizedState;
|
8414 | var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
|
8415 |
|
8416 | if (!suspenseInstance) {
|
8417 | {
|
8418 | throw Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
|
8419 | }
|
8420 | }
|
8421 |
|
8422 | return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
|
8423 | }
|
8424 |
|
8425 | function popToNextHostParent(fiber) {
|
8426 | var parent = fiber.return;
|
8427 |
|
8428 | while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
|
8429 | parent = parent.return;
|
8430 | }
|
8431 |
|
8432 | hydrationParentFiber = parent;
|
8433 | }
|
8434 |
|
8435 | function popHydrationState(fiber) {
|
8436 | if (!supportsHydration) {
|
8437 | return false;
|
8438 | }
|
8439 |
|
8440 | if (fiber !== hydrationParentFiber) {
|
8441 |
|
8442 |
|
8443 | return false;
|
8444 | }
|
8445 |
|
8446 | if (!isHydrating) {
|
8447 |
|
8448 |
|
8449 |
|
8450 | popToNextHostParent(fiber);
|
8451 | isHydrating = true;
|
8452 | return false;
|
8453 | }
|
8454 |
|
8455 | var type = fiber.type;
|
8456 |
|
8457 |
|
8458 |
|
8459 |
|
8460 |
|
8461 | if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
|
8462 | var nextInstance = nextHydratableInstance;
|
8463 |
|
8464 | while (nextInstance) {
|
8465 | deleteHydratableInstance(fiber, nextInstance);
|
8466 | nextInstance = getNextHydratableSibling(nextInstance);
|
8467 | }
|
8468 | }
|
8469 |
|
8470 | popToNextHostParent(fiber);
|
8471 |
|
8472 | if (fiber.tag === SuspenseComponent) {
|
8473 | nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
|
8474 | } else {
|
8475 | nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
|
8476 | }
|
8477 |
|
8478 | return true;
|
8479 | }
|
8480 |
|
8481 | function resetHydrationState() {
|
8482 | if (!supportsHydration) {
|
8483 | return;
|
8484 | }
|
8485 |
|
8486 | hydrationParentFiber = null;
|
8487 | nextHydratableInstance = null;
|
8488 | isHydrating = false;
|
8489 | }
|
8490 |
|
8491 | var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
|
8492 | var didReceiveUpdate = false;
|
8493 | var didWarnAboutBadClass;
|
8494 | var didWarnAboutModulePatternComponent;
|
8495 | var didWarnAboutContextTypeOnFunctionComponent;
|
8496 | var didWarnAboutGetDerivedStateOnFunctionComponent;
|
8497 | var didWarnAboutFunctionRefs;
|
8498 | var didWarnAboutReassigningProps;
|
8499 | var didWarnAboutMaxDuration;
|
8500 | var didWarnAboutRevealOrder;
|
8501 | var didWarnAboutTailOptions;
|
8502 | var didWarnAboutDefaultPropsOnFunctionComponent;
|
8503 |
|
8504 | {
|
8505 | didWarnAboutBadClass = {};
|
8506 | didWarnAboutModulePatternComponent = {};
|
8507 | didWarnAboutContextTypeOnFunctionComponent = {};
|
8508 | didWarnAboutGetDerivedStateOnFunctionComponent = {};
|
8509 | didWarnAboutFunctionRefs = {};
|
8510 | didWarnAboutReassigningProps = false;
|
8511 | didWarnAboutMaxDuration = false;
|
8512 | didWarnAboutRevealOrder = {};
|
8513 | didWarnAboutTailOptions = {};
|
8514 | didWarnAboutDefaultPropsOnFunctionComponent = {};
|
8515 | }
|
8516 |
|
8517 | function reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime) {
|
8518 | if (current === null) {
|
8519 |
|
8520 |
|
8521 |
|
8522 |
|
8523 | workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
8524 | } else {
|
8525 |
|
8526 |
|
8527 |
|
8528 |
|
8529 |
|
8530 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime);
|
8531 | }
|
8532 | }
|
8533 |
|
8534 | function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime) {
|
8535 |
|
8536 |
|
8537 |
|
8538 |
|
8539 |
|
8540 |
|
8541 |
|
8542 |
|
8543 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderExpirationTime);
|
8544 |
|
8545 |
|
8546 |
|
8547 |
|
8548 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
8549 | }
|
8550 |
|
8551 | function updateForwardRef(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
8552 |
|
8553 |
|
8554 |
|
8555 | {
|
8556 | if (workInProgress.type !== workInProgress.elementType) {
|
8557 |
|
8558 |
|
8559 | var innerPropTypes = Component.propTypes;
|
8560 |
|
8561 | if (innerPropTypes) {
|
8562 | checkPropTypes_1(innerPropTypes, nextProps,
|
8563 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
8564 | }
|
8565 | }
|
8566 | }
|
8567 |
|
8568 | var render = Component.render;
|
8569 | var ref = workInProgress.ref;
|
8570 |
|
8571 | var nextChildren;
|
8572 | prepareToReadContext(workInProgress, renderExpirationTime);
|
8573 |
|
8574 | {
|
8575 | ReactCurrentOwner$2.current = workInProgress;
|
8576 | setCurrentPhase('render');
|
8577 | nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime);
|
8578 |
|
8579 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
8580 |
|
8581 | if (workInProgress.memoizedState !== null) {
|
8582 | nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime);
|
8583 | }
|
8584 | }
|
8585 |
|
8586 | setCurrentPhase(null);
|
8587 | }
|
8588 |
|
8589 | if (current !== null && !didReceiveUpdate) {
|
8590 | bailoutHooks(current, workInProgress, renderExpirationTime);
|
8591 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8592 | }
|
8593 |
|
8594 |
|
8595 | workInProgress.effectTag |= PerformedWork;
|
8596 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
8597 | return workInProgress.child;
|
8598 | }
|
8599 |
|
8600 | function updateMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
|
8601 | if (current === null) {
|
8602 | var type = Component.type;
|
8603 |
|
8604 | if (isSimpleFunctionComponent(type) && Component.compare === null &&
|
8605 | Component.defaultProps === undefined) {
|
8606 | var resolvedType = type;
|
8607 |
|
8608 | {
|
8609 | resolvedType = resolveFunctionForHotReloading(type);
|
8610 | }
|
8611 |
|
8612 |
|
8613 |
|
8614 |
|
8615 | workInProgress.tag = SimpleMemoComponent;
|
8616 | workInProgress.type = resolvedType;
|
8617 |
|
8618 | {
|
8619 | validateFunctionComponentInDev(workInProgress, type);
|
8620 | }
|
8621 |
|
8622 | return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
|
8623 | }
|
8624 |
|
8625 | {
|
8626 | var innerPropTypes = type.propTypes;
|
8627 |
|
8628 | if (innerPropTypes) {
|
8629 |
|
8630 |
|
8631 | checkPropTypes_1(innerPropTypes, nextProps,
|
8632 | 'prop', getComponentName(type), getCurrentFiberStackInDev);
|
8633 | }
|
8634 | }
|
8635 |
|
8636 | var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
|
8637 | child.ref = workInProgress.ref;
|
8638 | child.return = workInProgress;
|
8639 | workInProgress.child = child;
|
8640 | return child;
|
8641 | }
|
8642 |
|
8643 | {
|
8644 | var _type = Component.type;
|
8645 | var _innerPropTypes = _type.propTypes;
|
8646 |
|
8647 | if (_innerPropTypes) {
|
8648 |
|
8649 |
|
8650 | checkPropTypes_1(_innerPropTypes, nextProps,
|
8651 | 'prop', getComponentName(_type), getCurrentFiberStackInDev);
|
8652 | }
|
8653 | }
|
8654 |
|
8655 | var currentChild = current.child;
|
8656 |
|
8657 | if (updateExpirationTime < renderExpirationTime) {
|
8658 |
|
8659 |
|
8660 | var prevProps = currentChild.memoizedProps;
|
8661 |
|
8662 | var compare = Component.compare;
|
8663 | compare = compare !== null ? compare : shallowEqual;
|
8664 |
|
8665 | if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
|
8666 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8667 | }
|
8668 | }
|
8669 |
|
8670 |
|
8671 | workInProgress.effectTag |= PerformedWork;
|
8672 | var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
|
8673 | newChild.ref = workInProgress.ref;
|
8674 | newChild.return = workInProgress;
|
8675 | workInProgress.child = newChild;
|
8676 | return newChild;
|
8677 | }
|
8678 |
|
8679 | function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
|
8680 |
|
8681 |
|
8682 |
|
8683 | {
|
8684 | if (workInProgress.type !== workInProgress.elementType) {
|
8685 |
|
8686 |
|
8687 | var outerMemoType = workInProgress.elementType;
|
8688 |
|
8689 | if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
|
8690 |
|
8691 |
|
8692 |
|
8693 | outerMemoType = refineResolvedLazyComponent(outerMemoType);
|
8694 | }
|
8695 |
|
8696 | var outerPropTypes = outerMemoType && outerMemoType.propTypes;
|
8697 |
|
8698 | if (outerPropTypes) {
|
8699 | checkPropTypes_1(outerPropTypes, nextProps,
|
8700 | 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
|
8701 | }
|
8702 |
|
8703 | }
|
8704 | }
|
8705 |
|
8706 | if (current !== null) {
|
8707 | var prevProps = current.memoizedProps;
|
8708 |
|
8709 | if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && (
|
8710 | workInProgress.type === current.type)) {
|
8711 | didReceiveUpdate = false;
|
8712 |
|
8713 | if (updateExpirationTime < renderExpirationTime) {
|
8714 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8715 | }
|
8716 | }
|
8717 | }
|
8718 |
|
8719 | return updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime);
|
8720 | }
|
8721 |
|
8722 | function updateFragment(current, workInProgress, renderExpirationTime) {
|
8723 | var nextChildren = workInProgress.pendingProps;
|
8724 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
8725 | return workInProgress.child;
|
8726 | }
|
8727 |
|
8728 | function updateMode(current, workInProgress, renderExpirationTime) {
|
8729 | var nextChildren = workInProgress.pendingProps.children;
|
8730 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
8731 | return workInProgress.child;
|
8732 | }
|
8733 |
|
8734 | function updateProfiler(current, workInProgress, renderExpirationTime) {
|
8735 | if (enableProfilerTimer) {
|
8736 | workInProgress.effectTag |= Update;
|
8737 | }
|
8738 |
|
8739 | var nextProps = workInProgress.pendingProps;
|
8740 | var nextChildren = nextProps.children;
|
8741 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
8742 | return workInProgress.child;
|
8743 | }
|
8744 |
|
8745 | function markRef(current, workInProgress) {
|
8746 | var ref = workInProgress.ref;
|
8747 |
|
8748 | if (current === null && ref !== null || current !== null && current.ref !== ref) {
|
8749 |
|
8750 | workInProgress.effectTag |= Ref;
|
8751 | }
|
8752 | }
|
8753 |
|
8754 | function updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
8755 | {
|
8756 | if (workInProgress.type !== workInProgress.elementType) {
|
8757 |
|
8758 |
|
8759 | var innerPropTypes = Component.propTypes;
|
8760 |
|
8761 | if (innerPropTypes) {
|
8762 | checkPropTypes_1(innerPropTypes, nextProps,
|
8763 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
8764 | }
|
8765 | }
|
8766 | }
|
8767 |
|
8768 | var context;
|
8769 |
|
8770 | if (!disableLegacyContext) {
|
8771 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
|
8772 | context = getMaskedContext(workInProgress, unmaskedContext);
|
8773 | }
|
8774 |
|
8775 | var nextChildren;
|
8776 | prepareToReadContext(workInProgress, renderExpirationTime);
|
8777 |
|
8778 | {
|
8779 | ReactCurrentOwner$2.current = workInProgress;
|
8780 | setCurrentPhase('render');
|
8781 | nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime);
|
8782 |
|
8783 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
8784 |
|
8785 | if (workInProgress.memoizedState !== null) {
|
8786 | nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime);
|
8787 | }
|
8788 | }
|
8789 |
|
8790 | setCurrentPhase(null);
|
8791 | }
|
8792 |
|
8793 | if (current !== null && !didReceiveUpdate) {
|
8794 | bailoutHooks(current, workInProgress, renderExpirationTime);
|
8795 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8796 | }
|
8797 |
|
8798 |
|
8799 | workInProgress.effectTag |= PerformedWork;
|
8800 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
8801 | return workInProgress.child;
|
8802 | }
|
8803 |
|
8804 | function updateClassComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
8805 | {
|
8806 | if (workInProgress.type !== workInProgress.elementType) {
|
8807 |
|
8808 |
|
8809 | var innerPropTypes = Component.propTypes;
|
8810 |
|
8811 | if (innerPropTypes) {
|
8812 | checkPropTypes_1(innerPropTypes, nextProps,
|
8813 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
8814 | }
|
8815 | }
|
8816 | }
|
8817 |
|
8818 |
|
8819 |
|
8820 |
|
8821 | var hasContext;
|
8822 |
|
8823 | if (isContextProvider(Component)) {
|
8824 | hasContext = true;
|
8825 | pushContextProvider(workInProgress);
|
8826 | } else {
|
8827 | hasContext = false;
|
8828 | }
|
8829 |
|
8830 | prepareToReadContext(workInProgress, renderExpirationTime);
|
8831 | var instance = workInProgress.stateNode;
|
8832 | var shouldUpdate;
|
8833 |
|
8834 | if (instance === null) {
|
8835 | if (current !== null) {
|
8836 |
|
8837 |
|
8838 |
|
8839 |
|
8840 | current.alternate = null;
|
8841 | workInProgress.alternate = null;
|
8842 |
|
8843 | workInProgress.effectTag |= Placement;
|
8844 | }
|
8845 |
|
8846 |
|
8847 | constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
8848 | mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
8849 | shouldUpdate = true;
|
8850 | } else if (current === null) {
|
8851 |
|
8852 | shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
8853 | } else {
|
8854 | shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderExpirationTime);
|
8855 | }
|
8856 |
|
8857 | var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
|
8858 |
|
8859 | {
|
8860 | var inst = workInProgress.stateNode;
|
8861 |
|
8862 | if (inst.props !== nextProps) {
|
8863 | !didWarnAboutReassigningProps ? warning$1(false, 'It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component') : void 0;
|
8864 | didWarnAboutReassigningProps = true;
|
8865 | }
|
8866 | }
|
8867 |
|
8868 | return nextUnitOfWork;
|
8869 | }
|
8870 |
|
8871 | function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
|
8872 |
|
8873 | markRef(current, workInProgress);
|
8874 | var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
|
8875 |
|
8876 | if (!shouldUpdate && !didCaptureError) {
|
8877 |
|
8878 | if (hasContext) {
|
8879 | invalidateContextProvider(workInProgress, Component, false);
|
8880 | }
|
8881 |
|
8882 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8883 | }
|
8884 |
|
8885 | var instance = workInProgress.stateNode;
|
8886 |
|
8887 | ReactCurrentOwner$2.current = workInProgress;
|
8888 | var nextChildren;
|
8889 |
|
8890 | if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
|
8891 |
|
8892 |
|
8893 |
|
8894 |
|
8895 |
|
8896 | nextChildren = null;
|
8897 |
|
8898 | if (enableProfilerTimer) {
|
8899 | stopProfilerTimerIfRunning(workInProgress);
|
8900 | }
|
8901 | } else {
|
8902 | {
|
8903 | setCurrentPhase('render');
|
8904 | nextChildren = instance.render();
|
8905 |
|
8906 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
8907 | instance.render();
|
8908 | }
|
8909 |
|
8910 | setCurrentPhase(null);
|
8911 | }
|
8912 | }
|
8913 |
|
8914 |
|
8915 | workInProgress.effectTag |= PerformedWork;
|
8916 |
|
8917 | if (current !== null && didCaptureError) {
|
8918 |
|
8919 |
|
8920 |
|
8921 |
|
8922 | forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime);
|
8923 | } else {
|
8924 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
8925 | }
|
8926 |
|
8927 |
|
8928 |
|
8929 | workInProgress.memoizedState = instance.state;
|
8930 |
|
8931 | if (hasContext) {
|
8932 | invalidateContextProvider(workInProgress, Component, true);
|
8933 | }
|
8934 |
|
8935 | return workInProgress.child;
|
8936 | }
|
8937 |
|
8938 | function pushHostRootContext(workInProgress) {
|
8939 | var root = workInProgress.stateNode;
|
8940 |
|
8941 | if (root.pendingContext) {
|
8942 | pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
|
8943 | } else if (root.context) {
|
8944 |
|
8945 | pushTopLevelContextObject(workInProgress, root.context, false);
|
8946 | }
|
8947 |
|
8948 | pushHostContainer(workInProgress, root.containerInfo);
|
8949 | }
|
8950 |
|
8951 | function updateHostRoot(current, workInProgress, renderExpirationTime) {
|
8952 | pushHostRootContext(workInProgress);
|
8953 | var updateQueue = workInProgress.updateQueue;
|
8954 |
|
8955 | if (!(updateQueue !== null)) {
|
8956 | {
|
8957 | throw Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.");
|
8958 | }
|
8959 | }
|
8960 |
|
8961 | var nextProps = workInProgress.pendingProps;
|
8962 | var prevState = workInProgress.memoizedState;
|
8963 | var prevChildren = prevState !== null ? prevState.element : null;
|
8964 | processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
|
8965 | var nextState = workInProgress.memoizedState;
|
8966 |
|
8967 |
|
8968 | var nextChildren = nextState.element;
|
8969 |
|
8970 | if (nextChildren === prevChildren) {
|
8971 |
|
8972 |
|
8973 | resetHydrationState();
|
8974 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8975 | }
|
8976 |
|
8977 | var root = workInProgress.stateNode;
|
8978 |
|
8979 | if (root.hydrate && enterHydrationState(workInProgress)) {
|
8980 |
|
8981 |
|
8982 |
|
8983 |
|
8984 | var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
8985 | workInProgress.child = child;
|
8986 | var node = child;
|
8987 |
|
8988 | while (node) {
|
8989 |
|
8990 |
|
8991 |
|
8992 |
|
8993 |
|
8994 |
|
8995 | node.effectTag = node.effectTag & ~Placement | Hydrating;
|
8996 | node = node.sibling;
|
8997 | }
|
8998 | } else {
|
8999 |
|
9000 |
|
9001 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
9002 | resetHydrationState();
|
9003 | }
|
9004 |
|
9005 | return workInProgress.child;
|
9006 | }
|
9007 |
|
9008 | function updateHostComponent(current, workInProgress, renderExpirationTime) {
|
9009 | pushHostContext(workInProgress);
|
9010 |
|
9011 | if (current === null) {
|
9012 | tryToClaimNextHydratableInstance(workInProgress);
|
9013 | }
|
9014 |
|
9015 | var type = workInProgress.type;
|
9016 | var nextProps = workInProgress.pendingProps;
|
9017 | var prevProps = current !== null ? current.memoizedProps : null;
|
9018 | var nextChildren = nextProps.children;
|
9019 | var isDirectTextChild = shouldSetTextContent(type, nextProps);
|
9020 |
|
9021 | if (isDirectTextChild) {
|
9022 |
|
9023 |
|
9024 |
|
9025 |
|
9026 | nextChildren = null;
|
9027 | } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
|
9028 |
|
9029 |
|
9030 | workInProgress.effectTag |= ContentReset;
|
9031 | }
|
9032 |
|
9033 | markRef(current, workInProgress);
|
9034 |
|
9035 | if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
|
9036 | if (enableSchedulerTracing) {
|
9037 | markSpawnedWork(Never);
|
9038 | }
|
9039 |
|
9040 |
|
9041 | workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
|
9042 | return null;
|
9043 | }
|
9044 |
|
9045 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
9046 | return workInProgress.child;
|
9047 | }
|
9048 |
|
9049 | function updateHostText(current, workInProgress) {
|
9050 | if (current === null) {
|
9051 | tryToClaimNextHydratableInstance(workInProgress);
|
9052 | }
|
9053 |
|
9054 |
|
9055 |
|
9056 | return null;
|
9057 | }
|
9058 |
|
9059 | function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
|
9060 | if (_current !== null) {
|
9061 |
|
9062 |
|
9063 |
|
9064 |
|
9065 | _current.alternate = null;
|
9066 | workInProgress.alternate = null;
|
9067 |
|
9068 | workInProgress.effectTag |= Placement;
|
9069 | }
|
9070 |
|
9071 | var props = workInProgress.pendingProps;
|
9072 |
|
9073 |
|
9074 | cancelWorkTimer(workInProgress);
|
9075 | var Component = readLazyComponentType(elementType);
|
9076 |
|
9077 | workInProgress.type = Component;
|
9078 | var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
|
9079 | startWorkTimer(workInProgress);
|
9080 | var resolvedProps = resolveDefaultProps(Component, props);
|
9081 | var child;
|
9082 |
|
9083 | switch (resolvedTag) {
|
9084 | case FunctionComponent:
|
9085 | {
|
9086 | {
|
9087 | validateFunctionComponentInDev(workInProgress, Component);
|
9088 | workInProgress.type = Component = resolveFunctionForHotReloading(Component);
|
9089 | }
|
9090 |
|
9091 | child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
9092 | break;
|
9093 | }
|
9094 |
|
9095 | case ClassComponent:
|
9096 | {
|
9097 | {
|
9098 | workInProgress.type = Component = resolveClassForHotReloading(Component);
|
9099 | }
|
9100 |
|
9101 | child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
9102 | break;
|
9103 | }
|
9104 |
|
9105 | case ForwardRef:
|
9106 | {
|
9107 | {
|
9108 | workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
|
9109 | }
|
9110 |
|
9111 | child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
9112 | break;
|
9113 | }
|
9114 |
|
9115 | case MemoComponent:
|
9116 | {
|
9117 | {
|
9118 | if (workInProgress.type !== workInProgress.elementType) {
|
9119 | var outerPropTypes = Component.propTypes;
|
9120 |
|
9121 | if (outerPropTypes) {
|
9122 | checkPropTypes_1(outerPropTypes, resolvedProps,
|
9123 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
9124 | }
|
9125 | }
|
9126 | }
|
9127 |
|
9128 | child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps),
|
9129 | updateExpirationTime, renderExpirationTime);
|
9130 | break;
|
9131 | }
|
9132 |
|
9133 | default:
|
9134 | {
|
9135 | var hint = '';
|
9136 |
|
9137 | {
|
9138 | if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
|
9139 | hint = ' Did you wrap a component in React.lazy() more than once?';
|
9140 | }
|
9141 | }
|
9142 |
|
9143 |
|
9144 |
|
9145 |
|
9146 | {
|
9147 | {
|
9148 | throw Error("Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint);
|
9149 | }
|
9150 | }
|
9151 | }
|
9152 | }
|
9153 |
|
9154 | return child;
|
9155 | }
|
9156 |
|
9157 | function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
|
9158 | if (_current !== null) {
|
9159 |
|
9160 |
|
9161 |
|
9162 |
|
9163 | _current.alternate = null;
|
9164 | workInProgress.alternate = null;
|
9165 |
|
9166 | workInProgress.effectTag |= Placement;
|
9167 | }
|
9168 |
|
9169 |
|
9170 | workInProgress.tag = ClassComponent;
|
9171 |
|
9172 |
|
9173 |
|
9174 |
|
9175 | var hasContext;
|
9176 |
|
9177 | if (isContextProvider(Component)) {
|
9178 | hasContext = true;
|
9179 | pushContextProvider(workInProgress);
|
9180 | } else {
|
9181 | hasContext = false;
|
9182 | }
|
9183 |
|
9184 | prepareToReadContext(workInProgress, renderExpirationTime);
|
9185 | constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
9186 | mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
9187 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
|
9188 | }
|
9189 |
|
9190 | function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
|
9191 | if (_current !== null) {
|
9192 |
|
9193 |
|
9194 |
|
9195 |
|
9196 | _current.alternate = null;
|
9197 | workInProgress.alternate = null;
|
9198 |
|
9199 | workInProgress.effectTag |= Placement;
|
9200 | }
|
9201 |
|
9202 | var props = workInProgress.pendingProps;
|
9203 | var context;
|
9204 |
|
9205 | if (!disableLegacyContext) {
|
9206 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
|
9207 | context = getMaskedContext(workInProgress, unmaskedContext);
|
9208 | }
|
9209 |
|
9210 | prepareToReadContext(workInProgress, renderExpirationTime);
|
9211 | var value;
|
9212 |
|
9213 | {
|
9214 | if (Component.prototype && typeof Component.prototype.render === 'function') {
|
9215 | var componentName = getComponentName(Component) || 'Unknown';
|
9216 |
|
9217 | if (!didWarnAboutBadClass[componentName]) {
|
9218 | warningWithoutStack$1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
|
9219 | didWarnAboutBadClass[componentName] = true;
|
9220 | }
|
9221 | }
|
9222 |
|
9223 | if (workInProgress.mode & StrictMode) {
|
9224 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
|
9225 | }
|
9226 |
|
9227 | ReactCurrentOwner$2.current = workInProgress;
|
9228 | value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
|
9229 | }
|
9230 |
|
9231 |
|
9232 | workInProgress.effectTag |= PerformedWork;
|
9233 |
|
9234 | if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
|
9235 | {
|
9236 | var _componentName = getComponentName(Component) || 'Unknown';
|
9237 |
|
9238 | if (!didWarnAboutModulePatternComponent[_componentName]) {
|
9239 | warningWithoutStack$1(false, 'The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
|
9240 | didWarnAboutModulePatternComponent[_componentName] = true;
|
9241 | }
|
9242 | }
|
9243 |
|
9244 |
|
9245 | workInProgress.tag = ClassComponent;
|
9246 |
|
9247 | resetHooks();
|
9248 |
|
9249 |
|
9250 |
|
9251 | var hasContext = false;
|
9252 |
|
9253 | if (isContextProvider(Component)) {
|
9254 | hasContext = true;
|
9255 | pushContextProvider(workInProgress);
|
9256 | } else {
|
9257 | hasContext = false;
|
9258 | }
|
9259 |
|
9260 | workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
|
9261 | var getDerivedStateFromProps = Component.getDerivedStateFromProps;
|
9262 |
|
9263 | if (typeof getDerivedStateFromProps === 'function') {
|
9264 | applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
|
9265 | }
|
9266 |
|
9267 | adoptClassInstance(workInProgress, value);
|
9268 | mountClassInstance(workInProgress, Component, props, renderExpirationTime);
|
9269 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
|
9270 | } else {
|
9271 |
|
9272 | workInProgress.tag = FunctionComponent;
|
9273 |
|
9274 | {
|
9275 | if (disableLegacyContext && Component.contextTypes) {
|
9276 | warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(Component) || 'Unknown');
|
9277 | }
|
9278 |
|
9279 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
9280 |
|
9281 | if (workInProgress.memoizedState !== null) {
|
9282 | value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
|
9283 | }
|
9284 | }
|
9285 | }
|
9286 |
|
9287 | reconcileChildren(null, workInProgress, value, renderExpirationTime);
|
9288 |
|
9289 | {
|
9290 | validateFunctionComponentInDev(workInProgress, Component);
|
9291 | }
|
9292 |
|
9293 | return workInProgress.child;
|
9294 | }
|
9295 | }
|
9296 |
|
9297 | function validateFunctionComponentInDev(workInProgress, Component) {
|
9298 | if (Component) {
|
9299 | !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
|
9300 | }
|
9301 |
|
9302 | if (workInProgress.ref !== null) {
|
9303 | var info = '';
|
9304 | var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
9305 |
|
9306 | if (ownerName) {
|
9307 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
9308 | }
|
9309 |
|
9310 | var warningKey = ownerName || workInProgress._debugID || '';
|
9311 | var debugSource = workInProgress._debugSource;
|
9312 |
|
9313 | if (debugSource) {
|
9314 | warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
|
9315 | }
|
9316 |
|
9317 | if (!didWarnAboutFunctionRefs[warningKey]) {
|
9318 | didWarnAboutFunctionRefs[warningKey] = true;
|
9319 | warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
|
9320 | }
|
9321 | }
|
9322 |
|
9323 | if (warnAboutDefaultPropsOnFunctionComponents && Component.defaultProps !== undefined) {
|
9324 | var componentName = getComponentName(Component) || 'Unknown';
|
9325 |
|
9326 | if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
|
9327 | warningWithoutStack$1(false, '%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
|
9328 | didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
|
9329 | }
|
9330 | }
|
9331 |
|
9332 | if (typeof Component.getDerivedStateFromProps === 'function') {
|
9333 | var _componentName2 = getComponentName(Component) || 'Unknown';
|
9334 |
|
9335 | if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
|
9336 | warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName2);
|
9337 | didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
|
9338 | }
|
9339 | }
|
9340 |
|
9341 | if (typeof Component.contextType === 'object' && Component.contextType !== null) {
|
9342 | var _componentName3 = getComponentName(Component) || 'Unknown';
|
9343 |
|
9344 | if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
|
9345 | warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName3);
|
9346 | didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
|
9347 | }
|
9348 | }
|
9349 | }
|
9350 |
|
9351 | var SUSPENDED_MARKER = {
|
9352 | dehydrated: null,
|
9353 | retryTime: NoWork
|
9354 | };
|
9355 |
|
9356 | function shouldRemainOnFallback(suspenseContext, current, workInProgress) {
|
9357 |
|
9358 |
|
9359 | return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current === null || current.memoizedState !== null);
|
9360 | }
|
9361 |
|
9362 | function updateSuspenseComponent(current, workInProgress, renderExpirationTime) {
|
9363 | var mode = workInProgress.mode;
|
9364 | var nextProps = workInProgress.pendingProps;
|
9365 |
|
9366 | {
|
9367 | if (shouldSuspend(workInProgress)) {
|
9368 | workInProgress.effectTag |= DidCapture;
|
9369 | }
|
9370 | }
|
9371 |
|
9372 | var suspenseContext = suspenseStackCursor.current;
|
9373 | var nextDidTimeout = false;
|
9374 | var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
|
9375 |
|
9376 | if (didSuspend || shouldRemainOnFallback(suspenseContext, current, workInProgress)) {
|
9377 |
|
9378 |
|
9379 | nextDidTimeout = true;
|
9380 | workInProgress.effectTag &= ~DidCapture;
|
9381 | } else {
|
9382 |
|
9383 | if (current === null || current.memoizedState !== null) {
|
9384 |
|
9385 |
|
9386 |
|
9387 |
|
9388 |
|
9389 | if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
|
9390 | suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
|
9391 | }
|
9392 | }
|
9393 | }
|
9394 |
|
9395 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
9396 | pushSuspenseContext(workInProgress, suspenseContext);
|
9397 |
|
9398 | {
|
9399 | if ('maxDuration' in nextProps) {
|
9400 | if (!didWarnAboutMaxDuration) {
|
9401 | didWarnAboutMaxDuration = true;
|
9402 | warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
|
9403 | }
|
9404 | }
|
9405 | }
|
9406 |
|
9407 |
|
9408 |
|
9409 |
|
9410 |
|
9411 |
|
9412 |
|
9413 |
|
9414 |
|
9415 |
|
9416 |
|
9417 |
|
9418 |
|
9419 |
|
9420 |
|
9421 |
|
9422 |
|
9423 |
|
9424 |
|
9425 |
|
9426 |
|
9427 |
|
9428 | if (current === null) {
|
9429 |
|
9430 |
|
9431 | if (nextProps.fallback !== undefined) {
|
9432 | tryToClaimNextHydratableInstance(workInProgress);
|
9433 |
|
9434 | if (enableSuspenseServerRenderer) {
|
9435 | var suspenseState = workInProgress.memoizedState;
|
9436 |
|
9437 | if (suspenseState !== null) {
|
9438 | var dehydrated = suspenseState.dehydrated;
|
9439 |
|
9440 | if (dehydrated !== null) {
|
9441 | return mountDehydratedSuspenseComponent(workInProgress, dehydrated, renderExpirationTime);
|
9442 | }
|
9443 | }
|
9444 | }
|
9445 | }
|
9446 |
|
9447 |
|
9448 |
|
9449 | if (nextDidTimeout) {
|
9450 |
|
9451 | var nextFallbackChildren = nextProps.fallback;
|
9452 | var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
|
9453 | primaryChildFragment.return = workInProgress;
|
9454 |
|
9455 | if ((workInProgress.mode & BatchedMode) === NoMode) {
|
9456 |
|
9457 |
|
9458 | var progressedState = workInProgress.memoizedState;
|
9459 | var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
|
9460 | primaryChildFragment.child = progressedPrimaryChild;
|
9461 | var progressedChild = progressedPrimaryChild;
|
9462 |
|
9463 | while (progressedChild !== null) {
|
9464 | progressedChild.return = primaryChildFragment;
|
9465 | progressedChild = progressedChild.sibling;
|
9466 | }
|
9467 | }
|
9468 |
|
9469 | var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
|
9470 | fallbackChildFragment.return = workInProgress;
|
9471 | primaryChildFragment.sibling = fallbackChildFragment;
|
9472 |
|
9473 |
|
9474 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
9475 | workInProgress.child = primaryChildFragment;
|
9476 | return fallbackChildFragment;
|
9477 | } else {
|
9478 |
|
9479 | var nextPrimaryChildren = nextProps.children;
|
9480 | workInProgress.memoizedState = null;
|
9481 | return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
|
9482 | }
|
9483 | } else {
|
9484 |
|
9485 |
|
9486 | var prevState = current.memoizedState;
|
9487 |
|
9488 | if (prevState !== null) {
|
9489 | if (enableSuspenseServerRenderer) {
|
9490 | var _dehydrated = prevState.dehydrated;
|
9491 |
|
9492 | if (_dehydrated !== null) {
|
9493 | if (!didSuspend) {
|
9494 | return updateDehydratedSuspenseComponent(current, workInProgress, _dehydrated, prevState, renderExpirationTime);
|
9495 | } else if (workInProgress.memoizedState !== null) {
|
9496 |
|
9497 |
|
9498 | workInProgress.child = current.child;
|
9499 |
|
9500 |
|
9501 | workInProgress.effectTag |= DidCapture;
|
9502 | return null;
|
9503 | } else {
|
9504 |
|
9505 |
|
9506 |
|
9507 |
|
9508 | var _nextFallbackChildren = nextProps.fallback;
|
9509 |
|
9510 | var _primaryChildFragment = createFiberFromFragment(
|
9511 |
|
9512 | null, mode, NoWork, null);
|
9513 |
|
9514 | _primaryChildFragment.return = workInProgress;
|
9515 |
|
9516 |
|
9517 | _primaryChildFragment.child = null;
|
9518 |
|
9519 | if ((workInProgress.mode & BatchedMode) === NoMode) {
|
9520 |
|
9521 |
|
9522 | var _progressedChild = _primaryChildFragment.child = workInProgress.child;
|
9523 |
|
9524 | while (_progressedChild !== null) {
|
9525 | _progressedChild.return = _primaryChildFragment;
|
9526 | _progressedChild = _progressedChild.sibling;
|
9527 | }
|
9528 | } else {
|
9529 |
|
9530 |
|
9531 | reconcileChildFibers(workInProgress, current.child, null, renderExpirationTime);
|
9532 | }
|
9533 |
|
9534 |
|
9535 |
|
9536 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
9537 |
|
9538 | var treeBaseDuration = 0;
|
9539 | var hiddenChild = _primaryChildFragment.child;
|
9540 |
|
9541 | while (hiddenChild !== null) {
|
9542 | treeBaseDuration += hiddenChild.treeBaseDuration;
|
9543 | hiddenChild = hiddenChild.sibling;
|
9544 | }
|
9545 |
|
9546 | _primaryChildFragment.treeBaseDuration = treeBaseDuration;
|
9547 | }
|
9548 |
|
9549 |
|
9550 | var _fallbackChildFragment = createFiberFromFragment(_nextFallbackChildren, mode, renderExpirationTime, null);
|
9551 |
|
9552 | _fallbackChildFragment.return = workInProgress;
|
9553 | _primaryChildFragment.sibling = _fallbackChildFragment;
|
9554 | _fallbackChildFragment.effectTag |= Placement;
|
9555 | _primaryChildFragment.childExpirationTime = NoWork;
|
9556 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
9557 | workInProgress.child = _primaryChildFragment;
|
9558 |
|
9559 |
|
9560 | return _fallbackChildFragment;
|
9561 | }
|
9562 | }
|
9563 | }
|
9564 |
|
9565 |
|
9566 |
|
9567 | var currentPrimaryChildFragment = current.child;
|
9568 | var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
9569 |
|
9570 | if (nextDidTimeout) {
|
9571 |
|
9572 |
|
9573 | var _nextFallbackChildren2 = nextProps.fallback;
|
9574 |
|
9575 | var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
|
9576 |
|
9577 | _primaryChildFragment2.return = workInProgress;
|
9578 |
|
9579 | if ((workInProgress.mode & BatchedMode) === NoMode) {
|
9580 |
|
9581 |
|
9582 | var _progressedState = workInProgress.memoizedState;
|
9583 |
|
9584 | var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
|
9585 |
|
9586 | if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
|
9587 | _primaryChildFragment2.child = _progressedPrimaryChild;
|
9588 | var _progressedChild2 = _progressedPrimaryChild;
|
9589 |
|
9590 | while (_progressedChild2 !== null) {
|
9591 | _progressedChild2.return = _primaryChildFragment2;
|
9592 | _progressedChild2 = _progressedChild2.sibling;
|
9593 | }
|
9594 | }
|
9595 | }
|
9596 |
|
9597 |
|
9598 |
|
9599 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
9600 |
|
9601 | var _treeBaseDuration = 0;
|
9602 | var _hiddenChild = _primaryChildFragment2.child;
|
9603 |
|
9604 | while (_hiddenChild !== null) {
|
9605 | _treeBaseDuration += _hiddenChild.treeBaseDuration;
|
9606 | _hiddenChild = _hiddenChild.sibling;
|
9607 | }
|
9608 |
|
9609 | _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
|
9610 | }
|
9611 |
|
9612 |
|
9613 |
|
9614 | var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2, currentFallbackChildFragment.expirationTime);
|
9615 |
|
9616 | _fallbackChildFragment2.return = workInProgress;
|
9617 | _primaryChildFragment2.sibling = _fallbackChildFragment2;
|
9618 | _primaryChildFragment2.childExpirationTime = NoWork;
|
9619 |
|
9620 |
|
9621 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
9622 | workInProgress.child = _primaryChildFragment2;
|
9623 | return _fallbackChildFragment2;
|
9624 | } else {
|
9625 |
|
9626 |
|
9627 | var _nextPrimaryChildren = nextProps.children;
|
9628 | var currentPrimaryChild = currentPrimaryChildFragment.child;
|
9629 | var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
|
9630 |
|
9631 |
|
9632 |
|
9633 |
|
9634 |
|
9635 |
|
9636 | workInProgress.memoizedState = null;
|
9637 | return workInProgress.child = primaryChild;
|
9638 | }
|
9639 | } else {
|
9640 |
|
9641 |
|
9642 | var _currentPrimaryChild = current.child;
|
9643 |
|
9644 | if (nextDidTimeout) {
|
9645 |
|
9646 |
|
9647 | var _nextFallbackChildren3 = nextProps.fallback;
|
9648 |
|
9649 | var _primaryChildFragment3 = createFiberFromFragment(
|
9650 |
|
9651 | null, mode, NoWork, null);
|
9652 |
|
9653 | _primaryChildFragment3.return = workInProgress;
|
9654 | _primaryChildFragment3.child = _currentPrimaryChild;
|
9655 |
|
9656 | if (_currentPrimaryChild !== null) {
|
9657 | _currentPrimaryChild.return = _primaryChildFragment3;
|
9658 | }
|
9659 |
|
9660 |
|
9661 |
|
9662 |
|
9663 |
|
9664 | if ((workInProgress.mode & BatchedMode) === NoMode) {
|
9665 |
|
9666 |
|
9667 | var _progressedState2 = workInProgress.memoizedState;
|
9668 |
|
9669 | var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
|
9670 |
|
9671 | _primaryChildFragment3.child = _progressedPrimaryChild2;
|
9672 | var _progressedChild3 = _progressedPrimaryChild2;
|
9673 |
|
9674 | while (_progressedChild3 !== null) {
|
9675 | _progressedChild3.return = _primaryChildFragment3;
|
9676 | _progressedChild3 = _progressedChild3.sibling;
|
9677 | }
|
9678 | }
|
9679 |
|
9680 |
|
9681 |
|
9682 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
9683 |
|
9684 | var _treeBaseDuration2 = 0;
|
9685 | var _hiddenChild2 = _primaryChildFragment3.child;
|
9686 |
|
9687 | while (_hiddenChild2 !== null) {
|
9688 | _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
|
9689 | _hiddenChild2 = _hiddenChild2.sibling;
|
9690 | }
|
9691 |
|
9692 | _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
|
9693 | }
|
9694 |
|
9695 |
|
9696 | var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null);
|
9697 |
|
9698 | _fallbackChildFragment3.return = workInProgress;
|
9699 | _primaryChildFragment3.sibling = _fallbackChildFragment3;
|
9700 | _fallbackChildFragment3.effectTag |= Placement;
|
9701 | _primaryChildFragment3.childExpirationTime = NoWork;
|
9702 |
|
9703 |
|
9704 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
9705 | workInProgress.child = _primaryChildFragment3;
|
9706 | return _fallbackChildFragment3;
|
9707 | } else {
|
9708 |
|
9709 |
|
9710 | workInProgress.memoizedState = null;
|
9711 | var _nextPrimaryChildren2 = nextProps.children;
|
9712 | return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
|
9713 | }
|
9714 | }
|
9715 | }
|
9716 | }
|
9717 |
|
9718 | function retrySuspenseComponentWithoutHydrating(current, workInProgress, renderExpirationTime) {
|
9719 |
|
9720 | workInProgress.memoizedState = null;
|
9721 |
|
9722 | var nextProps = workInProgress.pendingProps;
|
9723 | var nextChildren = nextProps.children;
|
9724 |
|
9725 |
|
9726 |
|
9727 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
9728 | return workInProgress.child;
|
9729 | }
|
9730 |
|
9731 | function mountDehydratedSuspenseComponent(workInProgress, suspenseInstance, renderExpirationTime) {
|
9732 |
|
9733 |
|
9734 | if ((workInProgress.mode & BatchedMode) === NoMode) {
|
9735 | {
|
9736 | warning$1(false, 'Cannot hydrate Suspense in legacy mode. Switch from ' + 'ReactDOM.hydrate(element, container) to ' + 'ReactDOM.createSyncRoot(container, { hydrate: true })' + '.render(element) or remove the Suspense components from ' + 'the server rendered components.');
|
9737 | }
|
9738 |
|
9739 | workInProgress.expirationTime = Sync;
|
9740 | } else if (isSuspenseInstanceFallback(suspenseInstance)) {
|
9741 |
|
9742 |
|
9743 |
|
9744 |
|
9745 |
|
9746 |
|
9747 |
|
9748 |
|
9749 |
|
9750 |
|
9751 | var serverDisplayTime = requestCurrentTimeForUpdate();
|
9752 |
|
9753 | var newExpirationTime = computeAsyncExpiration(serverDisplayTime);
|
9754 |
|
9755 | if (enableSchedulerTracing) {
|
9756 | markSpawnedWork(newExpirationTime);
|
9757 | }
|
9758 |
|
9759 | workInProgress.expirationTime = newExpirationTime;
|
9760 | } else {
|
9761 |
|
9762 |
|
9763 | workInProgress.expirationTime = Never;
|
9764 |
|
9765 | if (enableSchedulerTracing) {
|
9766 | markSpawnedWork(Never);
|
9767 | }
|
9768 | }
|
9769 |
|
9770 | return null;
|
9771 | }
|
9772 |
|
9773 | function updateDehydratedSuspenseComponent(current, workInProgress, suspenseInstance, suspenseState, renderExpirationTime) {
|
9774 |
|
9775 |
|
9776 | warnIfHydrating();
|
9777 |
|
9778 | if ((workInProgress.mode & BatchedMode) === NoMode) {
|
9779 | return retrySuspenseComponentWithoutHydrating(current, workInProgress, renderExpirationTime);
|
9780 | }
|
9781 |
|
9782 | if (isSuspenseInstanceFallback(suspenseInstance)) {
|
9783 |
|
9784 |
|
9785 |
|
9786 | return retrySuspenseComponentWithoutHydrating(current, workInProgress, renderExpirationTime);
|
9787 | }
|
9788 |
|
9789 |
|
9790 |
|
9791 | var hasContextChanged$$1 = current.childExpirationTime >= renderExpirationTime;
|
9792 |
|
9793 | if (didReceiveUpdate || hasContextChanged$$1) {
|
9794 |
|
9795 |
|
9796 |
|
9797 | if (renderExpirationTime < Sync) {
|
9798 | if (suspenseState.retryTime <= renderExpirationTime) {
|
9799 |
|
9800 |
|
9801 | var attemptHydrationAtExpirationTime = renderExpirationTime + 1;
|
9802 | suspenseState.retryTime = attemptHydrationAtExpirationTime;
|
9803 | scheduleWork(current, attemptHydrationAtExpirationTime);
|
9804 | } else {
|
9805 |
|
9806 |
|
9807 |
|
9808 |
|
9809 |
|
9810 | }
|
9811 | }
|
9812 |
|
9813 |
|
9814 |
|
9815 |
|
9816 |
|
9817 |
|
9818 | renderDidSuspendDelayIfPossible();
|
9819 | return retrySuspenseComponentWithoutHydrating(current, workInProgress, renderExpirationTime);
|
9820 | } else if (isSuspenseInstancePending(suspenseInstance)) {
|
9821 |
|
9822 |
|
9823 |
|
9824 |
|
9825 |
|
9826 |
|
9827 |
|
9828 |
|
9829 |
|
9830 | workInProgress.effectTag |= DidCapture;
|
9831 |
|
9832 | workInProgress.child = current.child;
|
9833 |
|
9834 | registerSuspenseInstanceRetry(suspenseInstance, retryDehydratedSuspenseBoundary.bind(null, current));
|
9835 | return null;
|
9836 | } else {
|
9837 |
|
9838 | reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress, suspenseInstance);
|
9839 | var nextProps = workInProgress.pendingProps;
|
9840 | var nextChildren = nextProps.children;
|
9841 | var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
9842 | var node = child;
|
9843 |
|
9844 | while (node) {
|
9845 |
|
9846 |
|
9847 |
|
9848 |
|
9849 |
|
9850 |
|
9851 | node.effectTag |= Hydrating;
|
9852 | node = node.sibling;
|
9853 | }
|
9854 |
|
9855 | workInProgress.child = child;
|
9856 | return workInProgress.child;
|
9857 | }
|
9858 | }
|
9859 |
|
9860 | function scheduleWorkOnFiber(fiber, renderExpirationTime) {
|
9861 | if (fiber.expirationTime < renderExpirationTime) {
|
9862 | fiber.expirationTime = renderExpirationTime;
|
9863 | }
|
9864 |
|
9865 | var alternate = fiber.alternate;
|
9866 |
|
9867 | if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
|
9868 | alternate.expirationTime = renderExpirationTime;
|
9869 | }
|
9870 |
|
9871 | scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
|
9872 | }
|
9873 |
|
9874 | function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
|
9875 |
|
9876 |
|
9877 |
|
9878 | var node = firstChild;
|
9879 |
|
9880 | while (node !== null) {
|
9881 | if (node.tag === SuspenseComponent) {
|
9882 | var state = node.memoizedState;
|
9883 |
|
9884 | if (state !== null) {
|
9885 | scheduleWorkOnFiber(node, renderExpirationTime);
|
9886 | }
|
9887 | } else if (node.tag === SuspenseListComponent) {
|
9888 |
|
9889 |
|
9890 |
|
9891 |
|
9892 |
|
9893 | scheduleWorkOnFiber(node, renderExpirationTime);
|
9894 | } else if (node.child !== null) {
|
9895 | node.child.return = node;
|
9896 | node = node.child;
|
9897 | continue;
|
9898 | }
|
9899 |
|
9900 | if (node === workInProgress) {
|
9901 | return;
|
9902 | }
|
9903 |
|
9904 | while (node.sibling === null) {
|
9905 | if (node.return === null || node.return === workInProgress) {
|
9906 | return;
|
9907 | }
|
9908 |
|
9909 | node = node.return;
|
9910 | }
|
9911 |
|
9912 | node.sibling.return = node.return;
|
9913 | node = node.sibling;
|
9914 | }
|
9915 | }
|
9916 |
|
9917 | function findLastContentRow(firstChild) {
|
9918 |
|
9919 |
|
9920 |
|
9921 |
|
9922 |
|
9923 |
|
9924 |
|
9925 | var row = firstChild;
|
9926 | var lastContentRow = null;
|
9927 |
|
9928 | while (row !== null) {
|
9929 | var currentRow = row.alternate;
|
9930 |
|
9931 | if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
9932 | lastContentRow = row;
|
9933 | }
|
9934 |
|
9935 | row = row.sibling;
|
9936 | }
|
9937 |
|
9938 | return lastContentRow;
|
9939 | }
|
9940 |
|
9941 | function validateRevealOrder(revealOrder) {
|
9942 | {
|
9943 | if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
|
9944 | didWarnAboutRevealOrder[revealOrder] = true;
|
9945 |
|
9946 | if (typeof revealOrder === 'string') {
|
9947 | switch (revealOrder.toLowerCase()) {
|
9948 | case 'together':
|
9949 | case 'forwards':
|
9950 | case 'backwards':
|
9951 | {
|
9952 | warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
|
9953 | break;
|
9954 | }
|
9955 |
|
9956 | case 'forward':
|
9957 | case 'backward':
|
9958 | {
|
9959 | warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
|
9960 | break;
|
9961 | }
|
9962 |
|
9963 | default:
|
9964 | warning$1(false, '"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
9965 | break;
|
9966 | }
|
9967 | } else {
|
9968 | warning$1(false, '%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
9969 | }
|
9970 | }
|
9971 | }
|
9972 | }
|
9973 |
|
9974 | function validateTailOptions(tailMode, revealOrder) {
|
9975 | {
|
9976 | if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
|
9977 | if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
|
9978 | didWarnAboutTailOptions[tailMode] = true;
|
9979 | warning$1(false, '"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
|
9980 | } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
|
9981 | didWarnAboutTailOptions[tailMode] = true;
|
9982 | warning$1(false, '<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
|
9983 | }
|
9984 | }
|
9985 | }
|
9986 | }
|
9987 |
|
9988 | function validateSuspenseListNestedChild(childSlot, index) {
|
9989 | {
|
9990 | var isArray = Array.isArray(childSlot);
|
9991 | var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
|
9992 |
|
9993 | if (isArray || isIterable) {
|
9994 | var type = isArray ? 'array' : 'iterable';
|
9995 | warning$1(false, 'A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type);
|
9996 | return false;
|
9997 | }
|
9998 | }
|
9999 |
|
10000 | return true;
|
10001 | }
|
10002 |
|
10003 | function validateSuspenseListChildren(children, revealOrder) {
|
10004 | {
|
10005 | if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
|
10006 | if (Array.isArray(children)) {
|
10007 | for (var i = 0; i < children.length; i++) {
|
10008 | if (!validateSuspenseListNestedChild(children[i], i)) {
|
10009 | return;
|
10010 | }
|
10011 | }
|
10012 | } else {
|
10013 | var iteratorFn = getIteratorFn(children);
|
10014 |
|
10015 | if (typeof iteratorFn === 'function') {
|
10016 | var childrenIterator = iteratorFn.call(children);
|
10017 |
|
10018 | if (childrenIterator) {
|
10019 | var step = childrenIterator.next();
|
10020 | var _i = 0;
|
10021 |
|
10022 | for (; !step.done; step = childrenIterator.next()) {
|
10023 | if (!validateSuspenseListNestedChild(step.value, _i)) {
|
10024 | return;
|
10025 | }
|
10026 |
|
10027 | _i++;
|
10028 | }
|
10029 | }
|
10030 | } else {
|
10031 | warning$1(false, 'A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder);
|
10032 | }
|
10033 | }
|
10034 | }
|
10035 | }
|
10036 | }
|
10037 |
|
10038 | function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) {
|
10039 | var renderState = workInProgress.memoizedState;
|
10040 |
|
10041 | if (renderState === null) {
|
10042 | workInProgress.memoizedState = {
|
10043 | isBackwards: isBackwards,
|
10044 | rendering: null,
|
10045 | last: lastContentRow,
|
10046 | tail: tail,
|
10047 | tailExpiration: 0,
|
10048 | tailMode: tailMode,
|
10049 | lastEffect: lastEffectBeforeRendering
|
10050 | };
|
10051 | } else {
|
10052 |
|
10053 | renderState.isBackwards = isBackwards;
|
10054 | renderState.rendering = null;
|
10055 | renderState.last = lastContentRow;
|
10056 | renderState.tail = tail;
|
10057 | renderState.tailExpiration = 0;
|
10058 | renderState.tailMode = tailMode;
|
10059 | renderState.lastEffect = lastEffectBeforeRendering;
|
10060 | }
|
10061 | }
|
10062 |
|
10063 |
|
10064 |
|
10065 |
|
10066 |
|
10067 |
|
10068 |
|
10069 |
|
10070 | function updateSuspenseListComponent(current, workInProgress, renderExpirationTime) {
|
10071 | var nextProps = workInProgress.pendingProps;
|
10072 | var revealOrder = nextProps.revealOrder;
|
10073 | var tailMode = nextProps.tail;
|
10074 | var newChildren = nextProps.children;
|
10075 | validateRevealOrder(revealOrder);
|
10076 | validateTailOptions(tailMode, revealOrder);
|
10077 | validateSuspenseListChildren(newChildren, revealOrder);
|
10078 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
10079 | var suspenseContext = suspenseStackCursor.current;
|
10080 | var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
10081 |
|
10082 | if (shouldForceFallback) {
|
10083 | suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
10084 | workInProgress.effectTag |= DidCapture;
|
10085 | } else {
|
10086 | var didSuspendBefore = current !== null && (current.effectTag & DidCapture) !== NoEffect;
|
10087 |
|
10088 | if (didSuspendBefore) {
|
10089 |
|
10090 |
|
10091 |
|
10092 | propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
|
10093 | }
|
10094 |
|
10095 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
10096 | }
|
10097 |
|
10098 | pushSuspenseContext(workInProgress, suspenseContext);
|
10099 |
|
10100 | if ((workInProgress.mode & BatchedMode) === NoMode) {
|
10101 |
|
10102 |
|
10103 | workInProgress.memoizedState = null;
|
10104 | } else {
|
10105 | switch (revealOrder) {
|
10106 | case 'forwards':
|
10107 | {
|
10108 | var lastContentRow = findLastContentRow(workInProgress.child);
|
10109 | var tail;
|
10110 |
|
10111 | if (lastContentRow === null) {
|
10112 |
|
10113 |
|
10114 | tail = workInProgress.child;
|
10115 | workInProgress.child = null;
|
10116 | } else {
|
10117 |
|
10118 |
|
10119 | tail = lastContentRow.sibling;
|
10120 | lastContentRow.sibling = null;
|
10121 | }
|
10122 |
|
10123 | initSuspenseListRenderState(workInProgress, false,
|
10124 | tail, lastContentRow, tailMode, workInProgress.lastEffect);
|
10125 | break;
|
10126 | }
|
10127 |
|
10128 | case 'backwards':
|
10129 | {
|
10130 |
|
10131 |
|
10132 |
|
10133 |
|
10134 | var _tail = null;
|
10135 | var row = workInProgress.child;
|
10136 | workInProgress.child = null;
|
10137 |
|
10138 | while (row !== null) {
|
10139 | var currentRow = row.alternate;
|
10140 |
|
10141 | if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
10142 |
|
10143 | workInProgress.child = row;
|
10144 | break;
|
10145 | }
|
10146 |
|
10147 | var nextRow = row.sibling;
|
10148 | row.sibling = _tail;
|
10149 | _tail = row;
|
10150 | row = nextRow;
|
10151 | }
|
10152 |
|
10153 |
|
10154 | initSuspenseListRenderState(workInProgress, true,
|
10155 | _tail, null,
|
10156 | tailMode, workInProgress.lastEffect);
|
10157 | break;
|
10158 | }
|
10159 |
|
10160 | case 'together':
|
10161 | {
|
10162 | initSuspenseListRenderState(workInProgress, false,
|
10163 | null,
|
10164 | null,
|
10165 | undefined, workInProgress.lastEffect);
|
10166 | break;
|
10167 | }
|
10168 |
|
10169 | default:
|
10170 | {
|
10171 |
|
10172 |
|
10173 | workInProgress.memoizedState = null;
|
10174 | }
|
10175 | }
|
10176 | }
|
10177 |
|
10178 | return workInProgress.child;
|
10179 | }
|
10180 |
|
10181 | function updatePortalComponent(current, workInProgress, renderExpirationTime) {
|
10182 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
10183 | var nextChildren = workInProgress.pendingProps;
|
10184 |
|
10185 | if (current === null) {
|
10186 |
|
10187 |
|
10188 |
|
10189 |
|
10190 |
|
10191 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
10192 | } else {
|
10193 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
10194 | }
|
10195 |
|
10196 | return workInProgress.child;
|
10197 | }
|
10198 |
|
10199 | function updateContextProvider(current, workInProgress, renderExpirationTime) {
|
10200 | var providerType = workInProgress.type;
|
10201 | var context = providerType._context;
|
10202 | var newProps = workInProgress.pendingProps;
|
10203 | var oldProps = workInProgress.memoizedProps;
|
10204 | var newValue = newProps.value;
|
10205 |
|
10206 | {
|
10207 | var providerPropTypes = workInProgress.type.propTypes;
|
10208 |
|
10209 | if (providerPropTypes) {
|
10210 | checkPropTypes_1(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
|
10211 | }
|
10212 | }
|
10213 |
|
10214 | pushProvider(workInProgress, newValue);
|
10215 |
|
10216 | if (oldProps !== null) {
|
10217 | var oldValue = oldProps.value;
|
10218 | var changedBits = calculateChangedBits(context, newValue, oldValue);
|
10219 |
|
10220 | if (changedBits === 0) {
|
10221 |
|
10222 | if (oldProps.children === newProps.children && !hasContextChanged()) {
|
10223 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
10224 | }
|
10225 | } else {
|
10226 |
|
10227 |
|
10228 | propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
|
10229 | }
|
10230 | }
|
10231 |
|
10232 | var newChildren = newProps.children;
|
10233 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
10234 | return workInProgress.child;
|
10235 | }
|
10236 |
|
10237 | var hasWarnedAboutUsingContextAsConsumer = false;
|
10238 |
|
10239 | function updateContextConsumer(current, workInProgress, renderExpirationTime) {
|
10240 | var context = workInProgress.type;
|
10241 |
|
10242 |
|
10243 |
|
10244 |
|
10245 |
|
10246 |
|
10247 |
|
10248 | {
|
10249 | if (context._context === undefined) {
|
10250 |
|
10251 |
|
10252 |
|
10253 | if (context !== context.Consumer) {
|
10254 | if (!hasWarnedAboutUsingContextAsConsumer) {
|
10255 | hasWarnedAboutUsingContextAsConsumer = true;
|
10256 | warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
|
10257 | }
|
10258 | }
|
10259 | } else {
|
10260 | context = context._context;
|
10261 | }
|
10262 | }
|
10263 |
|
10264 | var newProps = workInProgress.pendingProps;
|
10265 | var render = newProps.children;
|
10266 |
|
10267 | {
|
10268 | !(typeof render === 'function') ? warningWithoutStack$1(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
|
10269 | }
|
10270 |
|
10271 | prepareToReadContext(workInProgress, renderExpirationTime);
|
10272 | var newValue = readContext(context, newProps.unstable_observedBits);
|
10273 | var newChildren;
|
10274 |
|
10275 | {
|
10276 | ReactCurrentOwner$2.current = workInProgress;
|
10277 | setCurrentPhase('render');
|
10278 | newChildren = render(newValue);
|
10279 | setCurrentPhase(null);
|
10280 | }
|
10281 |
|
10282 |
|
10283 | workInProgress.effectTag |= PerformedWork;
|
10284 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
10285 | return workInProgress.child;
|
10286 | }
|
10287 |
|
10288 | function updateFundamentalComponent$1(current, workInProgress, renderExpirationTime) {
|
10289 | var fundamentalImpl = workInProgress.type.impl;
|
10290 |
|
10291 | if (fundamentalImpl.reconcileChildren === false) {
|
10292 | return null;
|
10293 | }
|
10294 |
|
10295 | var nextProps = workInProgress.pendingProps;
|
10296 | var nextChildren = nextProps.children;
|
10297 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
10298 | return workInProgress.child;
|
10299 | }
|
10300 |
|
10301 | function updateScopeComponent(current, workInProgress, renderExpirationTime) {
|
10302 | var nextProps = workInProgress.pendingProps;
|
10303 | var nextChildren = nextProps.children;
|
10304 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
10305 | return workInProgress.child;
|
10306 | }
|
10307 |
|
10308 | function markWorkInProgressReceivedUpdate() {
|
10309 | didReceiveUpdate = true;
|
10310 | }
|
10311 |
|
10312 | function bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime) {
|
10313 | cancelWorkTimer(workInProgress);
|
10314 |
|
10315 | if (current !== null) {
|
10316 |
|
10317 | workInProgress.dependencies = current.dependencies;
|
10318 | }
|
10319 |
|
10320 | if (enableProfilerTimer) {
|
10321 |
|
10322 | stopProfilerTimerIfRunning(workInProgress);
|
10323 | }
|
10324 |
|
10325 | var updateExpirationTime = workInProgress.expirationTime;
|
10326 |
|
10327 | if (updateExpirationTime !== NoWork) {
|
10328 | markUnprocessedUpdateTime(updateExpirationTime);
|
10329 | }
|
10330 |
|
10331 |
|
10332 | var childExpirationTime = workInProgress.childExpirationTime;
|
10333 |
|
10334 | if (childExpirationTime < renderExpirationTime) {
|
10335 |
|
10336 |
|
10337 |
|
10338 | return null;
|
10339 | } else {
|
10340 |
|
10341 |
|
10342 | cloneChildFibers(current, workInProgress);
|
10343 | return workInProgress.child;
|
10344 | }
|
10345 | }
|
10346 |
|
10347 | function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
|
10348 | {
|
10349 | var returnFiber = oldWorkInProgress.return;
|
10350 |
|
10351 | if (returnFiber === null) {
|
10352 | throw new Error('Cannot swap the root fiber.');
|
10353 | }
|
10354 |
|
10355 |
|
10356 |
|
10357 | current.alternate = null;
|
10358 | oldWorkInProgress.alternate = null;
|
10359 |
|
10360 | newWorkInProgress.index = oldWorkInProgress.index;
|
10361 | newWorkInProgress.sibling = oldWorkInProgress.sibling;
|
10362 | newWorkInProgress.return = oldWorkInProgress.return;
|
10363 | newWorkInProgress.ref = oldWorkInProgress.ref;
|
10364 |
|
10365 | if (oldWorkInProgress === returnFiber.child) {
|
10366 | returnFiber.child = newWorkInProgress;
|
10367 | } else {
|
10368 | var prevSibling = returnFiber.child;
|
10369 |
|
10370 | if (prevSibling === null) {
|
10371 | throw new Error('Expected parent to have a child.');
|
10372 | }
|
10373 |
|
10374 | while (prevSibling.sibling !== oldWorkInProgress) {
|
10375 | prevSibling = prevSibling.sibling;
|
10376 |
|
10377 | if (prevSibling === null) {
|
10378 | throw new Error('Expected to find the previous sibling.');
|
10379 | }
|
10380 | }
|
10381 |
|
10382 | prevSibling.sibling = newWorkInProgress;
|
10383 | }
|
10384 |
|
10385 |
|
10386 |
|
10387 | var last = returnFiber.lastEffect;
|
10388 |
|
10389 | if (last !== null) {
|
10390 | last.nextEffect = current;
|
10391 | returnFiber.lastEffect = current;
|
10392 | } else {
|
10393 | returnFiber.firstEffect = returnFiber.lastEffect = current;
|
10394 | }
|
10395 |
|
10396 | current.nextEffect = null;
|
10397 | current.effectTag = Deletion;
|
10398 | newWorkInProgress.effectTag |= Placement;
|
10399 |
|
10400 | return newWorkInProgress;
|
10401 | }
|
10402 | }
|
10403 |
|
10404 | function beginWork$1(current, workInProgress, renderExpirationTime) {
|
10405 | var updateExpirationTime = workInProgress.expirationTime;
|
10406 |
|
10407 | {
|
10408 | if (workInProgress._debugNeedsRemount && current !== null) {
|
10409 |
|
10410 | return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
|
10411 | }
|
10412 | }
|
10413 |
|
10414 | if (current !== null) {
|
10415 | var oldProps = current.memoizedProps;
|
10416 | var newProps = workInProgress.pendingProps;
|
10417 |
|
10418 | if (oldProps !== newProps || hasContextChanged() || (
|
10419 | workInProgress.type !== current.type)) {
|
10420 |
|
10421 |
|
10422 | didReceiveUpdate = true;
|
10423 | } else if (updateExpirationTime < renderExpirationTime) {
|
10424 | didReceiveUpdate = false;
|
10425 |
|
10426 |
|
10427 |
|
10428 | switch (workInProgress.tag) {
|
10429 | case HostRoot:
|
10430 | pushHostRootContext(workInProgress);
|
10431 | resetHydrationState();
|
10432 | break;
|
10433 |
|
10434 | case HostComponent:
|
10435 | pushHostContext(workInProgress);
|
10436 |
|
10437 | if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
|
10438 | if (enableSchedulerTracing) {
|
10439 | markSpawnedWork(Never);
|
10440 | }
|
10441 |
|
10442 |
|
10443 | workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
|
10444 | return null;
|
10445 | }
|
10446 |
|
10447 | break;
|
10448 |
|
10449 | case ClassComponent:
|
10450 | {
|
10451 | var Component = workInProgress.type;
|
10452 |
|
10453 | if (isContextProvider(Component)) {
|
10454 | pushContextProvider(workInProgress);
|
10455 | }
|
10456 |
|
10457 | break;
|
10458 | }
|
10459 |
|
10460 | case HostPortal:
|
10461 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
10462 | break;
|
10463 |
|
10464 | case ContextProvider:
|
10465 | {
|
10466 | var newValue = workInProgress.memoizedProps.value;
|
10467 | pushProvider(workInProgress, newValue);
|
10468 | break;
|
10469 | }
|
10470 |
|
10471 | case Profiler:
|
10472 | if (enableProfilerTimer) {
|
10473 | workInProgress.effectTag |= Update;
|
10474 | }
|
10475 |
|
10476 | break;
|
10477 |
|
10478 | case SuspenseComponent:
|
10479 | {
|
10480 | var state = workInProgress.memoizedState;
|
10481 |
|
10482 | if (state !== null) {
|
10483 | if (enableSuspenseServerRenderer) {
|
10484 | if (state.dehydrated !== null) {
|
10485 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
10486 |
|
10487 |
|
10488 |
|
10489 | workInProgress.effectTag |= DidCapture;
|
10490 | break;
|
10491 | }
|
10492 | }
|
10493 |
|
10494 |
|
10495 |
|
10496 |
|
10497 |
|
10498 | var primaryChildFragment = workInProgress.child;
|
10499 | var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
|
10500 |
|
10501 | if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
|
10502 |
|
10503 |
|
10504 | return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
|
10505 | } else {
|
10506 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
10507 |
|
10508 |
|
10509 | var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
10510 |
|
10511 | if (child !== null) {
|
10512 |
|
10513 |
|
10514 | return child.sibling;
|
10515 | } else {
|
10516 | return null;
|
10517 | }
|
10518 | }
|
10519 | } else {
|
10520 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
10521 | }
|
10522 |
|
10523 | break;
|
10524 | }
|
10525 |
|
10526 | case SuspenseListComponent:
|
10527 | {
|
10528 | var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect;
|
10529 | var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
|
10530 |
|
10531 | if (didSuspendBefore) {
|
10532 | if (hasChildWork) {
|
10533 |
|
10534 |
|
10535 |
|
10536 |
|
10537 |
|
10538 | return updateSuspenseListComponent(current, workInProgress, renderExpirationTime);
|
10539 | }
|
10540 |
|
10541 |
|
10542 |
|
10543 |
|
10544 | workInProgress.effectTag |= DidCapture;
|
10545 | }
|
10546 |
|
10547 |
|
10548 |
|
10549 |
|
10550 | var renderState = workInProgress.memoizedState;
|
10551 |
|
10552 | if (renderState !== null) {
|
10553 |
|
10554 |
|
10555 | renderState.rendering = null;
|
10556 | renderState.tail = null;
|
10557 | }
|
10558 |
|
10559 | pushSuspenseContext(workInProgress, suspenseStackCursor.current);
|
10560 |
|
10561 | if (hasChildWork) {
|
10562 | break;
|
10563 | } else {
|
10564 |
|
10565 |
|
10566 |
|
10567 | return null;
|
10568 | }
|
10569 | }
|
10570 | }
|
10571 |
|
10572 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
10573 | } else {
|
10574 |
|
10575 |
|
10576 |
|
10577 |
|
10578 | didReceiveUpdate = false;
|
10579 | }
|
10580 | } else {
|
10581 | didReceiveUpdate = false;
|
10582 | }
|
10583 |
|
10584 |
|
10585 | workInProgress.expirationTime = NoWork;
|
10586 |
|
10587 | switch (workInProgress.tag) {
|
10588 | case IndeterminateComponent:
|
10589 | {
|
10590 | return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderExpirationTime);
|
10591 | }
|
10592 |
|
10593 | case LazyComponent:
|
10594 | {
|
10595 | var elementType = workInProgress.elementType;
|
10596 | return mountLazyComponent(current, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
|
10597 | }
|
10598 |
|
10599 | case FunctionComponent:
|
10600 | {
|
10601 | var _Component = workInProgress.type;
|
10602 | var unresolvedProps = workInProgress.pendingProps;
|
10603 | var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
|
10604 | return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderExpirationTime);
|
10605 | }
|
10606 |
|
10607 | case ClassComponent:
|
10608 | {
|
10609 | var _Component2 = workInProgress.type;
|
10610 | var _unresolvedProps = workInProgress.pendingProps;
|
10611 |
|
10612 | var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
|
10613 |
|
10614 | return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
|
10615 | }
|
10616 |
|
10617 | case HostRoot:
|
10618 | return updateHostRoot(current, workInProgress, renderExpirationTime);
|
10619 |
|
10620 | case HostComponent:
|
10621 | return updateHostComponent(current, workInProgress, renderExpirationTime);
|
10622 |
|
10623 | case HostText:
|
10624 | return updateHostText(current, workInProgress);
|
10625 |
|
10626 | case SuspenseComponent:
|
10627 | return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
|
10628 |
|
10629 | case HostPortal:
|
10630 | return updatePortalComponent(current, workInProgress, renderExpirationTime);
|
10631 |
|
10632 | case ForwardRef:
|
10633 | {
|
10634 | var type = workInProgress.type;
|
10635 | var _unresolvedProps2 = workInProgress.pendingProps;
|
10636 |
|
10637 | var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
10638 |
|
10639 | return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderExpirationTime);
|
10640 | }
|
10641 |
|
10642 | case Fragment:
|
10643 | return updateFragment(current, workInProgress, renderExpirationTime);
|
10644 |
|
10645 | case Mode:
|
10646 | return updateMode(current, workInProgress, renderExpirationTime);
|
10647 |
|
10648 | case Profiler:
|
10649 | return updateProfiler(current, workInProgress, renderExpirationTime);
|
10650 |
|
10651 | case ContextProvider:
|
10652 | return updateContextProvider(current, workInProgress, renderExpirationTime);
|
10653 |
|
10654 | case ContextConsumer:
|
10655 | return updateContextConsumer(current, workInProgress, renderExpirationTime);
|
10656 |
|
10657 | case MemoComponent:
|
10658 | {
|
10659 | var _type2 = workInProgress.type;
|
10660 | var _unresolvedProps3 = workInProgress.pendingProps;
|
10661 |
|
10662 | var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
|
10663 |
|
10664 | {
|
10665 | if (workInProgress.type !== workInProgress.elementType) {
|
10666 | var outerPropTypes = _type2.propTypes;
|
10667 |
|
10668 | if (outerPropTypes) {
|
10669 | checkPropTypes_1(outerPropTypes, _resolvedProps3,
|
10670 | 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
|
10671 | }
|
10672 | }
|
10673 | }
|
10674 |
|
10675 | _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
|
10676 | return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
|
10677 | }
|
10678 |
|
10679 | case SimpleMemoComponent:
|
10680 | {
|
10681 | return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
|
10682 | }
|
10683 |
|
10684 | case IncompleteClassComponent:
|
10685 | {
|
10686 | var _Component3 = workInProgress.type;
|
10687 | var _unresolvedProps4 = workInProgress.pendingProps;
|
10688 |
|
10689 | var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
|
10690 |
|
10691 | return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
|
10692 | }
|
10693 |
|
10694 | case SuspenseListComponent:
|
10695 | {
|
10696 | return updateSuspenseListComponent(current, workInProgress, renderExpirationTime);
|
10697 | }
|
10698 |
|
10699 | case FundamentalComponent:
|
10700 | {
|
10701 | if (enableFundamentalAPI) {
|
10702 | return updateFundamentalComponent$1(current, workInProgress, renderExpirationTime);
|
10703 | }
|
10704 |
|
10705 | break;
|
10706 | }
|
10707 |
|
10708 | case ScopeComponent:
|
10709 | {
|
10710 | if (enableScopeAPI) {
|
10711 | return updateScopeComponent(current, workInProgress, renderExpirationTime);
|
10712 | }
|
10713 |
|
10714 | break;
|
10715 | }
|
10716 | }
|
10717 |
|
10718 | {
|
10719 | {
|
10720 | throw Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue.");
|
10721 | }
|
10722 | }
|
10723 | }
|
10724 |
|
10725 | function createFundamentalStateInstance(currentFiber, props, impl, state) {
|
10726 | return {
|
10727 | currentFiber: currentFiber,
|
10728 | impl: impl,
|
10729 | instance: null,
|
10730 | prevProps: null,
|
10731 | props: props,
|
10732 | state: state
|
10733 | };
|
10734 | }
|
10735 |
|
10736 | function isFiberSuspenseAndTimedOut(fiber) {
|
10737 | return fiber.tag === SuspenseComponent && fiber.memoizedState !== null;
|
10738 | }
|
10739 |
|
10740 | function getSuspenseFallbackChild(fiber) {
|
10741 | return fiber.child.sibling.child;
|
10742 | }
|
10743 |
|
10744 | function collectScopedNodes(node, fn, scopedNodes) {
|
10745 | if (enableScopeAPI) {
|
10746 | if (node.tag === HostComponent) {
|
10747 | var _type = node.type,
|
10748 | memoizedProps = node.memoizedProps;
|
10749 |
|
10750 | if (fn(_type, memoizedProps) === true) {
|
10751 | scopedNodes.push(getPublicInstance(node.stateNode));
|
10752 | }
|
10753 | }
|
10754 |
|
10755 | var child = node.child;
|
10756 |
|
10757 | if (isFiberSuspenseAndTimedOut(node)) {
|
10758 | child = getSuspenseFallbackChild(node);
|
10759 | }
|
10760 |
|
10761 | if (child !== null) {
|
10762 | collectScopedNodesFromChildren(child, fn, scopedNodes);
|
10763 | }
|
10764 | }
|
10765 | }
|
10766 |
|
10767 | function collectFirstScopedNode(node, fn) {
|
10768 | if (enableScopeAPI) {
|
10769 | if (node.tag === HostComponent) {
|
10770 | var _type2 = node.type,
|
10771 | memoizedProps = node.memoizedProps;
|
10772 |
|
10773 | if (fn(_type2, memoizedProps) === true) {
|
10774 | return getPublicInstance(node.stateNode);
|
10775 | }
|
10776 | }
|
10777 |
|
10778 | var child = node.child;
|
10779 |
|
10780 | if (isFiberSuspenseAndTimedOut(node)) {
|
10781 | child = getSuspenseFallbackChild(node);
|
10782 | }
|
10783 |
|
10784 | if (child !== null) {
|
10785 | return collectFirstScopedNodeFromChildren(child, fn);
|
10786 | }
|
10787 | }
|
10788 |
|
10789 | return null;
|
10790 | }
|
10791 |
|
10792 | function collectScopedNodesFromChildren(startingChild, fn, scopedNodes) {
|
10793 | var child = startingChild;
|
10794 |
|
10795 | while (child !== null) {
|
10796 | collectScopedNodes(child, fn, scopedNodes);
|
10797 | child = child.sibling;
|
10798 | }
|
10799 | }
|
10800 |
|
10801 | function collectFirstScopedNodeFromChildren(startingChild, fn) {
|
10802 | var child = startingChild;
|
10803 |
|
10804 | while (child !== null) {
|
10805 | var scopedNode = collectFirstScopedNode(child, fn);
|
10806 |
|
10807 | if (scopedNode !== null) {
|
10808 | return scopedNode;
|
10809 | }
|
10810 |
|
10811 | child = child.sibling;
|
10812 | }
|
10813 |
|
10814 | return null;
|
10815 | }
|
10816 |
|
10817 | function collectNearestScopeMethods(node, scope, childrenScopes) {
|
10818 | if (isValidScopeNode(node, scope)) {
|
10819 | childrenScopes.push(node.stateNode.methods);
|
10820 | } else {
|
10821 | var child = node.child;
|
10822 |
|
10823 | if (isFiberSuspenseAndTimedOut(node)) {
|
10824 | child = getSuspenseFallbackChild(node);
|
10825 | }
|
10826 |
|
10827 | if (child !== null) {
|
10828 | collectNearestChildScopeMethods(child, scope, childrenScopes);
|
10829 | }
|
10830 | }
|
10831 | }
|
10832 |
|
10833 | function collectNearestChildScopeMethods(startingChild, scope, childrenScopes) {
|
10834 | var child = startingChild;
|
10835 |
|
10836 | while (child !== null) {
|
10837 | collectNearestScopeMethods(child, scope, childrenScopes);
|
10838 | child = child.sibling;
|
10839 | }
|
10840 | }
|
10841 |
|
10842 | function isValidScopeNode(node, scope) {
|
10843 | return node.tag === ScopeComponent && node.type === scope && node.stateNode !== null;
|
10844 | }
|
10845 |
|
10846 | function createScopeMethods(scope, instance) {
|
10847 | return {
|
10848 | getChildren: function () {
|
10849 | var currentFiber = instance.fiber;
|
10850 | var child = currentFiber.child;
|
10851 | var childrenScopes = [];
|
10852 |
|
10853 | if (child !== null) {
|
10854 | collectNearestChildScopeMethods(child, scope, childrenScopes);
|
10855 | }
|
10856 |
|
10857 | return childrenScopes.length === 0 ? null : childrenScopes;
|
10858 | },
|
10859 | getChildrenFromRoot: function () {
|
10860 | var currentFiber = instance.fiber;
|
10861 | var node = currentFiber;
|
10862 |
|
10863 | while (node !== null) {
|
10864 | var parent = node.return;
|
10865 |
|
10866 | if (parent === null) {
|
10867 | break;
|
10868 | }
|
10869 |
|
10870 | node = parent;
|
10871 |
|
10872 | if (node.tag === ScopeComponent && node.type === scope) {
|
10873 | break;
|
10874 | }
|
10875 | }
|
10876 |
|
10877 | var childrenScopes = [];
|
10878 | collectNearestChildScopeMethods(node.child, scope, childrenScopes);
|
10879 | return childrenScopes.length === 0 ? null : childrenScopes;
|
10880 | },
|
10881 | getParent: function () {
|
10882 | var node = instance.fiber.return;
|
10883 |
|
10884 | while (node !== null) {
|
10885 | if (node.tag === ScopeComponent && node.type === scope) {
|
10886 | return node.stateNode.methods;
|
10887 | }
|
10888 |
|
10889 | node = node.return;
|
10890 | }
|
10891 |
|
10892 | return null;
|
10893 | },
|
10894 | getProps: function () {
|
10895 | var currentFiber = instance.fiber;
|
10896 | return currentFiber.memoizedProps;
|
10897 | },
|
10898 | queryAllNodes: function (fn) {
|
10899 | var currentFiber = instance.fiber;
|
10900 | var child = currentFiber.child;
|
10901 | var scopedNodes = [];
|
10902 |
|
10903 | if (child !== null) {
|
10904 | collectScopedNodesFromChildren(child, fn, scopedNodes);
|
10905 | }
|
10906 |
|
10907 | return scopedNodes.length === 0 ? null : scopedNodes;
|
10908 | },
|
10909 | queryFirstNode: function (fn) {
|
10910 | var currentFiber = instance.fiber;
|
10911 | var child = currentFiber.child;
|
10912 |
|
10913 | if (child !== null) {
|
10914 | return collectFirstScopedNodeFromChildren(child, fn);
|
10915 | }
|
10916 |
|
10917 | return null;
|
10918 | },
|
10919 | containsNode: function (node) {
|
10920 | var fiber = getInstanceFromNode(node);
|
10921 |
|
10922 | while (fiber !== null) {
|
10923 | if (fiber.tag === ScopeComponent && fiber.type === scope && fiber.stateNode === instance) {
|
10924 | return true;
|
10925 | }
|
10926 |
|
10927 | fiber = fiber.return;
|
10928 | }
|
10929 |
|
10930 | return false;
|
10931 | }
|
10932 | };
|
10933 | }
|
10934 |
|
10935 | function markUpdate(workInProgress) {
|
10936 |
|
10937 |
|
10938 | workInProgress.effectTag |= Update;
|
10939 | }
|
10940 |
|
10941 | function markRef$1(workInProgress) {
|
10942 | workInProgress.effectTag |= Ref;
|
10943 | }
|
10944 |
|
10945 | var appendAllChildren;
|
10946 | var updateHostContainer;
|
10947 | var updateHostComponent$1;
|
10948 | var updateHostText$1;
|
10949 |
|
10950 | if (supportsMutation) {
|
10951 |
|
10952 | appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
|
10953 |
|
10954 |
|
10955 | var node = workInProgress.child;
|
10956 |
|
10957 | while (node !== null) {
|
10958 | if (node.tag === HostComponent || node.tag === HostText) {
|
10959 | appendInitialChild(parent, node.stateNode);
|
10960 | } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
|
10961 | appendInitialChild(parent, node.stateNode.instance);
|
10962 | } else if (node.tag === HostPortal) {
|
10963 |
|
10964 |
|
10965 | } else if (node.child !== null) {
|
10966 | node.child.return = node;
|
10967 | node = node.child;
|
10968 | continue;
|
10969 | }
|
10970 |
|
10971 | if (node === workInProgress) {
|
10972 | return;
|
10973 | }
|
10974 |
|
10975 | while (node.sibling === null) {
|
10976 | if (node.return === null || node.return === workInProgress) {
|
10977 | return;
|
10978 | }
|
10979 |
|
10980 | node = node.return;
|
10981 | }
|
10982 |
|
10983 | node.sibling.return = node.return;
|
10984 | node = node.sibling;
|
10985 | }
|
10986 | };
|
10987 |
|
10988 | updateHostContainer = function (workInProgress) {
|
10989 | };
|
10990 |
|
10991 | updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
10992 |
|
10993 |
|
10994 | var oldProps = current.memoizedProps;
|
10995 |
|
10996 | if (oldProps === newProps) {
|
10997 |
|
10998 |
|
10999 | return;
|
11000 | }
|
11001 |
|
11002 |
|
11003 |
|
11004 |
|
11005 |
|
11006 | var instance = workInProgress.stateNode;
|
11007 | var currentHostContext = getHostContext();
|
11008 |
|
11009 |
|
11010 |
|
11011 | var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
|
11012 |
|
11013 | workInProgress.updateQueue = updatePayload;
|
11014 |
|
11015 |
|
11016 | if (updatePayload) {
|
11017 | markUpdate(workInProgress);
|
11018 | }
|
11019 | };
|
11020 |
|
11021 | updateHostText$1 = function (current, workInProgress, oldText, newText) {
|
11022 |
|
11023 | if (oldText !== newText) {
|
11024 | markUpdate(workInProgress);
|
11025 | }
|
11026 | };
|
11027 | } else if (supportsPersistence) {
|
11028 |
|
11029 | appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
|
11030 |
|
11031 |
|
11032 | var node = workInProgress.child;
|
11033 |
|
11034 | while (node !== null) {
|
11035 |
|
11036 | branches: if (node.tag === HostComponent) {
|
11037 | var instance = node.stateNode;
|
11038 |
|
11039 | if (needsVisibilityToggle && isHidden) {
|
11040 |
|
11041 | var props = node.memoizedProps;
|
11042 | var type = node.type;
|
11043 | instance = cloneHiddenInstance(instance, type, props, node);
|
11044 | }
|
11045 |
|
11046 | appendInitialChild(parent, instance);
|
11047 | } else if (node.tag === HostText) {
|
11048 | var _instance = node.stateNode;
|
11049 |
|
11050 | if (needsVisibilityToggle && isHidden) {
|
11051 |
|
11052 | var text = node.memoizedProps;
|
11053 | _instance = cloneHiddenTextInstance(_instance, text, node);
|
11054 | }
|
11055 |
|
11056 | appendInitialChild(parent, _instance);
|
11057 | } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
|
11058 | var _instance2 = node.stateNode.instance;
|
11059 |
|
11060 | if (needsVisibilityToggle && isHidden) {
|
11061 |
|
11062 | var _props = node.memoizedProps;
|
11063 | var _type = node.type;
|
11064 | _instance2 = cloneHiddenInstance(_instance2, _type, _props, node);
|
11065 | }
|
11066 |
|
11067 | appendInitialChild(parent, _instance2);
|
11068 | } else if (node.tag === HostPortal) {
|
11069 |
|
11070 |
|
11071 | } else if (node.tag === SuspenseComponent) {
|
11072 | if ((node.effectTag & Update) !== NoEffect) {
|
11073 |
|
11074 | var newIsHidden = node.memoizedState !== null;
|
11075 |
|
11076 | if (newIsHidden) {
|
11077 | var primaryChildParent = node.child;
|
11078 |
|
11079 | if (primaryChildParent !== null) {
|
11080 | if (primaryChildParent.child !== null) {
|
11081 | primaryChildParent.child.return = primaryChildParent;
|
11082 | appendAllChildren(parent, primaryChildParent, true, newIsHidden);
|
11083 | }
|
11084 |
|
11085 | var fallbackChildParent = primaryChildParent.sibling;
|
11086 |
|
11087 | if (fallbackChildParent !== null) {
|
11088 | fallbackChildParent.return = node;
|
11089 | node = fallbackChildParent;
|
11090 | continue;
|
11091 | }
|
11092 | }
|
11093 | }
|
11094 | }
|
11095 |
|
11096 | if (node.child !== null) {
|
11097 |
|
11098 | node.child.return = node;
|
11099 | node = node.child;
|
11100 | continue;
|
11101 | }
|
11102 | } else if (node.child !== null) {
|
11103 | node.child.return = node;
|
11104 | node = node.child;
|
11105 | continue;
|
11106 | }
|
11107 |
|
11108 |
|
11109 | node = node;
|
11110 |
|
11111 | if (node === workInProgress) {
|
11112 | return;
|
11113 | }
|
11114 |
|
11115 | while (node.sibling === null) {
|
11116 | if (node.return === null || node.return === workInProgress) {
|
11117 | return;
|
11118 | }
|
11119 |
|
11120 | node = node.return;
|
11121 | }
|
11122 |
|
11123 | node.sibling.return = node.return;
|
11124 | node = node.sibling;
|
11125 | }
|
11126 | };
|
11127 |
|
11128 |
|
11129 | var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
|
11130 |
|
11131 |
|
11132 | var node = workInProgress.child;
|
11133 |
|
11134 | while (node !== null) {
|
11135 |
|
11136 | branches: if (node.tag === HostComponent) {
|
11137 | var instance = node.stateNode;
|
11138 |
|
11139 | if (needsVisibilityToggle && isHidden) {
|
11140 |
|
11141 | var props = node.memoizedProps;
|
11142 | var type = node.type;
|
11143 | instance = cloneHiddenInstance(instance, type, props, node);
|
11144 | }
|
11145 |
|
11146 | appendChildToContainerChildSet(containerChildSet, instance);
|
11147 | } else if (node.tag === HostText) {
|
11148 | var _instance3 = node.stateNode;
|
11149 |
|
11150 | if (needsVisibilityToggle && isHidden) {
|
11151 |
|
11152 | var text = node.memoizedProps;
|
11153 | _instance3 = cloneHiddenTextInstance(_instance3, text, node);
|
11154 | }
|
11155 |
|
11156 | appendChildToContainerChildSet(containerChildSet, _instance3);
|
11157 | } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
|
11158 | var _instance4 = node.stateNode.instance;
|
11159 |
|
11160 | if (needsVisibilityToggle && isHidden) {
|
11161 |
|
11162 | var _props2 = node.memoizedProps;
|
11163 | var _type2 = node.type;
|
11164 | _instance4 = cloneHiddenInstance(_instance4, _type2, _props2, node);
|
11165 | }
|
11166 |
|
11167 | appendChildToContainerChildSet(containerChildSet, _instance4);
|
11168 | } else if (node.tag === HostPortal) {
|
11169 |
|
11170 |
|
11171 | } else if (node.tag === SuspenseComponent) {
|
11172 | if ((node.effectTag & Update) !== NoEffect) {
|
11173 |
|
11174 | var newIsHidden = node.memoizedState !== null;
|
11175 |
|
11176 | if (newIsHidden) {
|
11177 | var primaryChildParent = node.child;
|
11178 |
|
11179 | if (primaryChildParent !== null) {
|
11180 | if (primaryChildParent.child !== null) {
|
11181 | primaryChildParent.child.return = primaryChildParent;
|
11182 | appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
|
11183 | }
|
11184 |
|
11185 | var fallbackChildParent = primaryChildParent.sibling;
|
11186 |
|
11187 | if (fallbackChildParent !== null) {
|
11188 | fallbackChildParent.return = node;
|
11189 | node = fallbackChildParent;
|
11190 | continue;
|
11191 | }
|
11192 | }
|
11193 | }
|
11194 | }
|
11195 |
|
11196 | if (node.child !== null) {
|
11197 |
|
11198 | node.child.return = node;
|
11199 | node = node.child;
|
11200 | continue;
|
11201 | }
|
11202 | } else if (node.child !== null) {
|
11203 | node.child.return = node;
|
11204 | node = node.child;
|
11205 | continue;
|
11206 | }
|
11207 |
|
11208 |
|
11209 | node = node;
|
11210 |
|
11211 | if (node === workInProgress) {
|
11212 | return;
|
11213 | }
|
11214 |
|
11215 | while (node.sibling === null) {
|
11216 | if (node.return === null || node.return === workInProgress) {
|
11217 | return;
|
11218 | }
|
11219 |
|
11220 | node = node.return;
|
11221 | }
|
11222 |
|
11223 | node.sibling.return = node.return;
|
11224 | node = node.sibling;
|
11225 | }
|
11226 | };
|
11227 |
|
11228 | updateHostContainer = function (workInProgress) {
|
11229 | var portalOrRoot = workInProgress.stateNode;
|
11230 | var childrenUnchanged = workInProgress.firstEffect === null;
|
11231 |
|
11232 | if (childrenUnchanged) {
|
11233 | } else {
|
11234 | var container = portalOrRoot.containerInfo;
|
11235 | var newChildSet = createContainerChildSet(container);
|
11236 |
|
11237 | appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
|
11238 | portalOrRoot.pendingChildren = newChildSet;
|
11239 |
|
11240 | markUpdate(workInProgress);
|
11241 | finalizeContainerChildren(container, newChildSet);
|
11242 | }
|
11243 | };
|
11244 |
|
11245 | updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
11246 | var currentInstance = current.stateNode;
|
11247 | var oldProps = current.memoizedProps;
|
11248 |
|
11249 |
|
11250 | var childrenUnchanged = workInProgress.firstEffect === null;
|
11251 |
|
11252 | if (childrenUnchanged && oldProps === newProps) {
|
11253 |
|
11254 |
|
11255 | workInProgress.stateNode = currentInstance;
|
11256 | return;
|
11257 | }
|
11258 |
|
11259 | var recyclableInstance = workInProgress.stateNode;
|
11260 | var currentHostContext = getHostContext();
|
11261 | var updatePayload = null;
|
11262 |
|
11263 | if (oldProps !== newProps) {
|
11264 | updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
|
11265 | }
|
11266 |
|
11267 | if (childrenUnchanged && updatePayload === null) {
|
11268 |
|
11269 |
|
11270 | workInProgress.stateNode = currentInstance;
|
11271 | return;
|
11272 | }
|
11273 |
|
11274 | var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
|
11275 |
|
11276 | if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
|
11277 | markUpdate(workInProgress);
|
11278 | }
|
11279 |
|
11280 | workInProgress.stateNode = newInstance;
|
11281 |
|
11282 | if (childrenUnchanged) {
|
11283 |
|
11284 |
|
11285 |
|
11286 | markUpdate(workInProgress);
|
11287 | } else {
|
11288 |
|
11289 | appendAllChildren(newInstance, workInProgress, false, false);
|
11290 | }
|
11291 | };
|
11292 |
|
11293 | updateHostText$1 = function (current, workInProgress, oldText, newText) {
|
11294 | if (oldText !== newText) {
|
11295 |
|
11296 | var rootContainerInstance = getRootHostContainer();
|
11297 | var currentHostContext = getHostContext();
|
11298 | workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress);
|
11299 |
|
11300 |
|
11301 | markUpdate(workInProgress);
|
11302 | }
|
11303 | };
|
11304 | } else {
|
11305 |
|
11306 | updateHostContainer = function (workInProgress) {
|
11307 | };
|
11308 |
|
11309 | updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
11310 | };
|
11311 |
|
11312 | updateHostText$1 = function (current, workInProgress, oldText, newText) {
|
11313 | };
|
11314 | }
|
11315 |
|
11316 | function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
|
11317 | switch (renderState.tailMode) {
|
11318 | case 'hidden':
|
11319 | {
|
11320 |
|
11321 |
|
11322 |
|
11323 |
|
11324 |
|
11325 | var tailNode = renderState.tail;
|
11326 | var lastTailNode = null;
|
11327 |
|
11328 | while (tailNode !== null) {
|
11329 | if (tailNode.alternate !== null) {
|
11330 | lastTailNode = tailNode;
|
11331 | }
|
11332 |
|
11333 | tailNode = tailNode.sibling;
|
11334 | }
|
11335 |
|
11336 |
|
11337 |
|
11338 | if (lastTailNode === null) {
|
11339 |
|
11340 | renderState.tail = null;
|
11341 | } else {
|
11342 |
|
11343 |
|
11344 | lastTailNode.sibling = null;
|
11345 | }
|
11346 |
|
11347 | break;
|
11348 | }
|
11349 |
|
11350 | case 'collapsed':
|
11351 | {
|
11352 |
|
11353 |
|
11354 |
|
11355 |
|
11356 |
|
11357 | var _tailNode = renderState.tail;
|
11358 | var _lastTailNode = null;
|
11359 |
|
11360 | while (_tailNode !== null) {
|
11361 | if (_tailNode.alternate !== null) {
|
11362 | _lastTailNode = _tailNode;
|
11363 | }
|
11364 |
|
11365 | _tailNode = _tailNode.sibling;
|
11366 | }
|
11367 |
|
11368 |
|
11369 |
|
11370 | if (_lastTailNode === null) {
|
11371 |
|
11372 | if (!hasRenderedATailFallback && renderState.tail !== null) {
|
11373 |
|
11374 |
|
11375 | renderState.tail.sibling = null;
|
11376 | } else {
|
11377 | renderState.tail = null;
|
11378 | }
|
11379 | } else {
|
11380 |
|
11381 |
|
11382 | _lastTailNode.sibling = null;
|
11383 | }
|
11384 |
|
11385 | break;
|
11386 | }
|
11387 | }
|
11388 | }
|
11389 |
|
11390 | function completeWork(current, workInProgress, renderExpirationTime) {
|
11391 | var newProps = workInProgress.pendingProps;
|
11392 |
|
11393 | switch (workInProgress.tag) {
|
11394 | case IndeterminateComponent:
|
11395 | break;
|
11396 |
|
11397 | case LazyComponent:
|
11398 | break;
|
11399 |
|
11400 | case SimpleMemoComponent:
|
11401 | case FunctionComponent:
|
11402 | break;
|
11403 |
|
11404 | case ClassComponent:
|
11405 | {
|
11406 | var Component = workInProgress.type;
|
11407 |
|
11408 | if (isContextProvider(Component)) {
|
11409 | popContext(workInProgress);
|
11410 | }
|
11411 |
|
11412 | break;
|
11413 | }
|
11414 |
|
11415 | case HostRoot:
|
11416 | {
|
11417 | popHostContainer(workInProgress);
|
11418 | popTopLevelContextObject(workInProgress);
|
11419 | var fiberRoot = workInProgress.stateNode;
|
11420 |
|
11421 | if (fiberRoot.pendingContext) {
|
11422 | fiberRoot.context = fiberRoot.pendingContext;
|
11423 | fiberRoot.pendingContext = null;
|
11424 | }
|
11425 |
|
11426 | if (current === null || current.child === null) {
|
11427 |
|
11428 |
|
11429 | var wasHydrated = popHydrationState(workInProgress);
|
11430 |
|
11431 | if (wasHydrated) {
|
11432 |
|
11433 |
|
11434 | markUpdate(workInProgress);
|
11435 | }
|
11436 | }
|
11437 |
|
11438 | updateHostContainer(workInProgress);
|
11439 | break;
|
11440 | }
|
11441 |
|
11442 | case HostComponent:
|
11443 | {
|
11444 | popHostContext(workInProgress);
|
11445 | var rootContainerInstance = getRootHostContainer();
|
11446 | var type = workInProgress.type;
|
11447 |
|
11448 | if (current !== null && workInProgress.stateNode != null) {
|
11449 | updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
|
11450 |
|
11451 | if (enableFlareAPI) {
|
11452 | var prevListeners = current.memoizedProps.listeners;
|
11453 | var nextListeners = newProps.listeners;
|
11454 |
|
11455 | if (prevListeners !== nextListeners) {
|
11456 | markUpdate(workInProgress);
|
11457 | }
|
11458 | }
|
11459 |
|
11460 | if (current.ref !== workInProgress.ref) {
|
11461 | markRef$1(workInProgress);
|
11462 | }
|
11463 | } else {
|
11464 | if (!newProps) {
|
11465 | if (!(workInProgress.stateNode !== null)) {
|
11466 | {
|
11467 | throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
|
11468 | }
|
11469 | }
|
11470 |
|
11471 |
|
11472 | break;
|
11473 | }
|
11474 |
|
11475 | var currentHostContext = getHostContext();
|
11476 |
|
11477 |
|
11478 |
|
11479 |
|
11480 | var _wasHydrated = popHydrationState(workInProgress);
|
11481 |
|
11482 | if (_wasHydrated) {
|
11483 |
|
11484 |
|
11485 | if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
|
11486 |
|
11487 |
|
11488 | markUpdate(workInProgress);
|
11489 | }
|
11490 |
|
11491 | if (enableFlareAPI) {
|
11492 | var listeners = newProps.listeners;
|
11493 |
|
11494 | if (listeners != null) {
|
11495 | updateEventListeners(listeners, workInProgress, rootContainerInstance);
|
11496 | }
|
11497 | }
|
11498 | } else {
|
11499 | var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
|
11500 | appendAllChildren(instance, workInProgress, false, false);
|
11501 |
|
11502 | workInProgress.stateNode = instance;
|
11503 |
|
11504 | if (enableFlareAPI) {
|
11505 | var _listeners = newProps.listeners;
|
11506 |
|
11507 | if (_listeners != null) {
|
11508 | updateEventListeners(_listeners, workInProgress, rootContainerInstance);
|
11509 | }
|
11510 | }
|
11511 |
|
11512 |
|
11513 |
|
11514 |
|
11515 | if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
|
11516 | markUpdate(workInProgress);
|
11517 | }
|
11518 | }
|
11519 |
|
11520 | if (workInProgress.ref !== null) {
|
11521 |
|
11522 | markRef$1(workInProgress);
|
11523 | }
|
11524 | }
|
11525 |
|
11526 | break;
|
11527 | }
|
11528 |
|
11529 | case HostText:
|
11530 | {
|
11531 | var newText = newProps;
|
11532 |
|
11533 | if (current && workInProgress.stateNode != null) {
|
11534 | var oldText = current.memoizedProps;
|
11535 |
|
11536 |
|
11537 | updateHostText$1(current, workInProgress, oldText, newText);
|
11538 | } else {
|
11539 | if (typeof newText !== 'string') {
|
11540 | if (!(workInProgress.stateNode !== null)) {
|
11541 | {
|
11542 | throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
|
11543 | }
|
11544 | }
|
11545 |
|
11546 | }
|
11547 |
|
11548 | var _rootContainerInstance = getRootHostContainer();
|
11549 |
|
11550 | var _currentHostContext = getHostContext();
|
11551 |
|
11552 | var _wasHydrated2 = popHydrationState(workInProgress);
|
11553 |
|
11554 | if (_wasHydrated2) {
|
11555 | if (prepareToHydrateHostTextInstance(workInProgress)) {
|
11556 | markUpdate(workInProgress);
|
11557 | }
|
11558 | } else {
|
11559 | workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
|
11560 | }
|
11561 | }
|
11562 |
|
11563 | break;
|
11564 | }
|
11565 |
|
11566 | case ForwardRef:
|
11567 | break;
|
11568 |
|
11569 | case SuspenseComponent:
|
11570 | {
|
11571 | popSuspenseContext(workInProgress);
|
11572 | var nextState = workInProgress.memoizedState;
|
11573 |
|
11574 | if (enableSuspenseServerRenderer) {
|
11575 | if (nextState !== null && nextState.dehydrated !== null) {
|
11576 | if (current === null) {
|
11577 | var _wasHydrated3 = popHydrationState(workInProgress);
|
11578 |
|
11579 | if (!_wasHydrated3) {
|
11580 | {
|
11581 | throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");
|
11582 | }
|
11583 | }
|
11584 |
|
11585 | prepareToHydrateHostSuspenseInstance(workInProgress);
|
11586 |
|
11587 | if (enableSchedulerTracing) {
|
11588 | markSpawnedWork(Never);
|
11589 | }
|
11590 |
|
11591 | return null;
|
11592 | } else {
|
11593 |
|
11594 |
|
11595 |
|
11596 |
|
11597 | resetHydrationState();
|
11598 |
|
11599 | if ((workInProgress.effectTag & DidCapture) === NoEffect) {
|
11600 |
|
11601 | workInProgress.memoizedState = null;
|
11602 | }
|
11603 |
|
11604 |
|
11605 |
|
11606 |
|
11607 |
|
11608 |
|
11609 | workInProgress.effectTag |= Update;
|
11610 | return null;
|
11611 | }
|
11612 | }
|
11613 | }
|
11614 |
|
11615 | if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
|
11616 |
|
11617 | workInProgress.expirationTime = renderExpirationTime;
|
11618 |
|
11619 | return workInProgress;
|
11620 | }
|
11621 |
|
11622 | var nextDidTimeout = nextState !== null;
|
11623 | var prevDidTimeout = false;
|
11624 |
|
11625 | if (current === null) {
|
11626 | if (workInProgress.memoizedProps.fallback !== undefined) {
|
11627 | popHydrationState(workInProgress);
|
11628 | }
|
11629 | } else {
|
11630 | var prevState = current.memoizedState;
|
11631 | prevDidTimeout = prevState !== null;
|
11632 |
|
11633 | if (!nextDidTimeout && prevState !== null) {
|
11634 |
|
11635 |
|
11636 |
|
11637 |
|
11638 | var currentFallbackChild = current.child.sibling;
|
11639 |
|
11640 | if (currentFallbackChild !== null) {
|
11641 |
|
11642 | var first = workInProgress.firstEffect;
|
11643 |
|
11644 | if (first !== null) {
|
11645 | workInProgress.firstEffect = currentFallbackChild;
|
11646 | currentFallbackChild.nextEffect = first;
|
11647 | } else {
|
11648 | workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
|
11649 | currentFallbackChild.nextEffect = null;
|
11650 | }
|
11651 |
|
11652 | currentFallbackChild.effectTag = Deletion;
|
11653 | }
|
11654 | }
|
11655 | }
|
11656 |
|
11657 | if (nextDidTimeout && !prevDidTimeout) {
|
11658 |
|
11659 |
|
11660 |
|
11661 |
|
11662 |
|
11663 | if ((workInProgress.mode & BatchedMode) !== NoMode) {
|
11664 |
|
11665 |
|
11666 |
|
11667 |
|
11668 |
|
11669 |
|
11670 |
|
11671 | var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
|
11672 |
|
11673 | if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
|
11674 |
|
11675 |
|
11676 | renderDidSuspend();
|
11677 | } else {
|
11678 |
|
11679 |
|
11680 | renderDidSuspendDelayIfPossible();
|
11681 | }
|
11682 | }
|
11683 | }
|
11684 |
|
11685 | if (supportsPersistence) {
|
11686 |
|
11687 | if (nextDidTimeout) {
|
11688 |
|
11689 |
|
11690 |
|
11691 | workInProgress.effectTag |= Update;
|
11692 | }
|
11693 | }
|
11694 |
|
11695 | if (supportsMutation) {
|
11696 |
|
11697 | if (nextDidTimeout || prevDidTimeout) {
|
11698 |
|
11699 |
|
11700 |
|
11701 |
|
11702 |
|
11703 | workInProgress.effectTag |= Update;
|
11704 | }
|
11705 | }
|
11706 |
|
11707 | if (enableSuspenseCallback && workInProgress.updateQueue !== null && workInProgress.memoizedProps.suspenseCallback != null) {
|
11708 |
|
11709 | workInProgress.effectTag |= Update;
|
11710 | }
|
11711 |
|
11712 | break;
|
11713 | }
|
11714 |
|
11715 | case Fragment:
|
11716 | break;
|
11717 |
|
11718 | case Mode:
|
11719 | break;
|
11720 |
|
11721 | case Profiler:
|
11722 | break;
|
11723 |
|
11724 | case HostPortal:
|
11725 | popHostContainer(workInProgress);
|
11726 | updateHostContainer(workInProgress);
|
11727 | break;
|
11728 |
|
11729 | case ContextProvider:
|
11730 |
|
11731 | popProvider(workInProgress);
|
11732 | break;
|
11733 |
|
11734 | case ContextConsumer:
|
11735 | break;
|
11736 |
|
11737 | case MemoComponent:
|
11738 | break;
|
11739 |
|
11740 | case IncompleteClassComponent:
|
11741 | {
|
11742 |
|
11743 |
|
11744 | var _Component = workInProgress.type;
|
11745 |
|
11746 | if (isContextProvider(_Component)) {
|
11747 | popContext(workInProgress);
|
11748 | }
|
11749 |
|
11750 | break;
|
11751 | }
|
11752 |
|
11753 | case SuspenseListComponent:
|
11754 | {
|
11755 | popSuspenseContext(workInProgress);
|
11756 | var renderState = workInProgress.memoizedState;
|
11757 |
|
11758 | if (renderState === null) {
|
11759 |
|
11760 |
|
11761 | break;
|
11762 | }
|
11763 |
|
11764 | var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
|
11765 | var renderedTail = renderState.rendering;
|
11766 |
|
11767 | if (renderedTail === null) {
|
11768 |
|
11769 | if (!didSuspendAlready) {
|
11770 |
|
11771 |
|
11772 |
|
11773 |
|
11774 |
|
11775 |
|
11776 |
|
11777 |
|
11778 |
|
11779 | var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
|
11780 |
|
11781 | if (!cannotBeSuspended) {
|
11782 | var row = workInProgress.child;
|
11783 |
|
11784 | while (row !== null) {
|
11785 | var suspended = findFirstSuspended(row);
|
11786 |
|
11787 | if (suspended !== null) {
|
11788 | didSuspendAlready = true;
|
11789 | workInProgress.effectTag |= DidCapture;
|
11790 | cutOffTailIfNeeded(renderState, false);
|
11791 |
|
11792 |
|
11793 |
|
11794 |
|
11795 |
|
11796 |
|
11797 |
|
11798 |
|
11799 |
|
11800 |
|
11801 |
|
11802 |
|
11803 | var newThennables = suspended.updateQueue;
|
11804 |
|
11805 | if (newThennables !== null) {
|
11806 | workInProgress.updateQueue = newThennables;
|
11807 | workInProgress.effectTag |= Update;
|
11808 | }
|
11809 |
|
11810 |
|
11811 |
|
11812 |
|
11813 | if (renderState.lastEffect === null) {
|
11814 | workInProgress.firstEffect = null;
|
11815 | }
|
11816 |
|
11817 | workInProgress.lastEffect = renderState.lastEffect;
|
11818 |
|
11819 | resetChildFibers(workInProgress, renderExpirationTime);
|
11820 |
|
11821 |
|
11822 | pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
|
11823 | return workInProgress.child;
|
11824 | }
|
11825 |
|
11826 | row = row.sibling;
|
11827 | }
|
11828 | }
|
11829 | } else {
|
11830 | cutOffTailIfNeeded(renderState, false);
|
11831 | }
|
11832 |
|
11833 | } else {
|
11834 |
|
11835 | if (!didSuspendAlready) {
|
11836 | var _suspended = findFirstSuspended(renderedTail);
|
11837 |
|
11838 | if (_suspended !== null) {
|
11839 | workInProgress.effectTag |= DidCapture;
|
11840 | didSuspendAlready = true;
|
11841 |
|
11842 |
|
11843 | var _newThennables = _suspended.updateQueue;
|
11844 |
|
11845 | if (_newThennables !== null) {
|
11846 | workInProgress.updateQueue = _newThennables;
|
11847 | workInProgress.effectTag |= Update;
|
11848 | }
|
11849 |
|
11850 | cutOffTailIfNeeded(renderState, true);
|
11851 |
|
11852 | if (renderState.tail === null && renderState.tailMode === 'hidden') {
|
11853 |
|
11854 |
|
11855 |
|
11856 | var lastEffect = workInProgress.lastEffect = renderState.lastEffect;
|
11857 |
|
11858 | if (lastEffect !== null) {
|
11859 | lastEffect.nextEffect = null;
|
11860 | }
|
11861 |
|
11862 |
|
11863 | return null;
|
11864 | }
|
11865 | } else if (now() > renderState.tailExpiration && renderExpirationTime > Never) {
|
11866 |
|
11867 |
|
11868 |
|
11869 | workInProgress.effectTag |= DidCapture;
|
11870 | didSuspendAlready = true;
|
11871 | cutOffTailIfNeeded(renderState, false);
|
11872 |
|
11873 |
|
11874 |
|
11875 |
|
11876 |
|
11877 | var nextPriority = renderExpirationTime - 1;
|
11878 | workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
|
11879 |
|
11880 | if (enableSchedulerTracing) {
|
11881 | markSpawnedWork(nextPriority);
|
11882 | }
|
11883 | }
|
11884 | }
|
11885 |
|
11886 | if (renderState.isBackwards) {
|
11887 |
|
11888 |
|
11889 |
|
11890 |
|
11891 |
|
11892 | renderedTail.sibling = workInProgress.child;
|
11893 | workInProgress.child = renderedTail;
|
11894 | } else {
|
11895 | var previousSibling = renderState.last;
|
11896 |
|
11897 | if (previousSibling !== null) {
|
11898 | previousSibling.sibling = renderedTail;
|
11899 | } else {
|
11900 | workInProgress.child = renderedTail;
|
11901 | }
|
11902 |
|
11903 | renderState.last = renderedTail;
|
11904 | }
|
11905 | }
|
11906 |
|
11907 | if (renderState.tail !== null) {
|
11908 |
|
11909 | if (renderState.tailExpiration === 0) {
|
11910 |
|
11911 |
|
11912 | var TAIL_EXPIRATION_TIMEOUT_MS = 500;
|
11913 | renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS;
|
11914 | }
|
11915 |
|
11916 |
|
11917 | var next = renderState.tail;
|
11918 | renderState.rendering = next;
|
11919 | renderState.tail = next.sibling;
|
11920 | renderState.lastEffect = workInProgress.lastEffect;
|
11921 | next.sibling = null;
|
11922 |
|
11923 |
|
11924 |
|
11925 | var suspenseContext = suspenseStackCursor.current;
|
11926 |
|
11927 | if (didSuspendAlready) {
|
11928 | suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
11929 | } else {
|
11930 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
11931 | }
|
11932 |
|
11933 | pushSuspenseContext(workInProgress, suspenseContext);
|
11934 |
|
11935 | return next;
|
11936 | }
|
11937 |
|
11938 | break;
|
11939 | }
|
11940 |
|
11941 | case FundamentalComponent:
|
11942 | {
|
11943 | if (enableFundamentalAPI) {
|
11944 | var fundamentalImpl = workInProgress.type.impl;
|
11945 | var fundamentalInstance = workInProgress.stateNode;
|
11946 |
|
11947 | if (fundamentalInstance === null) {
|
11948 | var getInitialState = fundamentalImpl.getInitialState;
|
11949 | var fundamentalState;
|
11950 |
|
11951 | if (getInitialState !== undefined) {
|
11952 | fundamentalState = getInitialState(newProps);
|
11953 | }
|
11954 |
|
11955 | fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance(workInProgress, newProps, fundamentalImpl, fundamentalState || {});
|
11956 |
|
11957 | var _instance5 = getFundamentalComponentInstance(fundamentalInstance);
|
11958 |
|
11959 | fundamentalInstance.instance = _instance5;
|
11960 |
|
11961 | if (fundamentalImpl.reconcileChildren === false) {
|
11962 | return null;
|
11963 | }
|
11964 |
|
11965 | appendAllChildren(_instance5, workInProgress, false, false);
|
11966 | mountFundamentalComponent(fundamentalInstance);
|
11967 | } else {
|
11968 |
|
11969 | var prevProps = fundamentalInstance.props;
|
11970 | fundamentalInstance.prevProps = prevProps;
|
11971 | fundamentalInstance.props = newProps;
|
11972 | fundamentalInstance.currentFiber = workInProgress;
|
11973 |
|
11974 | if (supportsPersistence) {
|
11975 | var _instance6 = cloneFundamentalInstance(fundamentalInstance);
|
11976 |
|
11977 | fundamentalInstance.instance = _instance6;
|
11978 | appendAllChildren(_instance6, workInProgress, false, false);
|
11979 | }
|
11980 |
|
11981 | var shouldUpdate = shouldUpdateFundamentalComponent(fundamentalInstance);
|
11982 |
|
11983 | if (shouldUpdate) {
|
11984 | markUpdate(workInProgress);
|
11985 | }
|
11986 | }
|
11987 | }
|
11988 |
|
11989 | break;
|
11990 | }
|
11991 |
|
11992 | case ScopeComponent:
|
11993 | {
|
11994 | if (enableScopeAPI) {
|
11995 | if (current === null) {
|
11996 | var _type3 = workInProgress.type;
|
11997 | var scopeInstance = {
|
11998 | fiber: workInProgress,
|
11999 | methods: null
|
12000 | };
|
12001 | workInProgress.stateNode = scopeInstance;
|
12002 | scopeInstance.methods = createScopeMethods(_type3, scopeInstance);
|
12003 |
|
12004 | if (enableFlareAPI) {
|
12005 | var _listeners2 = newProps.listeners;
|
12006 |
|
12007 | if (_listeners2 != null) {
|
12008 | var _rootContainerInstance2 = getRootHostContainer();
|
12009 |
|
12010 | updateEventListeners(_listeners2, workInProgress, _rootContainerInstance2);
|
12011 | }
|
12012 | }
|
12013 |
|
12014 | if (workInProgress.ref !== null) {
|
12015 | markRef$1(workInProgress);
|
12016 | markUpdate(workInProgress);
|
12017 | }
|
12018 | } else {
|
12019 | if (enableFlareAPI) {
|
12020 | var _prevListeners = current.memoizedProps.listeners;
|
12021 | var _nextListeners = newProps.listeners;
|
12022 |
|
12023 | if (_prevListeners !== _nextListeners || workInProgress.ref !== null) {
|
12024 | markUpdate(workInProgress);
|
12025 | }
|
12026 | } else {
|
12027 | if (workInProgress.ref !== null) {
|
12028 | markUpdate(workInProgress);
|
12029 | }
|
12030 | }
|
12031 |
|
12032 | if (current.ref !== workInProgress.ref) {
|
12033 | markRef$1(workInProgress);
|
12034 | }
|
12035 | }
|
12036 | }
|
12037 |
|
12038 | break;
|
12039 | }
|
12040 |
|
12041 | default:
|
12042 | {
|
12043 | {
|
12044 | throw Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue.");
|
12045 | }
|
12046 | }
|
12047 |
|
12048 | }
|
12049 |
|
12050 | return null;
|
12051 | }
|
12052 |
|
12053 | function unwindWork(workInProgress, renderExpirationTime) {
|
12054 | switch (workInProgress.tag) {
|
12055 | case ClassComponent:
|
12056 | {
|
12057 | var Component = workInProgress.type;
|
12058 |
|
12059 | if (isContextProvider(Component)) {
|
12060 | popContext(workInProgress);
|
12061 | }
|
12062 |
|
12063 | var effectTag = workInProgress.effectTag;
|
12064 |
|
12065 | if (effectTag & ShouldCapture) {
|
12066 | workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
|
12067 | return workInProgress;
|
12068 | }
|
12069 |
|
12070 | return null;
|
12071 | }
|
12072 |
|
12073 | case HostRoot:
|
12074 | {
|
12075 | popHostContainer(workInProgress);
|
12076 | popTopLevelContextObject(workInProgress);
|
12077 | var _effectTag = workInProgress.effectTag;
|
12078 |
|
12079 | if (!((_effectTag & DidCapture) === NoEffect)) {
|
12080 | {
|
12081 | throw Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue.");
|
12082 | }
|
12083 | }
|
12084 |
|
12085 | workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
|
12086 | return workInProgress;
|
12087 | }
|
12088 |
|
12089 | case HostComponent:
|
12090 | {
|
12091 |
|
12092 | popHostContext(workInProgress);
|
12093 | return null;
|
12094 | }
|
12095 |
|
12096 | case SuspenseComponent:
|
12097 | {
|
12098 | popSuspenseContext(workInProgress);
|
12099 |
|
12100 | if (enableSuspenseServerRenderer) {
|
12101 | var suspenseState = workInProgress.memoizedState;
|
12102 |
|
12103 | if (suspenseState !== null && suspenseState.dehydrated !== null) {
|
12104 | if (!(workInProgress.alternate !== null)) {
|
12105 | {
|
12106 | throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");
|
12107 | }
|
12108 | }
|
12109 |
|
12110 | resetHydrationState();
|
12111 | }
|
12112 | }
|
12113 |
|
12114 | var _effectTag2 = workInProgress.effectTag;
|
12115 |
|
12116 | if (_effectTag2 & ShouldCapture) {
|
12117 | workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
|
12118 |
|
12119 | return workInProgress;
|
12120 | }
|
12121 |
|
12122 | return null;
|
12123 | }
|
12124 |
|
12125 | case SuspenseListComponent:
|
12126 | {
|
12127 | popSuspenseContext(workInProgress);
|
12128 |
|
12129 |
|
12130 | return null;
|
12131 | }
|
12132 |
|
12133 | case HostPortal:
|
12134 | popHostContainer(workInProgress);
|
12135 | return null;
|
12136 |
|
12137 | case ContextProvider:
|
12138 | popProvider(workInProgress);
|
12139 | return null;
|
12140 |
|
12141 | default:
|
12142 | return null;
|
12143 | }
|
12144 | }
|
12145 |
|
12146 | function unwindInterruptedWork(interruptedWork) {
|
12147 | switch (interruptedWork.tag) {
|
12148 | case ClassComponent:
|
12149 | {
|
12150 | var childContextTypes = interruptedWork.type.childContextTypes;
|
12151 |
|
12152 | if (childContextTypes !== null && childContextTypes !== undefined) {
|
12153 | popContext(interruptedWork);
|
12154 | }
|
12155 |
|
12156 | break;
|
12157 | }
|
12158 |
|
12159 | case HostRoot:
|
12160 | {
|
12161 | popHostContainer(interruptedWork);
|
12162 | popTopLevelContextObject(interruptedWork);
|
12163 | break;
|
12164 | }
|
12165 |
|
12166 | case HostComponent:
|
12167 | {
|
12168 | popHostContext(interruptedWork);
|
12169 | break;
|
12170 | }
|
12171 |
|
12172 | case HostPortal:
|
12173 | popHostContainer(interruptedWork);
|
12174 | break;
|
12175 |
|
12176 | case SuspenseComponent:
|
12177 | popSuspenseContext(interruptedWork);
|
12178 | break;
|
12179 |
|
12180 | case SuspenseListComponent:
|
12181 | popSuspenseContext(interruptedWork);
|
12182 | break;
|
12183 |
|
12184 | case ContextProvider:
|
12185 | popProvider(interruptedWork);
|
12186 | break;
|
12187 |
|
12188 | default:
|
12189 | break;
|
12190 | }
|
12191 | }
|
12192 |
|
12193 | function createCapturedValue(value, source) {
|
12194 |
|
12195 |
|
12196 | return {
|
12197 | value: value,
|
12198 | source: source,
|
12199 | stack: getStackByFiberInDevAndProd(source)
|
12200 | };
|
12201 | }
|
12202 |
|
12203 | var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
|
12204 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
12205 |
|
12206 | try {
|
12207 | func.apply(context, funcArgs);
|
12208 | } catch (error) {
|
12209 | this.onError(error);
|
12210 | }
|
12211 | };
|
12212 |
|
12213 | {
|
12214 |
|
12215 |
|
12216 |
|
12217 |
|
12218 |
|
12219 |
|
12220 |
|
12221 |
|
12222 |
|
12223 |
|
12224 |
|
12225 |
|
12226 |
|
12227 |
|
12228 |
|
12229 |
|
12230 |
|
12231 |
|
12232 |
|
12233 |
|
12234 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
12235 | var fakeNode = document.createElement('react');
|
12236 |
|
12237 | var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
|
12238 |
|
12239 |
|
12240 |
|
12241 |
|
12242 | if (!(typeof document !== 'undefined')) {
|
12243 | {
|
12244 | throw Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.");
|
12245 | }
|
12246 | }
|
12247 |
|
12248 | var evt = document.createEvent('Event');
|
12249 |
|
12250 |
|
12251 |
|
12252 |
|
12253 |
|
12254 |
|
12255 | var didError = true;
|
12256 |
|
12257 |
|
12258 |
|
12259 | var windowEvent = window.event;
|
12260 |
|
12261 |
|
12262 | var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
|
12263 |
|
12264 |
|
12265 |
|
12266 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
12267 |
|
12268 | function callCallback() {
|
12269 |
|
12270 |
|
12271 |
|
12272 |
|
12273 | fakeNode.removeEventListener(evtType, callCallback, false);
|
12274 |
|
12275 |
|
12276 |
|
12277 |
|
12278 | if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
|
12279 | window.event = windowEvent;
|
12280 | }
|
12281 |
|
12282 | func.apply(context, funcArgs);
|
12283 | didError = false;
|
12284 | }
|
12285 |
|
12286 |
|
12287 |
|
12288 |
|
12289 |
|
12290 |
|
12291 |
|
12292 |
|
12293 |
|
12294 |
|
12295 |
|
12296 |
|
12297 | var error;
|
12298 |
|
12299 | var didSetError = false;
|
12300 | var isCrossOriginError = false;
|
12301 |
|
12302 | function handleWindowError(event) {
|
12303 | error = event.error;
|
12304 | didSetError = true;
|
12305 |
|
12306 | if (error === null && event.colno === 0 && event.lineno === 0) {
|
12307 | isCrossOriginError = true;
|
12308 | }
|
12309 |
|
12310 | if (event.defaultPrevented) {
|
12311 |
|
12312 |
|
12313 |
|
12314 | if (error != null && typeof error === 'object') {
|
12315 | try {
|
12316 | error._suppressLogging = true;
|
12317 | } catch (inner) {
|
12318 | }
|
12319 | }
|
12320 | }
|
12321 | }
|
12322 |
|
12323 |
|
12324 | var evtType = "react-" + (name ? name : 'invokeguardedcallback');
|
12325 |
|
12326 | window.addEventListener('error', handleWindowError);
|
12327 | fakeNode.addEventListener(evtType, callCallback, false);
|
12328 |
|
12329 |
|
12330 | evt.initEvent(evtType, false, false);
|
12331 | fakeNode.dispatchEvent(evt);
|
12332 |
|
12333 | if (windowEventDescriptor) {
|
12334 | Object.defineProperty(window, 'event', windowEventDescriptor);
|
12335 | }
|
12336 |
|
12337 | if (didError) {
|
12338 | if (!didSetError) {
|
12339 |
|
12340 | error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
|
12341 | } else if (isCrossOriginError) {
|
12342 | error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
|
12343 | }
|
12344 |
|
12345 | this.onError(error);
|
12346 | }
|
12347 |
|
12348 |
|
12349 | window.removeEventListener('error', handleWindowError);
|
12350 | };
|
12351 |
|
12352 | invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
|
12353 | }
|
12354 | }
|
12355 |
|
12356 | var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
|
12357 |
|
12358 | var hasError = false;
|
12359 | var caughtError = null;
|
12360 |
|
12361 | var reporter = {
|
12362 | onError: function (error) {
|
12363 | hasError = true;
|
12364 | caughtError = error;
|
12365 | }
|
12366 | };
|
12367 |
|
12368 |
|
12369 |
|
12370 |
|
12371 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 |
|
12378 |
|
12379 |
|
12380 |
|
12381 | function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
|
12382 | hasError = false;
|
12383 | caughtError = null;
|
12384 | invokeGuardedCallbackImpl$1.apply(reporter, arguments);
|
12385 | }
|
12386 |
|
12387 |
|
12388 |
|
12389 |
|
12390 |
|
12391 |
|
12392 |
|
12393 |
|
12394 |
|
12395 |
|
12396 |
|
12397 |
|
12398 |
|
12399 |
|
12400 |
|
12401 |
|
12402 |
|
12403 |
|
12404 | function hasCaughtError() {
|
12405 | return hasError;
|
12406 | }
|
12407 | function clearCaughtError() {
|
12408 | if (hasError) {
|
12409 | var error = caughtError;
|
12410 | hasError = false;
|
12411 | caughtError = null;
|
12412 | return error;
|
12413 | } else {
|
12414 | {
|
12415 | {
|
12416 | throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");
|
12417 | }
|
12418 | }
|
12419 | }
|
12420 | }
|
12421 |
|
12422 |
|
12423 |
|
12424 |
|
12425 | function showErrorDialog(capturedError) {
|
12426 | return true;
|
12427 | }
|
12428 |
|
12429 | function logCapturedError(capturedError) {
|
12430 | var logError = showErrorDialog(capturedError);
|
12431 |
|
12432 |
|
12433 | if (logError === false) {
|
12434 | return;
|
12435 | }
|
12436 |
|
12437 | var error = capturedError.error;
|
12438 |
|
12439 | {
|
12440 | var componentName = capturedError.componentName,
|
12441 | componentStack = capturedError.componentStack,
|
12442 | errorBoundaryName = capturedError.errorBoundaryName,
|
12443 | errorBoundaryFound = capturedError.errorBoundaryFound,
|
12444 | willRetry = capturedError.willRetry;
|
12445 |
|
12446 |
|
12447 |
|
12448 | if (error != null && error._suppressLogging) {
|
12449 | if (errorBoundaryFound && willRetry) {
|
12450 |
|
12451 |
|
12452 |
|
12453 | return;
|
12454 | }
|
12455 |
|
12456 |
|
12457 |
|
12458 |
|
12459 |
|
12460 | console.error(error);
|
12461 |
|
12462 | }
|
12463 |
|
12464 | var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
|
12465 | var errorBoundaryMessage;
|
12466 |
|
12467 | if (errorBoundaryFound && errorBoundaryName) {
|
12468 | if (willRetry) {
|
12469 | errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
|
12470 | } else {
|
12471 | errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
|
12472 | }
|
12473 | } else {
|
12474 | errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
|
12475 | }
|
12476 |
|
12477 | var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage);
|
12478 |
|
12479 |
|
12480 |
|
12481 |
|
12482 | console.error(combinedMessage);
|
12483 | }
|
12484 | }
|
12485 |
|
12486 | var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
|
12487 |
|
12488 | {
|
12489 | didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
|
12490 | }
|
12491 |
|
12492 | var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
|
12493 | function logError(boundary, errorInfo) {
|
12494 | var source = errorInfo.source;
|
12495 | var stack = errorInfo.stack;
|
12496 |
|
12497 | if (stack === null && source !== null) {
|
12498 | stack = getStackByFiberInDevAndProd(source);
|
12499 | }
|
12500 |
|
12501 | var capturedError = {
|
12502 | componentName: source !== null ? getComponentName(source.type) : null,
|
12503 | componentStack: stack !== null ? stack : '',
|
12504 | error: errorInfo.value,
|
12505 | errorBoundary: null,
|
12506 | errorBoundaryName: null,
|
12507 | errorBoundaryFound: false,
|
12508 | willRetry: false
|
12509 | };
|
12510 |
|
12511 | if (boundary !== null && boundary.tag === ClassComponent) {
|
12512 | capturedError.errorBoundary = boundary.stateNode;
|
12513 | capturedError.errorBoundaryName = getComponentName(boundary.type);
|
12514 | capturedError.errorBoundaryFound = true;
|
12515 | capturedError.willRetry = true;
|
12516 | }
|
12517 |
|
12518 | try {
|
12519 | logCapturedError(capturedError);
|
12520 | } catch (e) {
|
12521 |
|
12522 |
|
12523 |
|
12524 |
|
12525 | setTimeout(function () {
|
12526 | throw e;
|
12527 | });
|
12528 | }
|
12529 | }
|
12530 |
|
12531 | var callComponentWillUnmountWithTimer = function (current, instance) {
|
12532 | startPhaseTimer(current, 'componentWillUnmount');
|
12533 | instance.props = current.memoizedProps;
|
12534 | instance.state = current.memoizedState;
|
12535 | instance.componentWillUnmount();
|
12536 | stopPhaseTimer();
|
12537 | };
|
12538 |
|
12539 |
|
12540 | function safelyCallComponentWillUnmount(current, instance) {
|
12541 | {
|
12542 | invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance);
|
12543 |
|
12544 | if (hasCaughtError()) {
|
12545 | var unmountError = clearCaughtError();
|
12546 | captureCommitPhaseError(current, unmountError);
|
12547 | }
|
12548 | }
|
12549 | }
|
12550 |
|
12551 | function safelyDetachRef(current) {
|
12552 | var ref = current.ref;
|
12553 |
|
12554 | if (ref !== null) {
|
12555 | if (typeof ref === 'function') {
|
12556 | {
|
12557 | invokeGuardedCallback(null, ref, null, null);
|
12558 |
|
12559 | if (hasCaughtError()) {
|
12560 | var refError = clearCaughtError();
|
12561 | captureCommitPhaseError(current, refError);
|
12562 | }
|
12563 | }
|
12564 | } else {
|
12565 | ref.current = null;
|
12566 | }
|
12567 | }
|
12568 | }
|
12569 |
|
12570 | function safelyCallDestroy(current, destroy) {
|
12571 | {
|
12572 | invokeGuardedCallback(null, destroy, null);
|
12573 |
|
12574 | if (hasCaughtError()) {
|
12575 | var error = clearCaughtError();
|
12576 | captureCommitPhaseError(current, error);
|
12577 | }
|
12578 | }
|
12579 | }
|
12580 |
|
12581 | function commitBeforeMutationLifeCycles(current, finishedWork) {
|
12582 | switch (finishedWork.tag) {
|
12583 | case FunctionComponent:
|
12584 | case ForwardRef:
|
12585 | case SimpleMemoComponent:
|
12586 | {
|
12587 | commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
|
12588 | return;
|
12589 | }
|
12590 |
|
12591 | case ClassComponent:
|
12592 | {
|
12593 | if (finishedWork.effectTag & Snapshot) {
|
12594 | if (current !== null) {
|
12595 | var prevProps = current.memoizedProps;
|
12596 | var prevState = current.memoizedState;
|
12597 | startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
|
12598 | var instance = finishedWork.stateNode;
|
12599 |
|
12600 |
|
12601 |
|
12602 | {
|
12603 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
12604 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12605 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12606 | }
|
12607 | }
|
12608 |
|
12609 | var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
|
12610 |
|
12611 | {
|
12612 | var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
|
12613 |
|
12614 | if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
|
12615 | didWarnSet.add(finishedWork.type);
|
12616 | warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
|
12617 | }
|
12618 | }
|
12619 |
|
12620 | instance.__reactInternalSnapshotBeforeUpdate = snapshot;
|
12621 | stopPhaseTimer();
|
12622 | }
|
12623 | }
|
12624 |
|
12625 | return;
|
12626 | }
|
12627 |
|
12628 | case HostRoot:
|
12629 | case HostComponent:
|
12630 | case HostText:
|
12631 | case HostPortal:
|
12632 | case IncompleteClassComponent:
|
12633 |
|
12634 | return;
|
12635 |
|
12636 | default:
|
12637 | {
|
12638 | {
|
12639 | {
|
12640 | throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
12641 | }
|
12642 | }
|
12643 | }
|
12644 | }
|
12645 | }
|
12646 |
|
12647 | function commitHookEffectList(unmountTag, mountTag, finishedWork) {
|
12648 | var updateQueue = finishedWork.updateQueue;
|
12649 | var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
12650 |
|
12651 | if (lastEffect !== null) {
|
12652 | var firstEffect = lastEffect.next;
|
12653 | var effect = firstEffect;
|
12654 |
|
12655 | do {
|
12656 | if ((effect.tag & unmountTag) !== NoEffect$1) {
|
12657 |
|
12658 | var destroy = effect.destroy;
|
12659 | effect.destroy = undefined;
|
12660 |
|
12661 | if (destroy !== undefined) {
|
12662 | destroy();
|
12663 | }
|
12664 | }
|
12665 |
|
12666 | if ((effect.tag & mountTag) !== NoEffect$1) {
|
12667 |
|
12668 | var create = effect.create;
|
12669 | effect.destroy = create();
|
12670 |
|
12671 | {
|
12672 | var _destroy = effect.destroy;
|
12673 |
|
12674 | if (_destroy !== undefined && typeof _destroy !== 'function') {
|
12675 | var addendum = void 0;
|
12676 |
|
12677 | if (_destroy === null) {
|
12678 | addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
|
12679 | } else if (typeof _destroy.then === 'function') {
|
12680 | addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
|
12681 | } else {
|
12682 | addendum = ' You returned: ' + _destroy;
|
12683 | }
|
12684 |
|
12685 | warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
|
12686 | }
|
12687 | }
|
12688 | }
|
12689 |
|
12690 | effect = effect.next;
|
12691 | } while (effect !== firstEffect);
|
12692 | }
|
12693 | }
|
12694 |
|
12695 | function commitPassiveHookEffects(finishedWork) {
|
12696 | if ((finishedWork.effectTag & Passive) !== NoEffect) {
|
12697 | switch (finishedWork.tag) {
|
12698 | case FunctionComponent:
|
12699 | case ForwardRef:
|
12700 | case SimpleMemoComponent:
|
12701 | {
|
12702 | commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
|
12703 | commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
|
12704 | break;
|
12705 | }
|
12706 |
|
12707 | default:
|
12708 | break;
|
12709 | }
|
12710 | }
|
12711 | }
|
12712 |
|
12713 | function commitLifeCycles(finishedRoot, current, finishedWork, committedExpirationTime) {
|
12714 | switch (finishedWork.tag) {
|
12715 | case FunctionComponent:
|
12716 | case ForwardRef:
|
12717 | case SimpleMemoComponent:
|
12718 | {
|
12719 | commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
|
12720 | break;
|
12721 | }
|
12722 |
|
12723 | case ClassComponent:
|
12724 | {
|
12725 | var instance = finishedWork.stateNode;
|
12726 |
|
12727 | if (finishedWork.effectTag & Update) {
|
12728 | if (current === null) {
|
12729 | startPhaseTimer(finishedWork, 'componentDidMount');
|
12730 |
|
12731 |
|
12732 |
|
12733 | {
|
12734 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
12735 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12736 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12737 | }
|
12738 | }
|
12739 |
|
12740 | instance.componentDidMount();
|
12741 | stopPhaseTimer();
|
12742 | } else {
|
12743 | var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps);
|
12744 | var prevState = current.memoizedState;
|
12745 | startPhaseTimer(finishedWork, 'componentDidUpdate');
|
12746 |
|
12747 |
|
12748 |
|
12749 | {
|
12750 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
12751 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12752 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12753 | }
|
12754 | }
|
12755 |
|
12756 | instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
12757 | stopPhaseTimer();
|
12758 | }
|
12759 | }
|
12760 |
|
12761 | var updateQueue = finishedWork.updateQueue;
|
12762 |
|
12763 | if (updateQueue !== null) {
|
12764 | {
|
12765 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
12766 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12767 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
12768 | }
|
12769 | }
|
12770 |
|
12771 |
|
12772 |
|
12773 |
|
12774 | commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
|
12775 | }
|
12776 |
|
12777 | return;
|
12778 | }
|
12779 |
|
12780 | case HostRoot:
|
12781 | {
|
12782 | var _updateQueue = finishedWork.updateQueue;
|
12783 |
|
12784 | if (_updateQueue !== null) {
|
12785 | var _instance = null;
|
12786 |
|
12787 | if (finishedWork.child !== null) {
|
12788 | switch (finishedWork.child.tag) {
|
12789 | case HostComponent:
|
12790 | _instance = getPublicInstance(finishedWork.child.stateNode);
|
12791 | break;
|
12792 |
|
12793 | case ClassComponent:
|
12794 | _instance = finishedWork.child.stateNode;
|
12795 | break;
|
12796 | }
|
12797 | }
|
12798 |
|
12799 | commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
|
12800 | }
|
12801 |
|
12802 | return;
|
12803 | }
|
12804 |
|
12805 | case HostComponent:
|
12806 | {
|
12807 | var _instance2 = finishedWork.stateNode;
|
12808 |
|
12809 |
|
12810 |
|
12811 |
|
12812 | if (current === null && finishedWork.effectTag & Update) {
|
12813 | var type = finishedWork.type;
|
12814 | var props = finishedWork.memoizedProps;
|
12815 |
|
12816 | }
|
12817 |
|
12818 | return;
|
12819 | }
|
12820 |
|
12821 | case HostText:
|
12822 | {
|
12823 |
|
12824 | return;
|
12825 | }
|
12826 |
|
12827 | case HostPortal:
|
12828 | {
|
12829 |
|
12830 | return;
|
12831 | }
|
12832 |
|
12833 | case Profiler:
|
12834 | {
|
12835 | if (enableProfilerTimer) {
|
12836 | var onRender = finishedWork.memoizedProps.onRender;
|
12837 |
|
12838 | if (typeof onRender === 'function') {
|
12839 | if (enableSchedulerTracing) {
|
12840 | onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
|
12841 | } else {
|
12842 | onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
|
12843 | }
|
12844 | }
|
12845 | }
|
12846 |
|
12847 | return;
|
12848 | }
|
12849 |
|
12850 | case SuspenseComponent:
|
12851 | {
|
12852 | commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
|
12853 | return;
|
12854 | }
|
12855 |
|
12856 | case SuspenseListComponent:
|
12857 | case IncompleteClassComponent:
|
12858 | case FundamentalComponent:
|
12859 | case ScopeComponent:
|
12860 | return;
|
12861 |
|
12862 | default:
|
12863 | {
|
12864 | {
|
12865 | {
|
12866 | throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
12867 | }
|
12868 | }
|
12869 | }
|
12870 | }
|
12871 | }
|
12872 |
|
12873 | function hideOrUnhideAllChildren(finishedWork, isHidden) {
|
12874 | if (supportsMutation) {
|
12875 |
|
12876 |
|
12877 | var node = finishedWork;
|
12878 |
|
12879 | while (true) {
|
12880 | if (node.tag === HostComponent) {
|
12881 | var instance = node.stateNode;
|
12882 |
|
12883 | if (isHidden) {
|
12884 | hideInstance(instance);
|
12885 | } else {
|
12886 | unhideInstance(node.stateNode, node.memoizedProps);
|
12887 | }
|
12888 | } else if (node.tag === HostText) {
|
12889 | var _instance3 = node.stateNode;
|
12890 |
|
12891 | if (isHidden) {
|
12892 |
|
12893 | } else {
|
12894 | unhideTextInstance(_instance3, node.memoizedProps);
|
12895 | }
|
12896 | } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) {
|
12897 |
|
12898 |
|
12899 | var fallbackChildFragment = node.child.sibling;
|
12900 | fallbackChildFragment.return = node;
|
12901 | node = fallbackChildFragment;
|
12902 | continue;
|
12903 | } else if (node.child !== null) {
|
12904 | node.child.return = node;
|
12905 | node = node.child;
|
12906 | continue;
|
12907 | }
|
12908 |
|
12909 | if (node === finishedWork) {
|
12910 | return;
|
12911 | }
|
12912 |
|
12913 | while (node.sibling === null) {
|
12914 | if (node.return === null || node.return === finishedWork) {
|
12915 | return;
|
12916 | }
|
12917 |
|
12918 | node = node.return;
|
12919 | }
|
12920 |
|
12921 | node.sibling.return = node.return;
|
12922 | node = node.sibling;
|
12923 | }
|
12924 | }
|
12925 | }
|
12926 |
|
12927 | function commitAttachRef(finishedWork) {
|
12928 | var ref = finishedWork.ref;
|
12929 |
|
12930 | if (ref !== null) {
|
12931 | var instance = finishedWork.stateNode;
|
12932 | var instanceToUse;
|
12933 |
|
12934 | switch (finishedWork.tag) {
|
12935 | case HostComponent:
|
12936 | instanceToUse = getPublicInstance(instance);
|
12937 | break;
|
12938 |
|
12939 | default:
|
12940 | instanceToUse = instance;
|
12941 | }
|
12942 |
|
12943 |
|
12944 | if (enableScopeAPI && finishedWork.tag === ScopeComponent) {
|
12945 | instanceToUse = instance.methods;
|
12946 | }
|
12947 |
|
12948 | if (typeof ref === 'function') {
|
12949 | ref(instanceToUse);
|
12950 | } else {
|
12951 | {
|
12952 | if (!ref.hasOwnProperty('current')) {
|
12953 | warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
|
12954 | }
|
12955 | }
|
12956 |
|
12957 | ref.current = instanceToUse;
|
12958 | }
|
12959 | }
|
12960 | }
|
12961 |
|
12962 | function commitDetachRef(current) {
|
12963 | var currentRef = current.ref;
|
12964 |
|
12965 | if (currentRef !== null) {
|
12966 | if (typeof currentRef === 'function') {
|
12967 | currentRef(null);
|
12968 | } else {
|
12969 | currentRef.current = null;
|
12970 | }
|
12971 | }
|
12972 | }
|
12973 |
|
12974 |
|
12975 |
|
12976 |
|
12977 | function commitUnmount(finishedRoot, current, renderPriorityLevel) {
|
12978 | onCommitUnmount(current);
|
12979 |
|
12980 | switch (current.tag) {
|
12981 | case FunctionComponent:
|
12982 | case ForwardRef:
|
12983 | case MemoComponent:
|
12984 | case SimpleMemoComponent:
|
12985 | {
|
12986 | var updateQueue = current.updateQueue;
|
12987 |
|
12988 | if (updateQueue !== null) {
|
12989 | var lastEffect = updateQueue.lastEffect;
|
12990 |
|
12991 | if (lastEffect !== null) {
|
12992 | var firstEffect = lastEffect.next;
|
12993 |
|
12994 |
|
12995 |
|
12996 |
|
12997 |
|
12998 |
|
12999 |
|
13000 |
|
13001 |
|
13002 |
|
13003 |
|
13004 |
|
13005 | var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
|
13006 | runWithPriority(priorityLevel, function () {
|
13007 | var effect = firstEffect;
|
13008 |
|
13009 | do {
|
13010 | var destroy = effect.destroy;
|
13011 |
|
13012 | if (destroy !== undefined) {
|
13013 | safelyCallDestroy(current, destroy);
|
13014 | }
|
13015 |
|
13016 | effect = effect.next;
|
13017 | } while (effect !== firstEffect);
|
13018 | });
|
13019 | }
|
13020 | }
|
13021 |
|
13022 | break;
|
13023 | }
|
13024 |
|
13025 | case ClassComponent:
|
13026 | {
|
13027 | safelyDetachRef(current);
|
13028 | var instance = current.stateNode;
|
13029 |
|
13030 | if (typeof instance.componentWillUnmount === 'function') {
|
13031 | safelyCallComponentWillUnmount(current, instance);
|
13032 | }
|
13033 |
|
13034 | return;
|
13035 | }
|
13036 |
|
13037 | case HostComponent:
|
13038 | {
|
13039 | if (enableFlareAPI) {
|
13040 | var dependencies = current.dependencies;
|
13041 |
|
13042 | if (dependencies !== null) {
|
13043 | var respondersMap = dependencies.responders;
|
13044 |
|
13045 | if (respondersMap !== null) {
|
13046 | var responderInstances = Array.from(respondersMap.values());
|
13047 |
|
13048 | for (var i = 0, length = responderInstances.length; i < length; i++) {
|
13049 | var responderInstance = responderInstances[i];
|
13050 | unmountResponderInstance(responderInstance);
|
13051 | }
|
13052 |
|
13053 | dependencies.responders = null;
|
13054 | }
|
13055 | }
|
13056 | }
|
13057 |
|
13058 | safelyDetachRef(current);
|
13059 | return;
|
13060 | }
|
13061 |
|
13062 | case HostPortal:
|
13063 | {
|
13064 |
|
13065 |
|
13066 |
|
13067 | if (supportsMutation) {
|
13068 | unmountHostComponents(finishedRoot, current, renderPriorityLevel);
|
13069 | } else if (supportsPersistence) {
|
13070 | emptyPortalContainer(current);
|
13071 | }
|
13072 |
|
13073 | return;
|
13074 | }
|
13075 |
|
13076 | case FundamentalComponent:
|
13077 | {
|
13078 | if (enableFundamentalAPI) {
|
13079 | var fundamentalInstance = current.stateNode;
|
13080 |
|
13081 | if (fundamentalInstance !== null) {
|
13082 | unmountFundamentalComponent(fundamentalInstance);
|
13083 | current.stateNode = null;
|
13084 | }
|
13085 | }
|
13086 |
|
13087 | return;
|
13088 | }
|
13089 |
|
13090 | case DehydratedFragment:
|
13091 | {
|
13092 | if (enableSuspenseCallback) {
|
13093 | var hydrationCallbacks = finishedRoot.hydrationCallbacks;
|
13094 |
|
13095 | if (hydrationCallbacks !== null) {
|
13096 | var onDeleted = hydrationCallbacks.onDeleted;
|
13097 |
|
13098 | if (onDeleted) {
|
13099 | onDeleted(current.stateNode);
|
13100 | }
|
13101 | }
|
13102 | }
|
13103 |
|
13104 | return;
|
13105 | }
|
13106 |
|
13107 | case ScopeComponent:
|
13108 | {
|
13109 | if (enableScopeAPI) {
|
13110 | safelyDetachRef(current);
|
13111 | }
|
13112 | }
|
13113 | }
|
13114 | }
|
13115 |
|
13116 | function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
|
13117 |
|
13118 |
|
13119 |
|
13120 |
|
13121 |
|
13122 | var node = root;
|
13123 |
|
13124 | while (true) {
|
13125 | commitUnmount(finishedRoot, node, renderPriorityLevel);
|
13126 |
|
13127 |
|
13128 | if (node.child !== null && (
|
13129 |
|
13130 | !supportsMutation || node.tag !== HostPortal)) {
|
13131 | node.child.return = node;
|
13132 | node = node.child;
|
13133 | continue;
|
13134 | }
|
13135 |
|
13136 | if (node === root) {
|
13137 | return;
|
13138 | }
|
13139 |
|
13140 | while (node.sibling === null) {
|
13141 | if (node.return === null || node.return === root) {
|
13142 | return;
|
13143 | }
|
13144 |
|
13145 | node = node.return;
|
13146 | }
|
13147 |
|
13148 | node.sibling.return = node.return;
|
13149 | node = node.sibling;
|
13150 | }
|
13151 | }
|
13152 |
|
13153 | function detachFiber(current) {
|
13154 | var alternate = current.alternate;
|
13155 |
|
13156 |
|
13157 |
|
13158 |
|
13159 |
|
13160 | current.return = null;
|
13161 | current.child = null;
|
13162 | current.memoizedState = null;
|
13163 | current.updateQueue = null;
|
13164 | current.dependencies = null;
|
13165 | current.alternate = null;
|
13166 | current.firstEffect = null;
|
13167 | current.lastEffect = null;
|
13168 | current.pendingProps = null;
|
13169 | current.memoizedProps = null;
|
13170 |
|
13171 | if (alternate !== null) {
|
13172 | detachFiber(alternate);
|
13173 | }
|
13174 | }
|
13175 |
|
13176 | function emptyPortalContainer(current) {
|
13177 | if (!supportsPersistence) {
|
13178 | return;
|
13179 | }
|
13180 |
|
13181 | var portal = current.stateNode;
|
13182 | var containerInfo = portal.containerInfo;
|
13183 | var emptyChildSet = createContainerChildSet(containerInfo);
|
13184 | replaceContainerChildren(containerInfo, emptyChildSet);
|
13185 | }
|
13186 |
|
13187 | function commitContainer(finishedWork) {
|
13188 | if (!supportsPersistence) {
|
13189 | return;
|
13190 | }
|
13191 |
|
13192 | switch (finishedWork.tag) {
|
13193 | case ClassComponent:
|
13194 | case HostComponent:
|
13195 | case HostText:
|
13196 | case FundamentalComponent:
|
13197 | {
|
13198 | return;
|
13199 | }
|
13200 |
|
13201 | case HostRoot:
|
13202 | case HostPortal:
|
13203 | {
|
13204 | var portalOrRoot = finishedWork.stateNode;
|
13205 | var containerInfo = portalOrRoot.containerInfo,
|
13206 | pendingChildren = portalOrRoot.pendingChildren;
|
13207 | replaceContainerChildren(containerInfo, pendingChildren);
|
13208 | return;
|
13209 | }
|
13210 |
|
13211 | default:
|
13212 | {
|
13213 | {
|
13214 | {
|
13215 | throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
13216 | }
|
13217 | }
|
13218 | }
|
13219 | }
|
13220 | }
|
13221 |
|
13222 | function getHostParentFiber(fiber) {
|
13223 | var parent = fiber.return;
|
13224 |
|
13225 | while (parent !== null) {
|
13226 | if (isHostParent(parent)) {
|
13227 | return parent;
|
13228 | }
|
13229 |
|
13230 | parent = parent.return;
|
13231 | }
|
13232 |
|
13233 | {
|
13234 | {
|
13235 | throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
|
13236 | }
|
13237 | }
|
13238 | }
|
13239 |
|
13240 | function isHostParent(fiber) {
|
13241 | return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
|
13242 | }
|
13243 |
|
13244 | function getHostSibling(fiber) {
|
13245 |
|
13246 |
|
13247 |
|
13248 |
|
13249 | var node = fiber;
|
13250 |
|
13251 | siblings: while (true) {
|
13252 |
|
13253 | while (node.sibling === null) {
|
13254 | if (node.return === null || isHostParent(node.return)) {
|
13255 |
|
13256 |
|
13257 | return null;
|
13258 | }
|
13259 |
|
13260 | node = node.return;
|
13261 | }
|
13262 |
|
13263 | node.sibling.return = node.return;
|
13264 | node = node.sibling;
|
13265 |
|
13266 | while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
|
13267 |
|
13268 |
|
13269 | if (node.effectTag & Placement) {
|
13270 |
|
13271 | continue siblings;
|
13272 | }
|
13273 |
|
13274 |
|
13275 |
|
13276 | if (node.child === null || node.tag === HostPortal) {
|
13277 | continue siblings;
|
13278 | } else {
|
13279 | node.child.return = node;
|
13280 | node = node.child;
|
13281 | }
|
13282 | }
|
13283 |
|
13284 |
|
13285 | if (!(node.effectTag & Placement)) {
|
13286 |
|
13287 | return node.stateNode;
|
13288 | }
|
13289 | }
|
13290 | }
|
13291 |
|
13292 | function commitPlacement(finishedWork) {
|
13293 | if (!supportsMutation) {
|
13294 | return;
|
13295 | }
|
13296 |
|
13297 |
|
13298 | var parentFiber = getHostParentFiber(finishedWork);
|
13299 |
|
13300 | var parent;
|
13301 | var isContainer;
|
13302 | var parentStateNode = parentFiber.stateNode;
|
13303 |
|
13304 | switch (parentFiber.tag) {
|
13305 | case HostComponent:
|
13306 | parent = parentStateNode;
|
13307 | isContainer = false;
|
13308 | break;
|
13309 |
|
13310 | case HostRoot:
|
13311 | parent = parentStateNode.containerInfo;
|
13312 | isContainer = true;
|
13313 | break;
|
13314 |
|
13315 | case HostPortal:
|
13316 | parent = parentStateNode.containerInfo;
|
13317 | isContainer = true;
|
13318 | break;
|
13319 |
|
13320 | case FundamentalComponent:
|
13321 | if (enableFundamentalAPI) {
|
13322 | parent = parentStateNode.instance;
|
13323 | isContainer = false;
|
13324 | }
|
13325 |
|
13326 |
|
13327 |
|
13328 | default:
|
13329 | {
|
13330 | {
|
13331 | throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.");
|
13332 | }
|
13333 | }
|
13334 |
|
13335 | }
|
13336 |
|
13337 | if (parentFiber.effectTag & ContentReset) {
|
13338 |
|
13339 | parentFiber.effectTag &= ~ContentReset;
|
13340 | }
|
13341 |
|
13342 | var before = getHostSibling(finishedWork);
|
13343 |
|
13344 |
|
13345 | var node = finishedWork;
|
13346 |
|
13347 | while (true) {
|
13348 | var isHost = node.tag === HostComponent || node.tag === HostText;
|
13349 |
|
13350 | if (isHost || enableFundamentalAPI && node.tag === FundamentalComponent) {
|
13351 | var stateNode = isHost ? node.stateNode : node.stateNode.instance;
|
13352 |
|
13353 | if (before) {
|
13354 | if (isContainer) {
|
13355 | insertInContainerBefore(parent, stateNode, before);
|
13356 | } else {
|
13357 | insertBefore(parent, stateNode, before);
|
13358 | }
|
13359 | } else {
|
13360 | if (isContainer) {
|
13361 | appendChildToContainer(parent, stateNode);
|
13362 | } else {
|
13363 | appendChild(parent, stateNode);
|
13364 | }
|
13365 | }
|
13366 | } else if (node.tag === HostPortal) {
|
13367 |
|
13368 |
|
13369 | } else if (node.child !== null) {
|
13370 | node.child.return = node;
|
13371 | node = node.child;
|
13372 | continue;
|
13373 | }
|
13374 |
|
13375 | if (node === finishedWork) {
|
13376 | return;
|
13377 | }
|
13378 |
|
13379 | while (node.sibling === null) {
|
13380 | if (node.return === null || node.return === finishedWork) {
|
13381 | return;
|
13382 | }
|
13383 |
|
13384 | node = node.return;
|
13385 | }
|
13386 |
|
13387 | node.sibling.return = node.return;
|
13388 | node = node.sibling;
|
13389 | }
|
13390 | }
|
13391 |
|
13392 | function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
|
13393 |
|
13394 |
|
13395 | var node = current;
|
13396 |
|
13397 |
|
13398 | var currentParentIsValid = false;
|
13399 |
|
13400 | var currentParent;
|
13401 | var currentParentIsContainer;
|
13402 |
|
13403 | while (true) {
|
13404 | if (!currentParentIsValid) {
|
13405 | var parent = node.return;
|
13406 |
|
13407 | findParent: while (true) {
|
13408 | if (!(parent !== null)) {
|
13409 | {
|
13410 | throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
|
13411 | }
|
13412 | }
|
13413 |
|
13414 | var parentStateNode = parent.stateNode;
|
13415 |
|
13416 | switch (parent.tag) {
|
13417 | case HostComponent:
|
13418 | currentParent = parentStateNode;
|
13419 | currentParentIsContainer = false;
|
13420 | break findParent;
|
13421 |
|
13422 | case HostRoot:
|
13423 | currentParent = parentStateNode.containerInfo;
|
13424 | currentParentIsContainer = true;
|
13425 | break findParent;
|
13426 |
|
13427 | case HostPortal:
|
13428 | currentParent = parentStateNode.containerInfo;
|
13429 | currentParentIsContainer = true;
|
13430 | break findParent;
|
13431 |
|
13432 | case FundamentalComponent:
|
13433 | if (enableFundamentalAPI) {
|
13434 | currentParent = parentStateNode.instance;
|
13435 | currentParentIsContainer = false;
|
13436 | }
|
13437 |
|
13438 | }
|
13439 |
|
13440 | parent = parent.return;
|
13441 | }
|
13442 |
|
13443 | currentParentIsValid = true;
|
13444 | }
|
13445 |
|
13446 | if (node.tag === HostComponent || node.tag === HostText) {
|
13447 | commitNestedUnmounts(finishedRoot, node, renderPriorityLevel);
|
13448 |
|
13449 |
|
13450 | if (currentParentIsContainer) {
|
13451 | removeChildFromContainer(currentParent, node.stateNode);
|
13452 | } else {
|
13453 | removeChild(currentParent, node.stateNode);
|
13454 | }
|
13455 |
|
13456 | } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
|
13457 | var fundamentalNode = node.stateNode.instance;
|
13458 | commitNestedUnmounts(finishedRoot, node, renderPriorityLevel);
|
13459 |
|
13460 |
|
13461 | if (currentParentIsContainer) {
|
13462 | removeChildFromContainer(currentParent, fundamentalNode);
|
13463 | } else {
|
13464 | removeChild(currentParent, fundamentalNode);
|
13465 | }
|
13466 | } else if (enableSuspenseServerRenderer && node.tag === DehydratedFragment) {
|
13467 | if (enableSuspenseCallback) {
|
13468 | var hydrationCallbacks = finishedRoot.hydrationCallbacks;
|
13469 |
|
13470 | if (hydrationCallbacks !== null) {
|
13471 | var onDeleted = hydrationCallbacks.onDeleted;
|
13472 |
|
13473 | if (onDeleted) {
|
13474 | onDeleted(node.stateNode);
|
13475 | }
|
13476 | }
|
13477 | }
|
13478 |
|
13479 |
|
13480 | if (currentParentIsContainer) {
|
13481 | clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
|
13482 | } else {
|
13483 | clearSuspenseBoundary(currentParent, node.stateNode);
|
13484 | }
|
13485 | } else if (node.tag === HostPortal) {
|
13486 | if (node.child !== null) {
|
13487 |
|
13488 |
|
13489 | currentParent = node.stateNode.containerInfo;
|
13490 | currentParentIsContainer = true;
|
13491 |
|
13492 | node.child.return = node;
|
13493 | node = node.child;
|
13494 | continue;
|
13495 | }
|
13496 | } else {
|
13497 | commitUnmount(finishedRoot, node, renderPriorityLevel);
|
13498 |
|
13499 | if (node.child !== null) {
|
13500 | node.child.return = node;
|
13501 | node = node.child;
|
13502 | continue;
|
13503 | }
|
13504 | }
|
13505 |
|
13506 | if (node === current) {
|
13507 | return;
|
13508 | }
|
13509 |
|
13510 | while (node.sibling === null) {
|
13511 | if (node.return === null || node.return === current) {
|
13512 | return;
|
13513 | }
|
13514 |
|
13515 | node = node.return;
|
13516 |
|
13517 | if (node.tag === HostPortal) {
|
13518 |
|
13519 |
|
13520 | currentParentIsValid = false;
|
13521 | }
|
13522 | }
|
13523 |
|
13524 | node.sibling.return = node.return;
|
13525 | node = node.sibling;
|
13526 | }
|
13527 | }
|
13528 |
|
13529 | function commitDeletion(finishedRoot, current, renderPriorityLevel) {
|
13530 | if (supportsMutation) {
|
13531 |
|
13532 |
|
13533 | unmountHostComponents(finishedRoot, current, renderPriorityLevel);
|
13534 | } else {
|
13535 |
|
13536 | commitNestedUnmounts(finishedRoot, current, renderPriorityLevel);
|
13537 | }
|
13538 |
|
13539 | detachFiber(current);
|
13540 | }
|
13541 |
|
13542 | function commitWork(current, finishedWork) {
|
13543 | if (!supportsMutation) {
|
13544 | switch (finishedWork.tag) {
|
13545 | case FunctionComponent:
|
13546 | case ForwardRef:
|
13547 | case MemoComponent:
|
13548 | case SimpleMemoComponent:
|
13549 | {
|
13550 |
|
13551 |
|
13552 | commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
|
13553 | return;
|
13554 | }
|
13555 |
|
13556 | case Profiler:
|
13557 | {
|
13558 | return;
|
13559 | }
|
13560 |
|
13561 | case SuspenseComponent:
|
13562 | {
|
13563 | commitSuspenseComponent(finishedWork);
|
13564 | attachSuspenseRetryListeners(finishedWork);
|
13565 | return;
|
13566 | }
|
13567 |
|
13568 | case SuspenseListComponent:
|
13569 | {
|
13570 | attachSuspenseRetryListeners(finishedWork);
|
13571 | return;
|
13572 | }
|
13573 |
|
13574 | case HostRoot:
|
13575 | {
|
13576 | if (supportsHydration) {
|
13577 | var root = finishedWork.stateNode;
|
13578 |
|
13579 | if (root.hydrate) {
|
13580 |
|
13581 | root.hydrate = false;
|
13582 | commitHydratedContainer(root.containerInfo);
|
13583 | }
|
13584 | }
|
13585 |
|
13586 | break;
|
13587 | }
|
13588 | }
|
13589 |
|
13590 | commitContainer(finishedWork);
|
13591 | return;
|
13592 | }
|
13593 |
|
13594 | switch (finishedWork.tag) {
|
13595 | case FunctionComponent:
|
13596 | case ForwardRef:
|
13597 | case MemoComponent:
|
13598 | case SimpleMemoComponent:
|
13599 | {
|
13600 |
|
13601 |
|
13602 | commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
|
13603 | return;
|
13604 | }
|
13605 |
|
13606 | case ClassComponent:
|
13607 | {
|
13608 | return;
|
13609 | }
|
13610 |
|
13611 | case HostComponent:
|
13612 | {
|
13613 | var instance = finishedWork.stateNode;
|
13614 |
|
13615 | if (instance != null) {
|
13616 |
|
13617 | var newProps = finishedWork.memoizedProps;
|
13618 |
|
13619 |
|
13620 |
|
13621 | var oldProps = current !== null ? current.memoizedProps : newProps;
|
13622 | var type = finishedWork.type;
|
13623 |
|
13624 | var updatePayload = finishedWork.updateQueue;
|
13625 | finishedWork.updateQueue = null;
|
13626 |
|
13627 | if (updatePayload !== null) {
|
13628 | commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
|
13629 | }
|
13630 |
|
13631 | if (enableFlareAPI) {
|
13632 | var prevListeners = oldProps.listeners;
|
13633 | var nextListeners = newProps.listeners;
|
13634 |
|
13635 | if (prevListeners !== nextListeners) {
|
13636 | updateEventListeners(nextListeners, finishedWork, null);
|
13637 | }
|
13638 | }
|
13639 | }
|
13640 |
|
13641 | return;
|
13642 | }
|
13643 |
|
13644 | case HostText:
|
13645 | {
|
13646 | if (!(finishedWork.stateNode !== null)) {
|
13647 | {
|
13648 | throw Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");
|
13649 | }
|
13650 | }
|
13651 |
|
13652 | var textInstance = finishedWork.stateNode;
|
13653 | var newText = finishedWork.memoizedProps;
|
13654 |
|
13655 |
|
13656 |
|
13657 | var oldText = current !== null ? current.memoizedProps : newText;
|
13658 | return;
|
13659 | }
|
13660 |
|
13661 | case HostRoot:
|
13662 | {
|
13663 | if (supportsHydration) {
|
13664 | var _root = finishedWork.stateNode;
|
13665 |
|
13666 | if (_root.hydrate) {
|
13667 |
|
13668 | _root.hydrate = false;
|
13669 | commitHydratedContainer(_root.containerInfo);
|
13670 | }
|
13671 | }
|
13672 |
|
13673 | return;
|
13674 | }
|
13675 |
|
13676 | case Profiler:
|
13677 | {
|
13678 | return;
|
13679 | }
|
13680 |
|
13681 | case SuspenseComponent:
|
13682 | {
|
13683 | commitSuspenseComponent(finishedWork);
|
13684 | attachSuspenseRetryListeners(finishedWork);
|
13685 | return;
|
13686 | }
|
13687 |
|
13688 | case SuspenseListComponent:
|
13689 | {
|
13690 | attachSuspenseRetryListeners(finishedWork);
|
13691 | return;
|
13692 | }
|
13693 |
|
13694 | case IncompleteClassComponent:
|
13695 | {
|
13696 | return;
|
13697 | }
|
13698 |
|
13699 | case FundamentalComponent:
|
13700 | {
|
13701 | if (enableFundamentalAPI) {
|
13702 | var fundamentalInstance = finishedWork.stateNode;
|
13703 | updateFundamentalComponent(fundamentalInstance);
|
13704 | }
|
13705 |
|
13706 | return;
|
13707 | }
|
13708 |
|
13709 | case ScopeComponent:
|
13710 | {
|
13711 | if (enableScopeAPI) {
|
13712 | var scopeInstance = finishedWork.stateNode;
|
13713 | scopeInstance.fiber = finishedWork;
|
13714 |
|
13715 | if (enableFlareAPI) {
|
13716 | var _newProps = finishedWork.memoizedProps;
|
13717 |
|
13718 | var _oldProps = current !== null ? current.memoizedProps : _newProps;
|
13719 |
|
13720 | var _prevListeners = _oldProps.listeners;
|
13721 | var _nextListeners = _newProps.listeners;
|
13722 |
|
13723 | if (_prevListeners !== _nextListeners) {
|
13724 | updateEventListeners(_nextListeners, finishedWork, null);
|
13725 | }
|
13726 | }
|
13727 | }
|
13728 |
|
13729 | return;
|
13730 | }
|
13731 |
|
13732 | default:
|
13733 | {
|
13734 | {
|
13735 | {
|
13736 | throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
13737 | }
|
13738 | }
|
13739 | }
|
13740 | }
|
13741 | }
|
13742 |
|
13743 | function commitSuspenseComponent(finishedWork) {
|
13744 | var newState = finishedWork.memoizedState;
|
13745 | var newDidTimeout;
|
13746 | var primaryChildParent = finishedWork;
|
13747 |
|
13748 | if (newState === null) {
|
13749 | newDidTimeout = false;
|
13750 | } else {
|
13751 | newDidTimeout = true;
|
13752 | primaryChildParent = finishedWork.child;
|
13753 | markCommitTimeOfFallback();
|
13754 | }
|
13755 |
|
13756 | if (supportsMutation && primaryChildParent !== null) {
|
13757 | hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
|
13758 | }
|
13759 |
|
13760 | if (enableSuspenseCallback && newState !== null) {
|
13761 | var suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
|
13762 |
|
13763 | if (typeof suspenseCallback === 'function') {
|
13764 | var thenables = finishedWork.updateQueue;
|
13765 |
|
13766 | if (thenables !== null) {
|
13767 | suspenseCallback(new Set(thenables));
|
13768 | }
|
13769 | } else {
|
13770 | if (suspenseCallback !== undefined) {
|
13771 | warning$1(false, 'Unexpected type for suspenseCallback.');
|
13772 | }
|
13773 | }
|
13774 | }
|
13775 | }
|
13776 |
|
13777 | function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
|
13778 | if (!supportsHydration) {
|
13779 | return;
|
13780 | }
|
13781 |
|
13782 | var newState = finishedWork.memoizedState;
|
13783 |
|
13784 | if (newState === null) {
|
13785 | var current = finishedWork.alternate;
|
13786 |
|
13787 | if (current !== null) {
|
13788 | var prevState = current.memoizedState;
|
13789 |
|
13790 | if (prevState !== null) {
|
13791 | var suspenseInstance = prevState.dehydrated;
|
13792 |
|
13793 | if (suspenseInstance !== null) {
|
13794 | commitHydratedSuspenseInstance(suspenseInstance);
|
13795 |
|
13796 | if (enableSuspenseCallback) {
|
13797 | var hydrationCallbacks = finishedRoot.hydrationCallbacks;
|
13798 |
|
13799 | if (hydrationCallbacks !== null) {
|
13800 | var onHydrated = hydrationCallbacks.onHydrated;
|
13801 |
|
13802 | if (onHydrated) {
|
13803 | onHydrated(suspenseInstance);
|
13804 | }
|
13805 | }
|
13806 | }
|
13807 | }
|
13808 | }
|
13809 | }
|
13810 | }
|
13811 | }
|
13812 |
|
13813 | function attachSuspenseRetryListeners(finishedWork) {
|
13814 |
|
13815 |
|
13816 |
|
13817 | var thenables = finishedWork.updateQueue;
|
13818 |
|
13819 | if (thenables !== null) {
|
13820 | finishedWork.updateQueue = null;
|
13821 | var retryCache = finishedWork.stateNode;
|
13822 |
|
13823 | if (retryCache === null) {
|
13824 | retryCache = finishedWork.stateNode = new PossiblyWeakSet();
|
13825 | }
|
13826 |
|
13827 | thenables.forEach(function (thenable) {
|
13828 |
|
13829 | var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
|
13830 |
|
13831 | if (!retryCache.has(thenable)) {
|
13832 | if (enableSchedulerTracing) {
|
13833 | if (thenable.__reactDoNotTraceInteractions !== true) {
|
13834 | retry = unstable_wrap(retry);
|
13835 | }
|
13836 | }
|
13837 |
|
13838 | retryCache.add(thenable);
|
13839 | thenable.then(retry, retry);
|
13840 | }
|
13841 | });
|
13842 | }
|
13843 | }
|
13844 |
|
13845 | function commitResetTextContent(current) {
|
13846 | if (!supportsMutation) {
|
13847 | return;
|
13848 | }
|
13849 |
|
13850 | resetTextContent(current.stateNode);
|
13851 | }
|
13852 |
|
13853 | var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
13854 |
|
13855 | function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
|
13856 | var update = createUpdate(expirationTime, null);
|
13857 |
|
13858 | update.tag = CaptureUpdate;
|
13859 |
|
13860 |
|
13861 | update.payload = {
|
13862 | element: null
|
13863 | };
|
13864 | var error = errorInfo.value;
|
13865 |
|
13866 | update.callback = function () {
|
13867 | onUncaughtError(error);
|
13868 | logError(fiber, errorInfo);
|
13869 | };
|
13870 |
|
13871 | return update;
|
13872 | }
|
13873 |
|
13874 | function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
|
13875 | var update = createUpdate(expirationTime, null);
|
13876 | update.tag = CaptureUpdate;
|
13877 | var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
|
13878 |
|
13879 | if (typeof getDerivedStateFromError === 'function') {
|
13880 | var error = errorInfo.value;
|
13881 |
|
13882 | update.payload = function () {
|
13883 | logError(fiber, errorInfo);
|
13884 | return getDerivedStateFromError(error);
|
13885 | };
|
13886 | }
|
13887 |
|
13888 | var inst = fiber.stateNode;
|
13889 |
|
13890 | if (inst !== null && typeof inst.componentDidCatch === 'function') {
|
13891 | update.callback = function callback() {
|
13892 | {
|
13893 | markFailedErrorBoundaryForHotReloading(fiber);
|
13894 | }
|
13895 |
|
13896 | if (typeof getDerivedStateFromError !== 'function') {
|
13897 |
|
13898 |
|
13899 |
|
13900 |
|
13901 |
|
13902 | markLegacyErrorBoundaryAsFailed(this);
|
13903 |
|
13904 | logError(fiber, errorInfo);
|
13905 | }
|
13906 |
|
13907 | var error = errorInfo.value;
|
13908 | var stack = errorInfo.stack;
|
13909 | this.componentDidCatch(error, {
|
13910 | componentStack: stack !== null ? stack : ''
|
13911 | });
|
13912 |
|
13913 | {
|
13914 | if (typeof getDerivedStateFromError !== 'function') {
|
13915 |
|
13916 |
|
13917 |
|
13918 | !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown') : void 0;
|
13919 | }
|
13920 | }
|
13921 | };
|
13922 | } else {
|
13923 | update.callback = function () {
|
13924 | markFailedErrorBoundaryForHotReloading(fiber);
|
13925 | };
|
13926 | }
|
13927 |
|
13928 | return update;
|
13929 | }
|
13930 |
|
13931 | function attachPingListener(root, renderExpirationTime, thenable) {
|
13932 |
|
13933 |
|
13934 |
|
13935 | var pingCache = root.pingCache;
|
13936 | var threadIDs;
|
13937 |
|
13938 | if (pingCache === null) {
|
13939 | pingCache = root.pingCache = new PossiblyWeakMap();
|
13940 | threadIDs = new Set();
|
13941 | pingCache.set(thenable, threadIDs);
|
13942 | } else {
|
13943 | threadIDs = pingCache.get(thenable);
|
13944 |
|
13945 | if (threadIDs === undefined) {
|
13946 | threadIDs = new Set();
|
13947 | pingCache.set(thenable, threadIDs);
|
13948 | }
|
13949 | }
|
13950 |
|
13951 | if (!threadIDs.has(renderExpirationTime)) {
|
13952 |
|
13953 | threadIDs.add(renderExpirationTime);
|
13954 | var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
|
13955 | thenable.then(ping, ping);
|
13956 | }
|
13957 | }
|
13958 |
|
13959 | function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
|
13960 |
|
13961 | sourceFiber.effectTag |= Incomplete;
|
13962 |
|
13963 | sourceFiber.firstEffect = sourceFiber.lastEffect = null;
|
13964 |
|
13965 | if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
|
13966 |
|
13967 | var thenable = value;
|
13968 | checkForWrongSuspensePriorityInDEV(sourceFiber);
|
13969 | var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext);
|
13970 |
|
13971 | var _workInProgress = returnFiber;
|
13972 |
|
13973 | do {
|
13974 | if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
|
13975 |
|
13976 |
|
13977 |
|
13978 | var thenables = _workInProgress.updateQueue;
|
13979 |
|
13980 | if (thenables === null) {
|
13981 | var updateQueue = new Set();
|
13982 | updateQueue.add(thenable);
|
13983 | _workInProgress.updateQueue = updateQueue;
|
13984 | } else {
|
13985 | thenables.add(thenable);
|
13986 | }
|
13987 |
|
13988 |
|
13989 |
|
13990 |
|
13991 |
|
13992 |
|
13993 |
|
13994 |
|
13995 |
|
13996 | if ((_workInProgress.mode & BatchedMode) === NoMode) {
|
13997 | _workInProgress.effectTag |= DidCapture;
|
13998 |
|
13999 |
|
14000 |
|
14001 | sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
|
14002 |
|
14003 | if (sourceFiber.tag === ClassComponent) {
|
14004 | var currentSourceFiber = sourceFiber.alternate;
|
14005 |
|
14006 | if (currentSourceFiber === null) {
|
14007 |
|
14008 |
|
14009 |
|
14010 | sourceFiber.tag = IncompleteClassComponent;
|
14011 | } else {
|
14012 |
|
14013 |
|
14014 |
|
14015 | var update = createUpdate(Sync, null);
|
14016 | update.tag = ForceUpdate;
|
14017 | enqueueUpdate(sourceFiber, update);
|
14018 | }
|
14019 | }
|
14020 |
|
14021 |
|
14022 |
|
14023 | sourceFiber.expirationTime = Sync;
|
14024 |
|
14025 | return;
|
14026 | }
|
14027 |
|
14028 |
|
14029 |
|
14030 |
|
14031 |
|
14032 |
|
14033 |
|
14034 |
|
14035 |
|
14036 |
|
14037 |
|
14038 |
|
14039 |
|
14040 |
|
14041 |
|
14042 |
|
14043 |
|
14044 |
|
14045 |
|
14046 |
|
14047 |
|
14048 |
|
14049 |
|
14050 |
|
14051 |
|
14052 |
|
14053 |
|
14054 |
|
14055 |
|
14056 |
|
14057 |
|
14058 |
|
14059 |
|
14060 |
|
14061 |
|
14062 |
|
14063 |
|
14064 |
|
14065 |
|
14066 |
|
14067 |
|
14068 | attachPingListener(root, renderExpirationTime, thenable);
|
14069 | _workInProgress.effectTag |= ShouldCapture;
|
14070 | _workInProgress.expirationTime = renderExpirationTime;
|
14071 | return;
|
14072 | }
|
14073 |
|
14074 |
|
14075 |
|
14076 | _workInProgress = _workInProgress.return;
|
14077 | } while (_workInProgress !== null);
|
14078 |
|
14079 |
|
14080 |
|
14081 | value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber));
|
14082 | }
|
14083 |
|
14084 |
|
14085 |
|
14086 |
|
14087 | renderDidError();
|
14088 | value = createCapturedValue(value, sourceFiber);
|
14089 | var workInProgress = returnFiber;
|
14090 |
|
14091 | do {
|
14092 | switch (workInProgress.tag) {
|
14093 | case HostRoot:
|
14094 | {
|
14095 | var _errorInfo = value;
|
14096 | workInProgress.effectTag |= ShouldCapture;
|
14097 | workInProgress.expirationTime = renderExpirationTime;
|
14098 |
|
14099 | var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
|
14100 |
|
14101 | enqueueCapturedUpdate(workInProgress, _update);
|
14102 | return;
|
14103 | }
|
14104 |
|
14105 | case ClassComponent:
|
14106 |
|
14107 | var errorInfo = value;
|
14108 | var ctor = workInProgress.type;
|
14109 | var instance = workInProgress.stateNode;
|
14110 |
|
14111 | if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
|
14112 | workInProgress.effectTag |= ShouldCapture;
|
14113 | workInProgress.expirationTime = renderExpirationTime;
|
14114 |
|
14115 | var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
|
14116 |
|
14117 | enqueueCapturedUpdate(workInProgress, _update2);
|
14118 | return;
|
14119 | }
|
14120 |
|
14121 | break;
|
14122 |
|
14123 | default:
|
14124 | break;
|
14125 | }
|
14126 |
|
14127 | workInProgress = workInProgress.return;
|
14128 | } while (workInProgress !== null);
|
14129 | }
|
14130 |
|
14131 | var ceil = Math.ceil;
|
14132 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
14133 | var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
14134 | var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
|
14135 | var NoContext =
|
14136 |
|
14137 | 0;
|
14138 | var BatchedContext =
|
14139 |
|
14140 | 1;
|
14141 | var DiscreteEventContext =
|
14142 |
|
14143 | 4;
|
14144 | var LegacyUnbatchedContext =
|
14145 |
|
14146 | 8;
|
14147 | var RenderContext =
|
14148 |
|
14149 | 16;
|
14150 | var CommitContext =
|
14151 |
|
14152 | 32;
|
14153 | var RootIncomplete = 0;
|
14154 | var RootFatalErrored = 1;
|
14155 | var RootErrored = 2;
|
14156 | var RootSuspended = 3;
|
14157 | var RootSuspendedWithDelay = 4;
|
14158 | var RootCompleted = 5;
|
14159 |
|
14160 | var executionContext = NoContext;
|
14161 |
|
14162 | var workInProgressRoot = null;
|
14163 |
|
14164 | var workInProgress = null;
|
14165 |
|
14166 | var renderExpirationTime = NoWork;
|
14167 |
|
14168 | var workInProgressRootExitStatus = RootIncomplete;
|
14169 |
|
14170 | var workInProgressRootFatalError = null;
|
14171 |
|
14172 |
|
14173 |
|
14174 |
|
14175 | var workInProgressRootLatestProcessedExpirationTime = Sync;
|
14176 | var workInProgressRootLatestSuspenseTimeout = Sync;
|
14177 | var workInProgressRootCanSuspendUsingConfig = null;
|
14178 |
|
14179 |
|
14180 | var workInProgressRootNextUnprocessedUpdateTime = NoWork;
|
14181 |
|
14182 |
|
14183 |
|
14184 | var workInProgressRootHasPendingPing = false;
|
14185 |
|
14186 |
|
14187 | var globalMostRecentFallbackTime = 0;
|
14188 | var FALLBACK_THROTTLE_MS = 500;
|
14189 | var nextEffect = null;
|
14190 | var hasUncaughtError = false;
|
14191 | var firstUncaughtError = null;
|
14192 | var legacyErrorBoundariesThatAlreadyFailed = null;
|
14193 | var rootDoesHavePassiveEffects = false;
|
14194 | var rootWithPendingPassiveEffects = null;
|
14195 | var pendingPassiveEffectsRenderPriority = NoPriority;
|
14196 | var pendingPassiveEffectsExpirationTime = NoWork;
|
14197 | var rootsWithPendingDiscreteUpdates = null;
|
14198 |
|
14199 | var NESTED_UPDATE_LIMIT = 50;
|
14200 | var nestedUpdateCount = 0;
|
14201 | var rootWithNestedUpdates = null;
|
14202 | var NESTED_PASSIVE_UPDATE_LIMIT = 50;
|
14203 | var nestedPassiveUpdateCount = 0;
|
14204 | var interruptedBy = null;
|
14205 |
|
14206 |
|
14207 |
|
14208 |
|
14209 | var spawnedWorkDuringRender = null;
|
14210 |
|
14211 |
|
14212 |
|
14213 |
|
14214 |
|
14215 |
|
14216 |
|
14217 | var currentEventTime = NoWork;
|
14218 | function requestCurrentTimeForUpdate() {
|
14219 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
14220 |
|
14221 | return msToExpirationTime(now());
|
14222 | }
|
14223 |
|
14224 |
|
14225 | if (currentEventTime !== NoWork) {
|
14226 |
|
14227 | return currentEventTime;
|
14228 | }
|
14229 |
|
14230 |
|
14231 | currentEventTime = msToExpirationTime(now());
|
14232 | return currentEventTime;
|
14233 | }
|
14234 | function getCurrentTime() {
|
14235 | return msToExpirationTime(now());
|
14236 | }
|
14237 | function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
|
14238 | var mode = fiber.mode;
|
14239 |
|
14240 | if ((mode & BatchedMode) === NoMode) {
|
14241 | return Sync;
|
14242 | }
|
14243 |
|
14244 | var priorityLevel = getCurrentPriorityLevel();
|
14245 |
|
14246 | if ((mode & ConcurrentMode) === NoMode) {
|
14247 | return priorityLevel === ImmediatePriority ? Sync : Batched;
|
14248 | }
|
14249 |
|
14250 | if ((executionContext & RenderContext) !== NoContext) {
|
14251 |
|
14252 |
|
14253 | return renderExpirationTime;
|
14254 | }
|
14255 |
|
14256 | var expirationTime;
|
14257 |
|
14258 | if (suspenseConfig !== null) {
|
14259 |
|
14260 | expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
|
14261 | } else {
|
14262 |
|
14263 | switch (priorityLevel) {
|
14264 | case ImmediatePriority:
|
14265 | expirationTime = Sync;
|
14266 | break;
|
14267 |
|
14268 | case UserBlockingPriority:
|
14269 |
|
14270 | expirationTime = computeInteractiveExpiration(currentTime);
|
14271 | break;
|
14272 |
|
14273 | case NormalPriority:
|
14274 | case LowPriority:
|
14275 |
|
14276 |
|
14277 | expirationTime = computeAsyncExpiration(currentTime);
|
14278 | break;
|
14279 |
|
14280 | case IdlePriority:
|
14281 | expirationTime = Idle;
|
14282 | break;
|
14283 |
|
14284 | default:
|
14285 | {
|
14286 | {
|
14287 | throw Error("Expected a valid priority level");
|
14288 | }
|
14289 | }
|
14290 |
|
14291 | }
|
14292 | }
|
14293 |
|
14294 |
|
14295 |
|
14296 |
|
14297 |
|
14298 |
|
14299 | if (workInProgressRoot !== null && expirationTime === renderExpirationTime) {
|
14300 |
|
14301 | expirationTime -= 1;
|
14302 | }
|
14303 |
|
14304 | return expirationTime;
|
14305 | }
|
14306 | function scheduleUpdateOnFiber(fiber, expirationTime) {
|
14307 | checkForNestedUpdates();
|
14308 | warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
|
14309 | var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
|
14310 |
|
14311 | if (root === null) {
|
14312 | warnAboutUpdateOnUnmountedFiberInDEV(fiber);
|
14313 | return;
|
14314 | }
|
14315 |
|
14316 | checkForInterruption(fiber, expirationTime);
|
14317 | recordScheduleUpdate();
|
14318 |
|
14319 |
|
14320 | var priorityLevel = getCurrentPriorityLevel();
|
14321 |
|
14322 | if (expirationTime === Sync) {
|
14323 | if (
|
14324 | (executionContext & LegacyUnbatchedContext) !== NoContext &&
|
14325 | (executionContext & (RenderContext | CommitContext)) === NoContext) {
|
14326 |
|
14327 | schedulePendingInteractions(root, expirationTime);
|
14328 |
|
14329 |
|
14330 |
|
14331 | performSyncWorkOnRoot(root);
|
14332 | } else {
|
14333 | ensureRootIsScheduled(root);
|
14334 | schedulePendingInteractions(root, expirationTime);
|
14335 |
|
14336 | if (executionContext === NoContext) {
|
14337 |
|
14338 |
|
14339 |
|
14340 |
|
14341 |
|
14342 | flushSyncCallbackQueue();
|
14343 | }
|
14344 | }
|
14345 | } else {
|
14346 | ensureRootIsScheduled(root);
|
14347 | schedulePendingInteractions(root, expirationTime);
|
14348 | }
|
14349 |
|
14350 | if ((executionContext & DiscreteEventContext) !== NoContext && (
|
14351 |
|
14352 | priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority)) {
|
14353 |
|
14354 |
|
14355 | if (rootsWithPendingDiscreteUpdates === null) {
|
14356 | rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
|
14357 | } else {
|
14358 | var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
|
14359 |
|
14360 | if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
|
14361 | rootsWithPendingDiscreteUpdates.set(root, expirationTime);
|
14362 | }
|
14363 | }
|
14364 | }
|
14365 | }
|
14366 | var scheduleWork = scheduleUpdateOnFiber;
|
14367 |
|
14368 |
|
14369 |
|
14370 |
|
14371 | function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
|
14372 |
|
14373 | if (fiber.expirationTime < expirationTime) {
|
14374 | fiber.expirationTime = expirationTime;
|
14375 | }
|
14376 |
|
14377 | var alternate = fiber.alternate;
|
14378 |
|
14379 | if (alternate !== null && alternate.expirationTime < expirationTime) {
|
14380 | alternate.expirationTime = expirationTime;
|
14381 | }
|
14382 |
|
14383 |
|
14384 | var node = fiber.return;
|
14385 | var root = null;
|
14386 |
|
14387 | if (node === null && fiber.tag === HostRoot) {
|
14388 | root = fiber.stateNode;
|
14389 | } else {
|
14390 | while (node !== null) {
|
14391 | alternate = node.alternate;
|
14392 |
|
14393 | if (node.childExpirationTime < expirationTime) {
|
14394 | node.childExpirationTime = expirationTime;
|
14395 |
|
14396 | if (alternate !== null && alternate.childExpirationTime < expirationTime) {
|
14397 | alternate.childExpirationTime = expirationTime;
|
14398 | }
|
14399 | } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
|
14400 | alternate.childExpirationTime = expirationTime;
|
14401 | }
|
14402 |
|
14403 | if (node.return === null && node.tag === HostRoot) {
|
14404 | root = node.stateNode;
|
14405 | break;
|
14406 | }
|
14407 |
|
14408 | node = node.return;
|
14409 | }
|
14410 | }
|
14411 |
|
14412 | if (root !== null) {
|
14413 | if (workInProgressRoot === root) {
|
14414 |
|
14415 |
|
14416 | markUnprocessedUpdateTime(expirationTime);
|
14417 |
|
14418 | if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
|
14419 |
|
14420 |
|
14421 |
|
14422 |
|
14423 |
|
14424 |
|
14425 |
|
14426 |
|
14427 |
|
14428 |
|
14429 |
|
14430 |
|
14431 |
|
14432 | markRootSuspendedAtTime(root, renderExpirationTime);
|
14433 | }
|
14434 | }
|
14435 |
|
14436 |
|
14437 | markRootUpdatedAtTime(root, expirationTime);
|
14438 | }
|
14439 |
|
14440 | return root;
|
14441 | }
|
14442 |
|
14443 | function getNextRootExpirationTimeToWorkOn(root) {
|
14444 |
|
14445 |
|
14446 |
|
14447 | var lastExpiredTime = root.lastExpiredTime;
|
14448 |
|
14449 | if (lastExpiredTime !== NoWork) {
|
14450 | return lastExpiredTime;
|
14451 | }
|
14452 |
|
14453 |
|
14454 |
|
14455 | var firstPendingTime = root.firstPendingTime;
|
14456 |
|
14457 | if (!isRootSuspendedAtTime(root, firstPendingTime)) {
|
14458 |
|
14459 | return firstPendingTime;
|
14460 | }
|
14461 |
|
14462 |
|
14463 |
|
14464 |
|
14465 | var lastPingedTime = root.lastPingedTime;
|
14466 | var nextKnownPendingLevel = root.nextKnownPendingLevel;
|
14467 | return lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel;
|
14468 | }
|
14469 |
|
14470 |
|
14471 |
|
14472 |
|
14473 |
|
14474 |
|
14475 | function ensureRootIsScheduled(root) {
|
14476 | var lastExpiredTime = root.lastExpiredTime;
|
14477 |
|
14478 | if (lastExpiredTime !== NoWork) {
|
14479 |
|
14480 | root.callbackExpirationTime = Sync;
|
14481 | root.callbackPriority = ImmediatePriority;
|
14482 | root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
|
14483 | return;
|
14484 | }
|
14485 |
|
14486 | var expirationTime = getNextRootExpirationTimeToWorkOn(root);
|
14487 | var existingCallbackNode = root.callbackNode;
|
14488 |
|
14489 | if (expirationTime === NoWork) {
|
14490 |
|
14491 | if (existingCallbackNode !== null) {
|
14492 | root.callbackNode = null;
|
14493 | root.callbackExpirationTime = NoWork;
|
14494 | root.callbackPriority = NoPriority;
|
14495 | }
|
14496 |
|
14497 | return;
|
14498 | }
|
14499 |
|
14500 |
|
14501 |
|
14502 | var currentTime = requestCurrentTimeForUpdate();
|
14503 | var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
|
14504 |
|
14505 |
|
14506 | if (existingCallbackNode !== null) {
|
14507 | var existingCallbackPriority = root.callbackPriority;
|
14508 | var existingCallbackExpirationTime = root.callbackExpirationTime;
|
14509 |
|
14510 | if (
|
14511 | existingCallbackExpirationTime === expirationTime &&
|
14512 | existingCallbackPriority >= priorityLevel) {
|
14513 |
|
14514 | return;
|
14515 | }
|
14516 |
|
14517 |
|
14518 |
|
14519 |
|
14520 | cancelCallback(existingCallbackNode);
|
14521 | }
|
14522 |
|
14523 | root.callbackExpirationTime = expirationTime;
|
14524 | root.callbackPriority = priorityLevel;
|
14525 | var callbackNode;
|
14526 |
|
14527 | if (expirationTime === Sync) {
|
14528 |
|
14529 | callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
|
14530 | } else if (disableSchedulerTimeoutBasedOnReactExpirationTime) {
|
14531 | callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root));
|
14532 | } else {
|
14533 | callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root),
|
14534 |
|
14535 | {
|
14536 | timeout: expirationTimeToMs(expirationTime) - now()
|
14537 | });
|
14538 | }
|
14539 |
|
14540 | root.callbackNode = callbackNode;
|
14541 | }
|
14542 |
|
14543 |
|
14544 |
|
14545 | function performConcurrentWorkOnRoot(root, didTimeout) {
|
14546 |
|
14547 |
|
14548 | currentEventTime = NoWork;
|
14549 |
|
14550 | if (didTimeout) {
|
14551 |
|
14552 |
|
14553 | var currentTime = requestCurrentTimeForUpdate();
|
14554 | markRootExpiredAtTime(root, currentTime);
|
14555 |
|
14556 | ensureRootIsScheduled(root);
|
14557 | return null;
|
14558 | }
|
14559 |
|
14560 |
|
14561 |
|
14562 | var expirationTime = getNextRootExpirationTimeToWorkOn(root);
|
14563 |
|
14564 | if (expirationTime !== NoWork) {
|
14565 | var originalCallbackNode = root.callbackNode;
|
14566 |
|
14567 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
14568 | {
|
14569 | throw Error("Should not already be working.");
|
14570 | }
|
14571 | }
|
14572 |
|
14573 | flushPassiveEffects();
|
14574 |
|
14575 |
|
14576 | if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
|
14577 | prepareFreshStack(root, expirationTime);
|
14578 | startWorkOnPendingInteractions(root, expirationTime);
|
14579 | }
|
14580 |
|
14581 |
|
14582 |
|
14583 | if (workInProgress !== null) {
|
14584 | var prevExecutionContext = executionContext;
|
14585 | executionContext |= RenderContext;
|
14586 | var prevDispatcher = pushDispatcher(root);
|
14587 | var prevInteractions = pushInteractions(root);
|
14588 | startWorkLoopTimer(workInProgress);
|
14589 |
|
14590 | do {
|
14591 | try {
|
14592 | workLoopConcurrent();
|
14593 | break;
|
14594 | } catch (thrownValue) {
|
14595 | handleError(root, thrownValue);
|
14596 | }
|
14597 | } while (true);
|
14598 |
|
14599 | resetContextDependencies();
|
14600 | executionContext = prevExecutionContext;
|
14601 | popDispatcher(prevDispatcher);
|
14602 |
|
14603 | if (enableSchedulerTracing) {
|
14604 | popInteractions(prevInteractions);
|
14605 | }
|
14606 |
|
14607 | if (workInProgressRootExitStatus === RootFatalErrored) {
|
14608 | var fatalError = workInProgressRootFatalError;
|
14609 | stopInterruptedWorkLoopTimer();
|
14610 | prepareFreshStack(root, expirationTime);
|
14611 | markRootSuspendedAtTime(root, expirationTime);
|
14612 | ensureRootIsScheduled(root);
|
14613 | throw fatalError;
|
14614 | }
|
14615 |
|
14616 | if (workInProgress !== null) {
|
14617 |
|
14618 | stopInterruptedWorkLoopTimer();
|
14619 | } else {
|
14620 |
|
14621 |
|
14622 | stopFinishedWorkLoopTimer();
|
14623 | var finishedWork = root.finishedWork = root.current.alternate;
|
14624 | root.finishedExpirationTime = expirationTime;
|
14625 | finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime);
|
14626 | }
|
14627 |
|
14628 | ensureRootIsScheduled(root);
|
14629 |
|
14630 | if (root.callbackNode === originalCallbackNode) {
|
14631 |
|
14632 |
|
14633 | return performConcurrentWorkOnRoot.bind(null, root);
|
14634 | }
|
14635 | }
|
14636 | }
|
14637 |
|
14638 | return null;
|
14639 | }
|
14640 |
|
14641 | function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
|
14642 |
|
14643 | workInProgressRoot = null;
|
14644 |
|
14645 | switch (exitStatus) {
|
14646 | case RootIncomplete:
|
14647 | case RootFatalErrored:
|
14648 | {
|
14649 | {
|
14650 | {
|
14651 | throw Error("Root did not complete. This is a bug in React.");
|
14652 | }
|
14653 | }
|
14654 | }
|
14655 |
|
14656 |
|
14657 |
|
14658 |
|
14659 | case RootErrored:
|
14660 | {
|
14661 |
|
14662 |
|
14663 |
|
14664 |
|
14665 |
|
14666 |
|
14667 |
|
14668 | markRootExpiredAtTime(root, expirationTime > Idle ? Idle : expirationTime);
|
14669 |
|
14670 |
|
14671 | break;
|
14672 | }
|
14673 |
|
14674 | case RootSuspended:
|
14675 | {
|
14676 | markRootSuspendedAtTime(root, expirationTime);
|
14677 | var lastSuspendedTime = root.lastSuspendedTime;
|
14678 |
|
14679 | if (expirationTime === lastSuspendedTime) {
|
14680 | root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
|
14681 | }
|
14682 |
|
14683 | flushSuspensePriorityWarningInDEV();
|
14684 |
|
14685 |
|
14686 |
|
14687 |
|
14688 |
|
14689 | var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
|
14690 |
|
14691 | if (hasNotProcessedNewUpdates &&
|
14692 | !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
|
14693 |
|
14694 |
|
14695 |
|
14696 |
|
14697 |
|
14698 |
|
14699 | var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now();
|
14700 |
|
14701 | if (msUntilTimeout > 10) {
|
14702 | if (workInProgressRootHasPendingPing) {
|
14703 | var lastPingedTime = root.lastPingedTime;
|
14704 |
|
14705 | if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
|
14706 |
|
14707 |
|
14708 | root.lastPingedTime = expirationTime;
|
14709 | prepareFreshStack(root, expirationTime);
|
14710 | break;
|
14711 | }
|
14712 | }
|
14713 |
|
14714 | var nextTime = getNextRootExpirationTimeToWorkOn(root);
|
14715 |
|
14716 | if (nextTime !== NoWork && nextTime !== expirationTime) {
|
14717 |
|
14718 | break;
|
14719 | }
|
14720 |
|
14721 | if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) {
|
14722 |
|
14723 |
|
14724 |
|
14725 | root.lastPingedTime = lastSuspendedTime;
|
14726 | break;
|
14727 | }
|
14728 |
|
14729 |
|
14730 |
|
14731 |
|
14732 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
|
14733 | break;
|
14734 | }
|
14735 | }
|
14736 |
|
14737 |
|
14738 | commitRoot(root);
|
14739 | break;
|
14740 | }
|
14741 |
|
14742 | case RootSuspendedWithDelay:
|
14743 | {
|
14744 | markRootSuspendedAtTime(root, expirationTime);
|
14745 | var _lastSuspendedTime = root.lastSuspendedTime;
|
14746 |
|
14747 | if (expirationTime === _lastSuspendedTime) {
|
14748 | root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
|
14749 | }
|
14750 |
|
14751 | flushSuspensePriorityWarningInDEV();
|
14752 |
|
14753 | if (
|
14754 | !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
|
14755 |
|
14756 |
|
14757 | if (workInProgressRootHasPendingPing) {
|
14758 | var _lastPingedTime = root.lastPingedTime;
|
14759 |
|
14760 | if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
|
14761 |
|
14762 |
|
14763 | root.lastPingedTime = expirationTime;
|
14764 | prepareFreshStack(root, expirationTime);
|
14765 | break;
|
14766 | }
|
14767 | }
|
14768 |
|
14769 | var _nextTime = getNextRootExpirationTimeToWorkOn(root);
|
14770 |
|
14771 | if (_nextTime !== NoWork && _nextTime !== expirationTime) {
|
14772 |
|
14773 | break;
|
14774 | }
|
14775 |
|
14776 | if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) {
|
14777 |
|
14778 |
|
14779 |
|
14780 | root.lastPingedTime = _lastSuspendedTime;
|
14781 | break;
|
14782 | }
|
14783 |
|
14784 | var _msUntilTimeout;
|
14785 |
|
14786 | if (workInProgressRootLatestSuspenseTimeout !== Sync) {
|
14787 |
|
14788 |
|
14789 | _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
|
14790 | } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
|
14791 |
|
14792 |
|
14793 |
|
14794 | _msUntilTimeout = 0;
|
14795 | } else {
|
14796 |
|
14797 |
|
14798 | var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
|
14799 | var currentTimeMs = now();
|
14800 | var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
|
14801 | var timeElapsed = currentTimeMs - eventTimeMs;
|
14802 |
|
14803 | if (timeElapsed < 0) {
|
14804 |
|
14805 | timeElapsed = 0;
|
14806 | }
|
14807 |
|
14808 | _msUntilTimeout = jnd(timeElapsed) - timeElapsed;
|
14809 |
|
14810 |
|
14811 |
|
14812 | if (timeUntilExpirationMs < _msUntilTimeout) {
|
14813 | _msUntilTimeout = timeUntilExpirationMs;
|
14814 | }
|
14815 | }
|
14816 |
|
14817 |
|
14818 | if (_msUntilTimeout > 10) {
|
14819 |
|
14820 |
|
14821 |
|
14822 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
|
14823 | break;
|
14824 | }
|
14825 | }
|
14826 |
|
14827 |
|
14828 | commitRoot(root);
|
14829 | break;
|
14830 | }
|
14831 |
|
14832 | case RootCompleted:
|
14833 | {
|
14834 |
|
14835 | if (
|
14836 | !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
|
14837 |
|
14838 |
|
14839 |
|
14840 |
|
14841 | var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
|
14842 |
|
14843 | if (_msUntilTimeout2 > 10) {
|
14844 | markRootSuspendedAtTime(root, expirationTime);
|
14845 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
|
14846 | break;
|
14847 | }
|
14848 | }
|
14849 |
|
14850 | commitRoot(root);
|
14851 | break;
|
14852 | }
|
14853 |
|
14854 | default:
|
14855 | {
|
14856 | {
|
14857 | {
|
14858 | throw Error("Unknown root exit status.");
|
14859 | }
|
14860 | }
|
14861 | }
|
14862 | }
|
14863 | }
|
14864 |
|
14865 |
|
14866 |
|
14867 | function performSyncWorkOnRoot(root) {
|
14868 |
|
14869 | var lastExpiredTime = root.lastExpiredTime;
|
14870 | var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync;
|
14871 |
|
14872 | if (root.finishedExpirationTime === expirationTime) {
|
14873 |
|
14874 |
|
14875 |
|
14876 | commitRoot(root);
|
14877 | } else {
|
14878 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
14879 | {
|
14880 | throw Error("Should not already be working.");
|
14881 | }
|
14882 | }
|
14883 |
|
14884 | flushPassiveEffects();
|
14885 |
|
14886 |
|
14887 | if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
|
14888 | prepareFreshStack(root, expirationTime);
|
14889 | startWorkOnPendingInteractions(root, expirationTime);
|
14890 | }
|
14891 |
|
14892 |
|
14893 |
|
14894 | if (workInProgress !== null) {
|
14895 | var prevExecutionContext = executionContext;
|
14896 | executionContext |= RenderContext;
|
14897 | var prevDispatcher = pushDispatcher(root);
|
14898 | var prevInteractions = pushInteractions(root);
|
14899 | startWorkLoopTimer(workInProgress);
|
14900 |
|
14901 | do {
|
14902 | try {
|
14903 | workLoopSync();
|
14904 | break;
|
14905 | } catch (thrownValue) {
|
14906 | handleError(root, thrownValue);
|
14907 | }
|
14908 | } while (true);
|
14909 |
|
14910 | resetContextDependencies();
|
14911 | executionContext = prevExecutionContext;
|
14912 | popDispatcher(prevDispatcher);
|
14913 |
|
14914 | if (enableSchedulerTracing) {
|
14915 | popInteractions(prevInteractions);
|
14916 | }
|
14917 |
|
14918 | if (workInProgressRootExitStatus === RootFatalErrored) {
|
14919 | var fatalError = workInProgressRootFatalError;
|
14920 | stopInterruptedWorkLoopTimer();
|
14921 | prepareFreshStack(root, expirationTime);
|
14922 | markRootSuspendedAtTime(root, expirationTime);
|
14923 | ensureRootIsScheduled(root);
|
14924 | throw fatalError;
|
14925 | }
|
14926 |
|
14927 | if (workInProgress !== null) {
|
14928 |
|
14929 | {
|
14930 | {
|
14931 | throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");
|
14932 | }
|
14933 | }
|
14934 | } else {
|
14935 |
|
14936 |
|
14937 | stopFinishedWorkLoopTimer();
|
14938 | root.finishedWork = root.current.alternate;
|
14939 | root.finishedExpirationTime = expirationTime;
|
14940 | finishSyncRender(root, workInProgressRootExitStatus, expirationTime);
|
14941 | }
|
14942 |
|
14943 |
|
14944 |
|
14945 | ensureRootIsScheduled(root);
|
14946 | }
|
14947 | }
|
14948 |
|
14949 | return null;
|
14950 | }
|
14951 |
|
14952 | function finishSyncRender(root, exitStatus, expirationTime) {
|
14953 |
|
14954 | workInProgressRoot = null;
|
14955 |
|
14956 | {
|
14957 | if (exitStatus === RootSuspended || exitStatus === RootSuspendedWithDelay) {
|
14958 | flushSuspensePriorityWarningInDEV();
|
14959 | }
|
14960 | }
|
14961 |
|
14962 | commitRoot(root);
|
14963 | }
|
14964 |
|
14965 |
|
14966 |
|
14967 |
|
14968 | function syncUpdates(fn, a, b, c) {
|
14969 | return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c));
|
14970 | }
|
14971 |
|
14972 |
|
14973 |
|
14974 |
|
14975 |
|
14976 | function flushSync(fn, a) {
|
14977 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
14978 | {
|
14979 | {
|
14980 | throw Error("flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.");
|
14981 | }
|
14982 | }
|
14983 | }
|
14984 |
|
14985 | var prevExecutionContext = executionContext;
|
14986 | executionContext |= BatchedContext;
|
14987 |
|
14988 | try {
|
14989 | return runWithPriority(ImmediatePriority, fn.bind(null, a));
|
14990 | } finally {
|
14991 | executionContext = prevExecutionContext;
|
14992 |
|
14993 |
|
14994 |
|
14995 | flushSyncCallbackQueue();
|
14996 | }
|
14997 | }
|
14998 |
|
14999 |
|
15000 | function prepareFreshStack(root, expirationTime) {
|
15001 | root.finishedWork = null;
|
15002 | root.finishedExpirationTime = NoWork;
|
15003 | var timeoutHandle = root.timeoutHandle;
|
15004 |
|
15005 | if (timeoutHandle !== noTimeout) {
|
15006 |
|
15007 |
|
15008 | root.timeoutHandle = noTimeout;
|
15009 |
|
15010 | cancelTimeout(timeoutHandle);
|
15011 | }
|
15012 |
|
15013 | if (workInProgress !== null) {
|
15014 | var interruptedWork = workInProgress.return;
|
15015 |
|
15016 | while (interruptedWork !== null) {
|
15017 | unwindInterruptedWork(interruptedWork);
|
15018 | interruptedWork = interruptedWork.return;
|
15019 | }
|
15020 | }
|
15021 |
|
15022 | workInProgressRoot = root;
|
15023 | workInProgress = createWorkInProgress(root.current, null, expirationTime);
|
15024 | renderExpirationTime = expirationTime;
|
15025 | workInProgressRootExitStatus = RootIncomplete;
|
15026 | workInProgressRootFatalError = null;
|
15027 | workInProgressRootLatestProcessedExpirationTime = Sync;
|
15028 | workInProgressRootLatestSuspenseTimeout = Sync;
|
15029 | workInProgressRootCanSuspendUsingConfig = null;
|
15030 | workInProgressRootNextUnprocessedUpdateTime = NoWork;
|
15031 | workInProgressRootHasPendingPing = false;
|
15032 |
|
15033 | if (enableSchedulerTracing) {
|
15034 | spawnedWorkDuringRender = null;
|
15035 | }
|
15036 |
|
15037 | {
|
15038 | ReactStrictModeWarnings.discardPendingWarnings();
|
15039 | componentsThatTriggeredHighPriSuspend = null;
|
15040 | }
|
15041 | }
|
15042 |
|
15043 | function handleError(root, thrownValue) {
|
15044 | do {
|
15045 | try {
|
15046 |
|
15047 | resetContextDependencies();
|
15048 | resetHooks();
|
15049 | resetCurrentFiber();
|
15050 |
|
15051 | if (workInProgress === null || workInProgress.return === null) {
|
15052 |
|
15053 |
|
15054 |
|
15055 |
|
15056 | workInProgressRootExitStatus = RootFatalErrored;
|
15057 | workInProgressRootFatalError = thrownValue;
|
15058 | return null;
|
15059 | }
|
15060 |
|
15061 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
15062 |
|
15063 |
|
15064 |
|
15065 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
|
15066 | }
|
15067 |
|
15068 | throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime);
|
15069 | workInProgress = completeUnitOfWork(workInProgress);
|
15070 | } catch (yetAnotherThrownValue) {
|
15071 |
|
15072 | thrownValue = yetAnotherThrownValue;
|
15073 | continue;
|
15074 | }
|
15075 |
|
15076 |
|
15077 | return;
|
15078 | } while (true);
|
15079 | }
|
15080 |
|
15081 | function pushDispatcher(root) {
|
15082 | var prevDispatcher = ReactCurrentDispatcher.current;
|
15083 | ReactCurrentDispatcher.current = ContextOnlyDispatcher;
|
15084 |
|
15085 | if (prevDispatcher === null) {
|
15086 |
|
15087 |
|
15088 |
|
15089 | return ContextOnlyDispatcher;
|
15090 | } else {
|
15091 | return prevDispatcher;
|
15092 | }
|
15093 | }
|
15094 |
|
15095 | function popDispatcher(prevDispatcher) {
|
15096 | ReactCurrentDispatcher.current = prevDispatcher;
|
15097 | }
|
15098 |
|
15099 | function pushInteractions(root) {
|
15100 | if (enableSchedulerTracing) {
|
15101 | var prevInteractions = __interactionsRef.current;
|
15102 | __interactionsRef.current = root.memoizedInteractions;
|
15103 | return prevInteractions;
|
15104 | }
|
15105 |
|
15106 | return null;
|
15107 | }
|
15108 |
|
15109 | function popInteractions(prevInteractions) {
|
15110 | if (enableSchedulerTracing) {
|
15111 | __interactionsRef.current = prevInteractions;
|
15112 | }
|
15113 | }
|
15114 |
|
15115 | function markCommitTimeOfFallback() {
|
15116 | globalMostRecentFallbackTime = now();
|
15117 | }
|
15118 | function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
|
15119 | if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) {
|
15120 | workInProgressRootLatestProcessedExpirationTime = expirationTime;
|
15121 | }
|
15122 |
|
15123 | if (suspenseConfig !== null) {
|
15124 | if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) {
|
15125 | workInProgressRootLatestSuspenseTimeout = expirationTime;
|
15126 |
|
15127 | workInProgressRootCanSuspendUsingConfig = suspenseConfig;
|
15128 | }
|
15129 | }
|
15130 | }
|
15131 | function markUnprocessedUpdateTime(expirationTime) {
|
15132 | if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
|
15133 | workInProgressRootNextUnprocessedUpdateTime = expirationTime;
|
15134 | }
|
15135 | }
|
15136 | function renderDidSuspend() {
|
15137 | if (workInProgressRootExitStatus === RootIncomplete) {
|
15138 | workInProgressRootExitStatus = RootSuspended;
|
15139 | }
|
15140 | }
|
15141 | function renderDidSuspendDelayIfPossible() {
|
15142 | if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
|
15143 | workInProgressRootExitStatus = RootSuspendedWithDelay;
|
15144 | }
|
15145 |
|
15146 |
|
15147 | if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) {
|
15148 |
|
15149 |
|
15150 |
|
15151 |
|
15152 | markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime);
|
15153 | markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime);
|
15154 | }
|
15155 | }
|
15156 | function renderDidError() {
|
15157 | if (workInProgressRootExitStatus !== RootCompleted) {
|
15158 | workInProgressRootExitStatus = RootErrored;
|
15159 | }
|
15160 | }
|
15161 |
|
15162 |
|
15163 | function renderHasNotSuspendedYet() {
|
15164 |
|
15165 |
|
15166 | return workInProgressRootExitStatus === RootIncomplete;
|
15167 | }
|
15168 |
|
15169 | function inferTimeFromExpirationTime(expirationTime) {
|
15170 |
|
15171 |
|
15172 | var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
|
15173 | return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
|
15174 | }
|
15175 |
|
15176 | function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
|
15177 |
|
15178 |
|
15179 |
|
15180 | var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
|
15181 | return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
|
15182 | }
|
15183 |
|
15184 |
|
15185 |
|
15186 |
|
15187 | function workLoopSync() {
|
15188 |
|
15189 | while (workInProgress !== null) {
|
15190 | workInProgress = performUnitOfWork(workInProgress);
|
15191 | }
|
15192 | }
|
15193 |
|
15194 |
|
15195 |
|
15196 | function workLoopConcurrent() {
|
15197 |
|
15198 | while (workInProgress !== null && !shouldYield()) {
|
15199 | workInProgress = performUnitOfWork(workInProgress);
|
15200 | }
|
15201 | }
|
15202 |
|
15203 | function performUnitOfWork(unitOfWork) {
|
15204 |
|
15205 |
|
15206 |
|
15207 | var current = unitOfWork.alternate;
|
15208 | startWorkTimer(unitOfWork);
|
15209 | setCurrentFiber(unitOfWork);
|
15210 | var next;
|
15211 |
|
15212 | if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
|
15213 | startProfilerTimer(unitOfWork);
|
15214 | next = beginWork$$1(current, unitOfWork, renderExpirationTime);
|
15215 | stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
|
15216 | } else {
|
15217 | next = beginWork$$1(current, unitOfWork, renderExpirationTime);
|
15218 | }
|
15219 |
|
15220 | resetCurrentFiber();
|
15221 | unitOfWork.memoizedProps = unitOfWork.pendingProps;
|
15222 |
|
15223 | if (next === null) {
|
15224 |
|
15225 | next = completeUnitOfWork(unitOfWork);
|
15226 | }
|
15227 |
|
15228 | ReactCurrentOwner$1.current = null;
|
15229 | return next;
|
15230 | }
|
15231 |
|
15232 | function completeUnitOfWork(unitOfWork) {
|
15233 |
|
15234 |
|
15235 | workInProgress = unitOfWork;
|
15236 |
|
15237 | do {
|
15238 |
|
15239 |
|
15240 |
|
15241 | var current = workInProgress.alternate;
|
15242 | var returnFiber = workInProgress.return;
|
15243 |
|
15244 | if ((workInProgress.effectTag & Incomplete) === NoEffect) {
|
15245 | setCurrentFiber(workInProgress);
|
15246 | var next = void 0;
|
15247 |
|
15248 | if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoMode) {
|
15249 | next = completeWork(current, workInProgress, renderExpirationTime);
|
15250 | } else {
|
15251 | startProfilerTimer(workInProgress);
|
15252 | next = completeWork(current, workInProgress, renderExpirationTime);
|
15253 |
|
15254 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
|
15255 | }
|
15256 |
|
15257 | stopWorkTimer(workInProgress);
|
15258 | resetCurrentFiber();
|
15259 | resetChildExpirationTime(workInProgress);
|
15260 |
|
15261 | if (next !== null) {
|
15262 |
|
15263 | return next;
|
15264 | }
|
15265 |
|
15266 | if (returnFiber !== null &&
|
15267 | (returnFiber.effectTag & Incomplete) === NoEffect) {
|
15268 |
|
15269 |
|
15270 |
|
15271 | if (returnFiber.firstEffect === null) {
|
15272 | returnFiber.firstEffect = workInProgress.firstEffect;
|
15273 | }
|
15274 |
|
15275 | if (workInProgress.lastEffect !== null) {
|
15276 | if (returnFiber.lastEffect !== null) {
|
15277 | returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
|
15278 | }
|
15279 |
|
15280 | returnFiber.lastEffect = workInProgress.lastEffect;
|
15281 | }
|
15282 |
|
15283 |
|
15284 |
|
15285 |
|
15286 |
|
15287 |
|
15288 |
|
15289 | var effectTag = workInProgress.effectTag;
|
15290 |
|
15291 |
|
15292 |
|
15293 | if (effectTag > PerformedWork) {
|
15294 | if (returnFiber.lastEffect !== null) {
|
15295 | returnFiber.lastEffect.nextEffect = workInProgress;
|
15296 | } else {
|
15297 | returnFiber.firstEffect = workInProgress;
|
15298 | }
|
15299 |
|
15300 | returnFiber.lastEffect = workInProgress;
|
15301 | }
|
15302 | }
|
15303 | } else {
|
15304 |
|
15305 |
|
15306 |
|
15307 | var _next = unwindWork(workInProgress, renderExpirationTime);
|
15308 |
|
15309 |
|
15310 | if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode) {
|
15311 |
|
15312 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
|
15313 |
|
15314 | var actualDuration = workInProgress.actualDuration;
|
15315 | var child = workInProgress.child;
|
15316 |
|
15317 | while (child !== null) {
|
15318 | actualDuration += child.actualDuration;
|
15319 | child = child.sibling;
|
15320 | }
|
15321 |
|
15322 | workInProgress.actualDuration = actualDuration;
|
15323 | }
|
15324 |
|
15325 | if (_next !== null) {
|
15326 |
|
15327 |
|
15328 |
|
15329 |
|
15330 |
|
15331 |
|
15332 | stopFailedWorkTimer(workInProgress);
|
15333 | _next.effectTag &= HostEffectMask;
|
15334 | return _next;
|
15335 | }
|
15336 |
|
15337 | stopWorkTimer(workInProgress);
|
15338 |
|
15339 | if (returnFiber !== null) {
|
15340 |
|
15341 | returnFiber.firstEffect = returnFiber.lastEffect = null;
|
15342 | returnFiber.effectTag |= Incomplete;
|
15343 | }
|
15344 | }
|
15345 |
|
15346 | var siblingFiber = workInProgress.sibling;
|
15347 |
|
15348 | if (siblingFiber !== null) {
|
15349 |
|
15350 | return siblingFiber;
|
15351 | }
|
15352 |
|
15353 |
|
15354 | workInProgress = returnFiber;
|
15355 | } while (workInProgress !== null);
|
15356 |
|
15357 |
|
15358 | if (workInProgressRootExitStatus === RootIncomplete) {
|
15359 | workInProgressRootExitStatus = RootCompleted;
|
15360 | }
|
15361 |
|
15362 | return null;
|
15363 | }
|
15364 |
|
15365 | function getRemainingExpirationTime(fiber) {
|
15366 | var updateExpirationTime = fiber.expirationTime;
|
15367 | var childExpirationTime = fiber.childExpirationTime;
|
15368 | return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime;
|
15369 | }
|
15370 |
|
15371 | function resetChildExpirationTime(completedWork) {
|
15372 | if (renderExpirationTime !== Never && completedWork.childExpirationTime === Never) {
|
15373 |
|
15374 |
|
15375 | return;
|
15376 | }
|
15377 |
|
15378 | var newChildExpirationTime = NoWork;
|
15379 |
|
15380 | if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
|
15381 |
|
15382 |
|
15383 | var actualDuration = completedWork.actualDuration;
|
15384 | var treeBaseDuration = completedWork.selfBaseDuration;
|
15385 |
|
15386 |
|
15387 |
|
15388 |
|
15389 |
|
15390 |
|
15391 |
|
15392 | var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
|
15393 | var child = completedWork.child;
|
15394 |
|
15395 | while (child !== null) {
|
15396 | var childUpdateExpirationTime = child.expirationTime;
|
15397 | var childChildExpirationTime = child.childExpirationTime;
|
15398 |
|
15399 | if (childUpdateExpirationTime > newChildExpirationTime) {
|
15400 | newChildExpirationTime = childUpdateExpirationTime;
|
15401 | }
|
15402 |
|
15403 | if (childChildExpirationTime > newChildExpirationTime) {
|
15404 | newChildExpirationTime = childChildExpirationTime;
|
15405 | }
|
15406 |
|
15407 | if (shouldBubbleActualDurations) {
|
15408 | actualDuration += child.actualDuration;
|
15409 | }
|
15410 |
|
15411 | treeBaseDuration += child.treeBaseDuration;
|
15412 | child = child.sibling;
|
15413 | }
|
15414 |
|
15415 | completedWork.actualDuration = actualDuration;
|
15416 | completedWork.treeBaseDuration = treeBaseDuration;
|
15417 | } else {
|
15418 | var _child = completedWork.child;
|
15419 |
|
15420 | while (_child !== null) {
|
15421 | var _childUpdateExpirationTime = _child.expirationTime;
|
15422 | var _childChildExpirationTime = _child.childExpirationTime;
|
15423 |
|
15424 | if (_childUpdateExpirationTime > newChildExpirationTime) {
|
15425 | newChildExpirationTime = _childUpdateExpirationTime;
|
15426 | }
|
15427 |
|
15428 | if (_childChildExpirationTime > newChildExpirationTime) {
|
15429 | newChildExpirationTime = _childChildExpirationTime;
|
15430 | }
|
15431 |
|
15432 | _child = _child.sibling;
|
15433 | }
|
15434 | }
|
15435 |
|
15436 | completedWork.childExpirationTime = newChildExpirationTime;
|
15437 | }
|
15438 |
|
15439 | function commitRoot(root) {
|
15440 | var renderPriorityLevel = getCurrentPriorityLevel();
|
15441 | runWithPriority(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
|
15442 | return null;
|
15443 | }
|
15444 |
|
15445 | function commitRootImpl(root, renderPriorityLevel) {
|
15446 | flushPassiveEffects();
|
15447 | flushRenderPhaseStrictModeWarningsInDEV();
|
15448 |
|
15449 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
15450 | {
|
15451 | throw Error("Should not already be working.");
|
15452 | }
|
15453 | }
|
15454 |
|
15455 | var finishedWork = root.finishedWork;
|
15456 | var expirationTime = root.finishedExpirationTime;
|
15457 |
|
15458 | if (finishedWork === null) {
|
15459 | return null;
|
15460 | }
|
15461 |
|
15462 | root.finishedWork = null;
|
15463 | root.finishedExpirationTime = NoWork;
|
15464 |
|
15465 | if (!(finishedWork !== root.current)) {
|
15466 | {
|
15467 | throw Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");
|
15468 | }
|
15469 | }
|
15470 |
|
15471 |
|
15472 |
|
15473 | root.callbackNode = null;
|
15474 | root.callbackExpirationTime = NoWork;
|
15475 | root.callbackPriority = NoPriority;
|
15476 | root.nextKnownPendingLevel = NoWork;
|
15477 | startCommitTimer();
|
15478 |
|
15479 |
|
15480 | var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
|
15481 | markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
|
15482 |
|
15483 | if (root === workInProgressRoot) {
|
15484 |
|
15485 | workInProgressRoot = null;
|
15486 | workInProgress = null;
|
15487 | renderExpirationTime = NoWork;
|
15488 | } else {}
|
15489 |
|
15490 |
|
15491 |
|
15492 |
|
15493 |
|
15494 | var firstEffect;
|
15495 |
|
15496 | if (finishedWork.effectTag > PerformedWork) {
|
15497 |
|
15498 |
|
15499 |
|
15500 |
|
15501 | if (finishedWork.lastEffect !== null) {
|
15502 | finishedWork.lastEffect.nextEffect = finishedWork;
|
15503 | firstEffect = finishedWork.firstEffect;
|
15504 | } else {
|
15505 | firstEffect = finishedWork;
|
15506 | }
|
15507 | } else {
|
15508 |
|
15509 | firstEffect = finishedWork.firstEffect;
|
15510 | }
|
15511 |
|
15512 | if (firstEffect !== null) {
|
15513 | var prevExecutionContext = executionContext;
|
15514 | executionContext |= CommitContext;
|
15515 | var prevInteractions = pushInteractions(root);
|
15516 |
|
15517 | ReactCurrentOwner$1.current = null;
|
15518 |
|
15519 |
|
15520 |
|
15521 |
|
15522 |
|
15523 |
|
15524 | startCommitSnapshotEffectsTimer();
|
15525 | prepareForCommit(root.containerInfo);
|
15526 | nextEffect = firstEffect;
|
15527 |
|
15528 | do {
|
15529 | {
|
15530 | invokeGuardedCallback(null, commitBeforeMutationEffects, null);
|
15531 |
|
15532 | if (hasCaughtError()) {
|
15533 | if (!(nextEffect !== null)) {
|
15534 | {
|
15535 | throw Error("Should be working on an effect.");
|
15536 | }
|
15537 | }
|
15538 |
|
15539 | var error = clearCaughtError();
|
15540 | captureCommitPhaseError(nextEffect, error);
|
15541 | nextEffect = nextEffect.nextEffect;
|
15542 | }
|
15543 | }
|
15544 | } while (nextEffect !== null);
|
15545 |
|
15546 | stopCommitSnapshotEffectsTimer();
|
15547 |
|
15548 | if (enableProfilerTimer) {
|
15549 |
|
15550 |
|
15551 | recordCommitTime();
|
15552 | }
|
15553 |
|
15554 |
|
15555 | startCommitHostEffectsTimer();
|
15556 | nextEffect = firstEffect;
|
15557 |
|
15558 | do {
|
15559 | {
|
15560 | invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
|
15561 |
|
15562 | if (hasCaughtError()) {
|
15563 | if (!(nextEffect !== null)) {
|
15564 | {
|
15565 | throw Error("Should be working on an effect.");
|
15566 | }
|
15567 | }
|
15568 |
|
15569 | var _error = clearCaughtError();
|
15570 |
|
15571 | captureCommitPhaseError(nextEffect, _error);
|
15572 | nextEffect = nextEffect.nextEffect;
|
15573 | }
|
15574 | }
|
15575 | } while (nextEffect !== null);
|
15576 |
|
15577 | stopCommitHostEffectsTimer();
|
15578 | resetAfterCommit(root.containerInfo);
|
15579 |
|
15580 |
|
15581 |
|
15582 |
|
15583 | root.current = finishedWork;
|
15584 |
|
15585 |
|
15586 |
|
15587 | startCommitLifeCyclesTimer();
|
15588 | nextEffect = firstEffect;
|
15589 |
|
15590 | do {
|
15591 | {
|
15592 | invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
|
15593 |
|
15594 | if (hasCaughtError()) {
|
15595 | if (!(nextEffect !== null)) {
|
15596 | {
|
15597 | throw Error("Should be working on an effect.");
|
15598 | }
|
15599 | }
|
15600 |
|
15601 | var _error2 = clearCaughtError();
|
15602 |
|
15603 | captureCommitPhaseError(nextEffect, _error2);
|
15604 | nextEffect = nextEffect.nextEffect;
|
15605 | }
|
15606 | }
|
15607 | } while (nextEffect !== null);
|
15608 |
|
15609 | stopCommitLifeCyclesTimer();
|
15610 | nextEffect = null;
|
15611 |
|
15612 |
|
15613 | requestPaint();
|
15614 |
|
15615 | if (enableSchedulerTracing) {
|
15616 | popInteractions(prevInteractions);
|
15617 | }
|
15618 |
|
15619 | executionContext = prevExecutionContext;
|
15620 | } else {
|
15621 |
|
15622 | root.current = finishedWork;
|
15623 |
|
15624 |
|
15625 |
|
15626 | startCommitSnapshotEffectsTimer();
|
15627 | stopCommitSnapshotEffectsTimer();
|
15628 |
|
15629 | if (enableProfilerTimer) {
|
15630 | recordCommitTime();
|
15631 | }
|
15632 |
|
15633 | startCommitHostEffectsTimer();
|
15634 | stopCommitHostEffectsTimer();
|
15635 | startCommitLifeCyclesTimer();
|
15636 | stopCommitLifeCyclesTimer();
|
15637 | }
|
15638 |
|
15639 | stopCommitTimer();
|
15640 | var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
|
15641 |
|
15642 | if (rootDoesHavePassiveEffects) {
|
15643 |
|
15644 |
|
15645 | rootDoesHavePassiveEffects = false;
|
15646 | rootWithPendingPassiveEffects = root;
|
15647 | pendingPassiveEffectsExpirationTime = expirationTime;
|
15648 | pendingPassiveEffectsRenderPriority = renderPriorityLevel;
|
15649 | } else {
|
15650 |
|
15651 |
|
15652 |
|
15653 | nextEffect = firstEffect;
|
15654 |
|
15655 | while (nextEffect !== null) {
|
15656 | var nextNextEffect = nextEffect.nextEffect;
|
15657 | nextEffect.nextEffect = null;
|
15658 | nextEffect = nextNextEffect;
|
15659 | }
|
15660 | }
|
15661 |
|
15662 |
|
15663 | var remainingExpirationTime = root.firstPendingTime;
|
15664 |
|
15665 | if (remainingExpirationTime !== NoWork) {
|
15666 | if (enableSchedulerTracing) {
|
15667 | if (spawnedWorkDuringRender !== null) {
|
15668 | var expirationTimes = spawnedWorkDuringRender;
|
15669 | spawnedWorkDuringRender = null;
|
15670 |
|
15671 | for (var i = 0; i < expirationTimes.length; i++) {
|
15672 | scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
|
15673 | }
|
15674 | }
|
15675 |
|
15676 | schedulePendingInteractions(root, remainingExpirationTime);
|
15677 | }
|
15678 | } else {
|
15679 |
|
15680 |
|
15681 | legacyErrorBoundariesThatAlreadyFailed = null;
|
15682 | }
|
15683 |
|
15684 | if (enableSchedulerTracing) {
|
15685 | if (!rootDidHavePassiveEffects) {
|
15686 |
|
15687 |
|
15688 |
|
15689 |
|
15690 | finishPendingInteractions(root, expirationTime);
|
15691 | }
|
15692 | }
|
15693 |
|
15694 | if (remainingExpirationTime === Sync) {
|
15695 |
|
15696 |
|
15697 | if (root === rootWithNestedUpdates) {
|
15698 | nestedUpdateCount++;
|
15699 | } else {
|
15700 | nestedUpdateCount = 0;
|
15701 | rootWithNestedUpdates = root;
|
15702 | }
|
15703 | } else {
|
15704 | nestedUpdateCount = 0;
|
15705 | }
|
15706 |
|
15707 | onCommitRoot(finishedWork.stateNode, expirationTime);
|
15708 |
|
15709 |
|
15710 | ensureRootIsScheduled(root);
|
15711 |
|
15712 | if (hasUncaughtError) {
|
15713 | hasUncaughtError = false;
|
15714 | var _error3 = firstUncaughtError;
|
15715 | firstUncaughtError = null;
|
15716 | throw _error3;
|
15717 | }
|
15718 |
|
15719 | if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
|
15720 |
|
15721 |
|
15722 |
|
15723 |
|
15724 | return null;
|
15725 | }
|
15726 |
|
15727 |
|
15728 | flushSyncCallbackQueue();
|
15729 | return null;
|
15730 | }
|
15731 |
|
15732 | function commitBeforeMutationEffects() {
|
15733 | while (nextEffect !== null) {
|
15734 | var effectTag = nextEffect.effectTag;
|
15735 |
|
15736 | if ((effectTag & Snapshot) !== NoEffect) {
|
15737 | setCurrentFiber(nextEffect);
|
15738 | recordEffect();
|
15739 | var current = nextEffect.alternate;
|
15740 | commitBeforeMutationLifeCycles(current, nextEffect);
|
15741 | resetCurrentFiber();
|
15742 | }
|
15743 |
|
15744 | if ((effectTag & Passive) !== NoEffect) {
|
15745 |
|
15746 |
|
15747 | if (!rootDoesHavePassiveEffects) {
|
15748 | rootDoesHavePassiveEffects = true;
|
15749 | scheduleCallback(NormalPriority, function () {
|
15750 | flushPassiveEffects();
|
15751 | return null;
|
15752 | });
|
15753 | }
|
15754 | }
|
15755 |
|
15756 | nextEffect = nextEffect.nextEffect;
|
15757 | }
|
15758 | }
|
15759 |
|
15760 | function commitMutationEffects(root, renderPriorityLevel) {
|
15761 |
|
15762 | while (nextEffect !== null) {
|
15763 | setCurrentFiber(nextEffect);
|
15764 | var effectTag = nextEffect.effectTag;
|
15765 |
|
15766 | if (effectTag & ContentReset) {
|
15767 | commitResetTextContent(nextEffect);
|
15768 | }
|
15769 |
|
15770 | if (effectTag & Ref) {
|
15771 | var current = nextEffect.alternate;
|
15772 |
|
15773 | if (current !== null) {
|
15774 | commitDetachRef(current);
|
15775 | }
|
15776 | }
|
15777 |
|
15778 |
|
15779 |
|
15780 |
|
15781 |
|
15782 | var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating);
|
15783 |
|
15784 | switch (primaryEffectTag) {
|
15785 | case Placement:
|
15786 | {
|
15787 | commitPlacement(nextEffect);
|
15788 |
|
15789 |
|
15790 |
|
15791 |
|
15792 | nextEffect.effectTag &= ~Placement;
|
15793 | break;
|
15794 | }
|
15795 |
|
15796 | case PlacementAndUpdate:
|
15797 | {
|
15798 |
|
15799 | commitPlacement(nextEffect);
|
15800 |
|
15801 |
|
15802 | nextEffect.effectTag &= ~Placement;
|
15803 |
|
15804 | var _current = nextEffect.alternate;
|
15805 | commitWork(_current, nextEffect);
|
15806 | break;
|
15807 | }
|
15808 |
|
15809 | case Hydrating:
|
15810 | {
|
15811 | nextEffect.effectTag &= ~Hydrating;
|
15812 | break;
|
15813 | }
|
15814 |
|
15815 | case HydratingAndUpdate:
|
15816 | {
|
15817 | nextEffect.effectTag &= ~Hydrating;
|
15818 |
|
15819 | var _current2 = nextEffect.alternate;
|
15820 | commitWork(_current2, nextEffect);
|
15821 | break;
|
15822 | }
|
15823 |
|
15824 | case Update:
|
15825 | {
|
15826 | var _current3 = nextEffect.alternate;
|
15827 | commitWork(_current3, nextEffect);
|
15828 | break;
|
15829 | }
|
15830 |
|
15831 | case Deletion:
|
15832 | {
|
15833 | commitDeletion(root, nextEffect, renderPriorityLevel);
|
15834 | break;
|
15835 | }
|
15836 | }
|
15837 |
|
15838 |
|
15839 | recordEffect();
|
15840 | resetCurrentFiber();
|
15841 | nextEffect = nextEffect.nextEffect;
|
15842 | }
|
15843 | }
|
15844 |
|
15845 | function commitLayoutEffects(root, committedExpirationTime) {
|
15846 |
|
15847 | while (nextEffect !== null) {
|
15848 | setCurrentFiber(nextEffect);
|
15849 | var effectTag = nextEffect.effectTag;
|
15850 |
|
15851 | if (effectTag & (Update | Callback)) {
|
15852 | recordEffect();
|
15853 | var current = nextEffect.alternate;
|
15854 | commitLifeCycles(root, current, nextEffect, committedExpirationTime);
|
15855 | }
|
15856 |
|
15857 | if (effectTag & Ref) {
|
15858 | recordEffect();
|
15859 | commitAttachRef(nextEffect);
|
15860 | }
|
15861 |
|
15862 | resetCurrentFiber();
|
15863 | nextEffect = nextEffect.nextEffect;
|
15864 | }
|
15865 | }
|
15866 |
|
15867 | function flushPassiveEffects() {
|
15868 | if (pendingPassiveEffectsRenderPriority !== NoPriority) {
|
15869 | var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority;
|
15870 | pendingPassiveEffectsRenderPriority = NoPriority;
|
15871 | return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
|
15872 | }
|
15873 | }
|
15874 |
|
15875 | function flushPassiveEffectsImpl() {
|
15876 | if (rootWithPendingPassiveEffects === null) {
|
15877 | return false;
|
15878 | }
|
15879 |
|
15880 | var root = rootWithPendingPassiveEffects;
|
15881 | var expirationTime = pendingPassiveEffectsExpirationTime;
|
15882 | rootWithPendingPassiveEffects = null;
|
15883 | pendingPassiveEffectsExpirationTime = NoWork;
|
15884 |
|
15885 | if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
15886 | {
|
15887 | throw Error("Cannot flush passive effects while already rendering.");
|
15888 | }
|
15889 | }
|
15890 |
|
15891 | var prevExecutionContext = executionContext;
|
15892 | executionContext |= CommitContext;
|
15893 | var prevInteractions = pushInteractions(root);
|
15894 |
|
15895 |
|
15896 |
|
15897 | var effect = root.current.firstEffect;
|
15898 |
|
15899 | while (effect !== null) {
|
15900 | {
|
15901 | setCurrentFiber(effect);
|
15902 | invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
|
15903 |
|
15904 | if (hasCaughtError()) {
|
15905 | if (!(effect !== null)) {
|
15906 | {
|
15907 | throw Error("Should be working on an effect.");
|
15908 | }
|
15909 | }
|
15910 |
|
15911 | var error = clearCaughtError();
|
15912 | captureCommitPhaseError(effect, error);
|
15913 | }
|
15914 |
|
15915 | resetCurrentFiber();
|
15916 | }
|
15917 |
|
15918 | var nextNextEffect = effect.nextEffect;
|
15919 |
|
15920 | effect.nextEffect = null;
|
15921 | effect = nextNextEffect;
|
15922 | }
|
15923 |
|
15924 | if (enableSchedulerTracing) {
|
15925 | popInteractions(prevInteractions);
|
15926 | finishPendingInteractions(root, expirationTime);
|
15927 | }
|
15928 |
|
15929 | executionContext = prevExecutionContext;
|
15930 | flushSyncCallbackQueue();
|
15931 |
|
15932 |
|
15933 | nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
|
15934 | return true;
|
15935 | }
|
15936 |
|
15937 | function isAlreadyFailedLegacyErrorBoundary(instance) {
|
15938 | return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
|
15939 | }
|
15940 | function markLegacyErrorBoundaryAsFailed(instance) {
|
15941 | if (legacyErrorBoundariesThatAlreadyFailed === null) {
|
15942 | legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
|
15943 | } else {
|
15944 | legacyErrorBoundariesThatAlreadyFailed.add(instance);
|
15945 | }
|
15946 | }
|
15947 |
|
15948 | function prepareToThrowUncaughtError(error) {
|
15949 | if (!hasUncaughtError) {
|
15950 | hasUncaughtError = true;
|
15951 | firstUncaughtError = error;
|
15952 | }
|
15953 | }
|
15954 |
|
15955 | var onUncaughtError = prepareToThrowUncaughtError;
|
15956 |
|
15957 | function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
|
15958 | var errorInfo = createCapturedValue(error, sourceFiber);
|
15959 | var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
|
15960 | enqueueUpdate(rootFiber, update);
|
15961 | var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
|
15962 |
|
15963 | if (root !== null) {
|
15964 | ensureRootIsScheduled(root);
|
15965 | schedulePendingInteractions(root, Sync);
|
15966 | }
|
15967 | }
|
15968 |
|
15969 | function captureCommitPhaseError(sourceFiber, error) {
|
15970 | if (sourceFiber.tag === HostRoot) {
|
15971 |
|
15972 |
|
15973 | captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
|
15974 | return;
|
15975 | }
|
15976 |
|
15977 | var fiber = sourceFiber.return;
|
15978 |
|
15979 | while (fiber !== null) {
|
15980 | if (fiber.tag === HostRoot) {
|
15981 | captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
|
15982 | return;
|
15983 | } else if (fiber.tag === ClassComponent) {
|
15984 | var ctor = fiber.type;
|
15985 | var instance = fiber.stateNode;
|
15986 |
|
15987 | if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
|
15988 | var errorInfo = createCapturedValue(error, sourceFiber);
|
15989 | var update = createClassErrorUpdate(fiber, errorInfo,
|
15990 | Sync);
|
15991 | enqueueUpdate(fiber, update);
|
15992 | var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
|
15993 |
|
15994 | if (root !== null) {
|
15995 | ensureRootIsScheduled(root);
|
15996 | schedulePendingInteractions(root, Sync);
|
15997 | }
|
15998 |
|
15999 | return;
|
16000 | }
|
16001 | }
|
16002 |
|
16003 | fiber = fiber.return;
|
16004 | }
|
16005 | }
|
16006 | function pingSuspendedRoot(root, thenable, suspendedTime) {
|
16007 | var pingCache = root.pingCache;
|
16008 |
|
16009 | if (pingCache !== null) {
|
16010 |
|
16011 |
|
16012 | pingCache.delete(thenable);
|
16013 | }
|
16014 |
|
16015 | if (workInProgressRoot === root && renderExpirationTime === suspendedTime) {
|
16016 |
|
16017 |
|
16018 |
|
16019 |
|
16020 |
|
16021 |
|
16022 |
|
16023 |
|
16024 |
|
16025 |
|
16026 |
|
16027 | if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
|
16028 |
|
16029 |
|
16030 | prepareFreshStack(root, renderExpirationTime);
|
16031 | } else {
|
16032 |
|
16033 |
|
16034 | workInProgressRootHasPendingPing = true;
|
16035 | }
|
16036 |
|
16037 | return;
|
16038 | }
|
16039 |
|
16040 | if (!isRootSuspendedAtTime(root, suspendedTime)) {
|
16041 |
|
16042 | return;
|
16043 | }
|
16044 |
|
16045 | var lastPingedTime = root.lastPingedTime;
|
16046 |
|
16047 | if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
|
16048 |
|
16049 | return;
|
16050 | }
|
16051 |
|
16052 |
|
16053 | root.lastPingedTime = suspendedTime;
|
16054 |
|
16055 | if (root.finishedExpirationTime === suspendedTime) {
|
16056 |
|
16057 | root.finishedExpirationTime = NoWork;
|
16058 | root.finishedWork = null;
|
16059 | }
|
16060 |
|
16061 | ensureRootIsScheduled(root);
|
16062 | schedulePendingInteractions(root, suspendedTime);
|
16063 | }
|
16064 |
|
16065 | function retryTimedOutBoundary(boundaryFiber, retryTime) {
|
16066 |
|
16067 |
|
16068 |
|
16069 |
|
16070 | if (retryTime === NoWork) {
|
16071 | var suspenseConfig = null;
|
16072 |
|
16073 | var currentTime = requestCurrentTimeForUpdate();
|
16074 | retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
|
16075 | }
|
16076 |
|
16077 |
|
16078 | var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
|
16079 |
|
16080 | if (root !== null) {
|
16081 | ensureRootIsScheduled(root);
|
16082 | schedulePendingInteractions(root, retryTime);
|
16083 | }
|
16084 | }
|
16085 |
|
16086 | function retryDehydratedSuspenseBoundary(boundaryFiber) {
|
16087 | var suspenseState = boundaryFiber.memoizedState;
|
16088 | var retryTime = NoWork;
|
16089 |
|
16090 | if (suspenseState !== null) {
|
16091 | retryTime = suspenseState.retryTime;
|
16092 | }
|
16093 |
|
16094 | retryTimedOutBoundary(boundaryFiber, retryTime);
|
16095 | }
|
16096 | function resolveRetryThenable(boundaryFiber, thenable) {
|
16097 | var retryTime = NoWork;
|
16098 |
|
16099 | var retryCache;
|
16100 |
|
16101 | if (enableSuspenseServerRenderer) {
|
16102 | switch (boundaryFiber.tag) {
|
16103 | case SuspenseComponent:
|
16104 | retryCache = boundaryFiber.stateNode;
|
16105 | var suspenseState = boundaryFiber.memoizedState;
|
16106 |
|
16107 | if (suspenseState !== null) {
|
16108 | retryTime = suspenseState.retryTime;
|
16109 | }
|
16110 |
|
16111 | break;
|
16112 |
|
16113 | case SuspenseListComponent:
|
16114 | retryCache = boundaryFiber.stateNode;
|
16115 | break;
|
16116 |
|
16117 | default:
|
16118 | {
|
16119 | {
|
16120 | throw Error("Pinged unknown suspense boundary type. This is probably a bug in React.");
|
16121 | }
|
16122 | }
|
16123 |
|
16124 | }
|
16125 | } else {
|
16126 | retryCache = boundaryFiber.stateNode;
|
16127 | }
|
16128 |
|
16129 | if (retryCache !== null) {
|
16130 |
|
16131 |
|
16132 | retryCache.delete(thenable);
|
16133 | }
|
16134 |
|
16135 | retryTimedOutBoundary(boundaryFiber, retryTime);
|
16136 | }
|
16137 |
|
16138 |
|
16139 |
|
16140 |
|
16141 |
|
16142 |
|
16143 |
|
16144 |
|
16145 |
|
16146 | function jnd(timeElapsed) {
|
16147 | return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
|
16148 | }
|
16149 |
|
16150 | function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
|
16151 | var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
|
16152 |
|
16153 | if (busyMinDurationMs <= 0) {
|
16154 | return 0;
|
16155 | }
|
16156 |
|
16157 | var busyDelayMs = suspenseConfig.busyDelayMs | 0;
|
16158 |
|
16159 | var currentTimeMs = now();
|
16160 | var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
|
16161 | var timeElapsed = currentTimeMs - eventTimeMs;
|
16162 |
|
16163 | if (timeElapsed <= busyDelayMs) {
|
16164 |
|
16165 |
|
16166 | return 0;
|
16167 | }
|
16168 |
|
16169 | var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed;
|
16170 |
|
16171 | return msUntilTimeout;
|
16172 | }
|
16173 |
|
16174 | function checkForNestedUpdates() {
|
16175 | if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
|
16176 | nestedUpdateCount = 0;
|
16177 | rootWithNestedUpdates = null;
|
16178 |
|
16179 | {
|
16180 | {
|
16181 | throw Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");
|
16182 | }
|
16183 | }
|
16184 | }
|
16185 |
|
16186 | {
|
16187 | if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
|
16188 | nestedPassiveUpdateCount = 0;
|
16189 | warning$1(false, 'Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.');
|
16190 | }
|
16191 | }
|
16192 | }
|
16193 |
|
16194 | function flushRenderPhaseStrictModeWarningsInDEV() {
|
16195 | {
|
16196 | ReactStrictModeWarnings.flushLegacyContextWarning();
|
16197 |
|
16198 | if (warnAboutDeprecatedLifecycles) {
|
16199 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
|
16200 | }
|
16201 | }
|
16202 | }
|
16203 |
|
16204 | function stopFinishedWorkLoopTimer() {
|
16205 | var didCompleteRoot = true;
|
16206 | stopWorkLoopTimer(interruptedBy, didCompleteRoot);
|
16207 | interruptedBy = null;
|
16208 | }
|
16209 |
|
16210 | function stopInterruptedWorkLoopTimer() {
|
16211 |
|
16212 | var didCompleteRoot = false;
|
16213 | stopWorkLoopTimer(interruptedBy, didCompleteRoot);
|
16214 | interruptedBy = null;
|
16215 | }
|
16216 |
|
16217 | function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
|
16218 | if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime) {
|
16219 | interruptedBy = fiberThatReceivedUpdate;
|
16220 | }
|
16221 | }
|
16222 |
|
16223 | var didWarnStateUpdateForUnmountedComponent = null;
|
16224 |
|
16225 | function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
|
16226 | {
|
16227 | var tag = fiber.tag;
|
16228 |
|
16229 | if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
|
16230 |
|
16231 | return;
|
16232 | }
|
16233 |
|
16234 |
|
16235 |
|
16236 | var componentName = getComponentName(fiber.type) || 'ReactComponent';
|
16237 |
|
16238 | if (didWarnStateUpdateForUnmountedComponent !== null) {
|
16239 | if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
|
16240 | return;
|
16241 | }
|
16242 |
|
16243 | didWarnStateUpdateForUnmountedComponent.add(componentName);
|
16244 | } else {
|
16245 | didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
|
16246 | }
|
16247 |
|
16248 | warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
|
16249 | }
|
16250 | }
|
16251 |
|
16252 | var beginWork$$1;
|
16253 |
|
16254 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
16255 | var dummyFiber = null;
|
16256 |
|
16257 | beginWork$$1 = function (current, unitOfWork, expirationTime) {
|
16258 |
|
16259 |
|
16260 |
|
16261 |
|
16262 |
|
16263 | var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
|
16264 |
|
16265 | try {
|
16266 | return beginWork$1(current, unitOfWork, expirationTime);
|
16267 | } catch (originalError) {
|
16268 | if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
|
16269 |
|
16270 | throw originalError;
|
16271 | }
|
16272 |
|
16273 |
|
16274 |
|
16275 | resetContextDependencies();
|
16276 | resetHooks();
|
16277 |
|
16278 |
|
16279 |
|
16280 | unwindInterruptedWork(unitOfWork);
|
16281 |
|
16282 | assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
|
16283 |
|
16284 | if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
|
16285 |
|
16286 | startProfilerTimer(unitOfWork);
|
16287 | }
|
16288 |
|
16289 |
|
16290 | invokeGuardedCallback(null, beginWork$1, null, current, unitOfWork, expirationTime);
|
16291 |
|
16292 | if (hasCaughtError()) {
|
16293 | var replayError = clearCaughtError();
|
16294 |
|
16295 |
|
16296 | throw replayError;
|
16297 | } else {
|
16298 |
|
16299 | throw originalError;
|
16300 | }
|
16301 | }
|
16302 | };
|
16303 | } else {
|
16304 | beginWork$$1 = beginWork$1;
|
16305 | }
|
16306 |
|
16307 | var didWarnAboutUpdateInRender = false;
|
16308 | var didWarnAboutUpdateInGetChildContext = false;
|
16309 |
|
16310 | function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
|
16311 | {
|
16312 | if (fiber.tag === ClassComponent) {
|
16313 | switch (phase) {
|
16314 | case 'getChildContext':
|
16315 | if (didWarnAboutUpdateInGetChildContext) {
|
16316 | return;
|
16317 | }
|
16318 |
|
16319 | warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
|
16320 | didWarnAboutUpdateInGetChildContext = true;
|
16321 | break;
|
16322 |
|
16323 | case 'render':
|
16324 | if (didWarnAboutUpdateInRender) {
|
16325 | return;
|
16326 | }
|
16327 |
|
16328 | warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure function of ' + 'props and state.');
|
16329 | didWarnAboutUpdateInRender = true;
|
16330 | break;
|
16331 | }
|
16332 | }
|
16333 | }
|
16334 | }
|
16335 |
|
16336 |
|
16337 | var IsThisRendererActing = {
|
16338 | current: false
|
16339 | };
|
16340 | function warnIfNotScopedWithMatchingAct(fiber) {
|
16341 | {
|
16342 | if (warnsIfNotActing === true && IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
|
16343 | warningWithoutStack$1(false, "It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber));
|
16344 | }
|
16345 | }
|
16346 | }
|
16347 | function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
|
16348 | {
|
16349 | if (warnsIfNotActing === true && (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
|
16350 | warningWithoutStack$1(false, 'An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
|
16351 | }
|
16352 | }
|
16353 | }
|
16354 |
|
16355 | function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
|
16356 | {
|
16357 | if (warnsIfNotActing === true && executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
|
16358 | warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
|
16359 | }
|
16360 | }
|
16361 | }
|
16362 |
|
16363 | var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV;
|
16364 |
|
16365 | var didWarnAboutUnmockedScheduler = false;
|
16366 |
|
16367 |
|
16368 |
|
16369 |
|
16370 | function warnIfUnmockedScheduler(fiber) {
|
16371 | {
|
16372 | if (didWarnAboutUnmockedScheduler === false && unstable_flushAllWithoutAsserting === undefined) {
|
16373 | if (fiber.mode & BatchedMode || fiber.mode & ConcurrentMode) {
|
16374 | didWarnAboutUnmockedScheduler = true;
|
16375 | warningWithoutStack$1(false, 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
|
16376 | } else if (warnAboutUnmockedScheduler === true) {
|
16377 | didWarnAboutUnmockedScheduler = true;
|
16378 | warningWithoutStack$1(false, 'Starting from React v17, the "scheduler" module will need to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
|
16379 | }
|
16380 | }
|
16381 | }
|
16382 | }
|
16383 | var componentsThatTriggeredHighPriSuspend = null;
|
16384 | function checkForWrongSuspensePriorityInDEV(sourceFiber) {
|
16385 | {
|
16386 | var currentPriorityLevel = getCurrentPriorityLevel();
|
16387 |
|
16388 | if ((sourceFiber.mode & ConcurrentMode) !== NoEffect && (currentPriorityLevel === UserBlockingPriority || currentPriorityLevel === ImmediatePriority)) {
|
16389 | var workInProgressNode = sourceFiber;
|
16390 |
|
16391 | while (workInProgressNode !== null) {
|
16392 |
|
16393 | var current = workInProgressNode.alternate;
|
16394 |
|
16395 | if (current !== null) {
|
16396 |
|
16397 |
|
16398 | switch (workInProgressNode.tag) {
|
16399 | case ClassComponent:
|
16400 |
|
16401 |
|
16402 | var updateQueue = current.updateQueue;
|
16403 |
|
16404 | if (updateQueue !== null) {
|
16405 | var update = updateQueue.firstUpdate;
|
16406 |
|
16407 | while (update !== null) {
|
16408 | var priorityLevel = update.priority;
|
16409 |
|
16410 | if (priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority) {
|
16411 | if (componentsThatTriggeredHighPriSuspend === null) {
|
16412 | componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
|
16413 | } else {
|
16414 | componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
|
16415 | }
|
16416 |
|
16417 | break;
|
16418 | }
|
16419 |
|
16420 | update = update.next;
|
16421 | }
|
16422 | }
|
16423 |
|
16424 | break;
|
16425 |
|
16426 | case FunctionComponent:
|
16427 | case ForwardRef:
|
16428 | case SimpleMemoComponent:
|
16429 | if (workInProgressNode.memoizedState !== null && workInProgressNode.memoizedState.baseUpdate !== null) {
|
16430 | var _update = workInProgressNode.memoizedState.baseUpdate;
|
16431 |
|
16432 |
|
16433 | while (_update !== null) {
|
16434 | var priority = _update.priority;
|
16435 |
|
16436 | if (priority === UserBlockingPriority || priority === ImmediatePriority) {
|
16437 | if (componentsThatTriggeredHighPriSuspend === null) {
|
16438 | componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
|
16439 | } else {
|
16440 | componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
|
16441 | }
|
16442 |
|
16443 | break;
|
16444 | }
|
16445 |
|
16446 | if (_update.next === workInProgressNode.memoizedState.baseUpdate) {
|
16447 | break;
|
16448 | }
|
16449 |
|
16450 | _update = _update.next;
|
16451 | }
|
16452 | }
|
16453 |
|
16454 | break;
|
16455 |
|
16456 | default:
|
16457 | break;
|
16458 | }
|
16459 | }
|
16460 |
|
16461 | workInProgressNode = workInProgressNode.return;
|
16462 | }
|
16463 | }
|
16464 | }
|
16465 | }
|
16466 |
|
16467 | function flushSuspensePriorityWarningInDEV() {
|
16468 | {
|
16469 | if (componentsThatTriggeredHighPriSuspend !== null) {
|
16470 | var componentNames = [];
|
16471 | componentsThatTriggeredHighPriSuspend.forEach(function (name) {
|
16472 | return componentNames.push(name);
|
16473 | });
|
16474 | componentsThatTriggeredHighPriSuspend = null;
|
16475 |
|
16476 | if (componentNames.length > 0) {
|
16477 | warningWithoutStack$1(false, '%s triggered a user-blocking update that suspended.' + '\n\n' + 'The fix is to split the update into multiple parts: a user-blocking ' + 'update to provide immediate feedback, and another update that ' + 'triggers the bulk of the changes.' + '\n\n' + 'Refer to the documentation for useTransition to learn how ' + 'to implement this pattern.',
|
16478 | componentNames.sort().join(', '));
|
16479 | }
|
16480 | }
|
16481 | }
|
16482 | }
|
16483 |
|
16484 | function computeThreadID(root, expirationTime) {
|
16485 |
|
16486 | return expirationTime * 1000 + root.interactionThreadID;
|
16487 | }
|
16488 |
|
16489 | function markSpawnedWork(expirationTime) {
|
16490 | if (!enableSchedulerTracing) {
|
16491 | return;
|
16492 | }
|
16493 |
|
16494 | if (spawnedWorkDuringRender === null) {
|
16495 | spawnedWorkDuringRender = [expirationTime];
|
16496 | } else {
|
16497 | spawnedWorkDuringRender.push(expirationTime);
|
16498 | }
|
16499 | }
|
16500 |
|
16501 | function scheduleInteractions(root, expirationTime, interactions) {
|
16502 | if (!enableSchedulerTracing) {
|
16503 | return;
|
16504 | }
|
16505 |
|
16506 | if (interactions.size > 0) {
|
16507 | var pendingInteractionMap = root.pendingInteractionMap;
|
16508 | var pendingInteractions = pendingInteractionMap.get(expirationTime);
|
16509 |
|
16510 | if (pendingInteractions != null) {
|
16511 | interactions.forEach(function (interaction) {
|
16512 | if (!pendingInteractions.has(interaction)) {
|
16513 |
|
16514 | interaction.__count++;
|
16515 | }
|
16516 |
|
16517 | pendingInteractions.add(interaction);
|
16518 | });
|
16519 | } else {
|
16520 | pendingInteractionMap.set(expirationTime, new Set(interactions));
|
16521 |
|
16522 | interactions.forEach(function (interaction) {
|
16523 | interaction.__count++;
|
16524 | });
|
16525 | }
|
16526 |
|
16527 | var subscriber = __subscriberRef.current;
|
16528 |
|
16529 | if (subscriber !== null) {
|
16530 | var threadID = computeThreadID(root, expirationTime);
|
16531 | subscriber.onWorkScheduled(interactions, threadID);
|
16532 | }
|
16533 | }
|
16534 | }
|
16535 |
|
16536 | function schedulePendingInteractions(root, expirationTime) {
|
16537 |
|
16538 |
|
16539 |
|
16540 | if (!enableSchedulerTracing) {
|
16541 | return;
|
16542 | }
|
16543 |
|
16544 | scheduleInteractions(root, expirationTime, __interactionsRef.current);
|
16545 | }
|
16546 |
|
16547 | function startWorkOnPendingInteractions(root, expirationTime) {
|
16548 |
|
16549 | if (!enableSchedulerTracing) {
|
16550 | return;
|
16551 | }
|
16552 |
|
16553 |
|
16554 |
|
16555 |
|
16556 | var interactions = new Set();
|
16557 | root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
|
16558 | if (scheduledExpirationTime >= expirationTime) {
|
16559 | scheduledInteractions.forEach(function (interaction) {
|
16560 | return interactions.add(interaction);
|
16561 | });
|
16562 | }
|
16563 | });
|
16564 |
|
16565 |
|
16566 |
|
16567 |
|
16568 |
|
16569 | root.memoizedInteractions = interactions;
|
16570 |
|
16571 | if (interactions.size > 0) {
|
16572 | var subscriber = __subscriberRef.current;
|
16573 |
|
16574 | if (subscriber !== null) {
|
16575 | var threadID = computeThreadID(root, expirationTime);
|
16576 |
|
16577 | try {
|
16578 | subscriber.onWorkStarted(interactions, threadID);
|
16579 | } catch (error) {
|
16580 |
|
16581 | scheduleCallback(ImmediatePriority, function () {
|
16582 | throw error;
|
16583 | });
|
16584 | }
|
16585 | }
|
16586 | }
|
16587 | }
|
16588 |
|
16589 | function finishPendingInteractions(root, committedExpirationTime) {
|
16590 | if (!enableSchedulerTracing) {
|
16591 | return;
|
16592 | }
|
16593 |
|
16594 | var earliestRemainingTimeAfterCommit = root.firstPendingTime;
|
16595 | var subscriber;
|
16596 |
|
16597 | try {
|
16598 | subscriber = __subscriberRef.current;
|
16599 |
|
16600 | if (subscriber !== null && root.memoizedInteractions.size > 0) {
|
16601 | var threadID = computeThreadID(root, committedExpirationTime);
|
16602 | subscriber.onWorkStopped(root.memoizedInteractions, threadID);
|
16603 | }
|
16604 | } catch (error) {
|
16605 |
|
16606 | scheduleCallback(ImmediatePriority, function () {
|
16607 | throw error;
|
16608 | });
|
16609 | } finally {
|
16610 |
|
16611 |
|
16612 |
|
16613 | var pendingInteractionMap = root.pendingInteractionMap;
|
16614 | pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
|
16615 |
|
16616 |
|
16617 |
|
16618 | if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
|
16619 | pendingInteractionMap.delete(scheduledExpirationTime);
|
16620 | scheduledInteractions.forEach(function (interaction) {
|
16621 | interaction.__count--;
|
16622 |
|
16623 | if (subscriber !== null && interaction.__count === 0) {
|
16624 | try {
|
16625 | subscriber.onInteractionScheduledWorkCompleted(interaction);
|
16626 | } catch (error) {
|
16627 |
|
16628 | scheduleCallback(ImmediatePriority, function () {
|
16629 | throw error;
|
16630 | });
|
16631 | }
|
16632 | }
|
16633 | });
|
16634 | }
|
16635 | });
|
16636 | }
|
16637 | }
|
16638 |
|
16639 | var onCommitFiberRoot = null;
|
16640 | var onCommitFiberUnmount = null;
|
16641 | var hasLoggedError = false;
|
16642 | var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
|
16643 | function injectInternals(internals) {
|
16644 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
|
16645 |
|
16646 | return false;
|
16647 | }
|
16648 |
|
16649 | var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
16650 |
|
16651 | if (hook.isDisabled) {
|
16652 |
|
16653 |
|
16654 |
|
16655 | return true;
|
16656 | }
|
16657 |
|
16658 | if (!hook.supportsFiber) {
|
16659 | {
|
16660 | warningWithoutStack$1(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
|
16661 | }
|
16662 |
|
16663 |
|
16664 | return true;
|
16665 | }
|
16666 |
|
16667 | try {
|
16668 | var rendererID = hook.inject(internals);
|
16669 |
|
16670 | onCommitFiberRoot = function (root, expirationTime) {
|
16671 | try {
|
16672 | var didError = (root.current.effectTag & DidCapture) === DidCapture;
|
16673 |
|
16674 | if (enableProfilerTimer) {
|
16675 | var currentTime = getCurrentTime();
|
16676 | var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
|
16677 | hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
|
16678 | } else {
|
16679 | hook.onCommitFiberRoot(rendererID, root, undefined, didError);
|
16680 | }
|
16681 | } catch (err) {
|
16682 | if (true && !hasLoggedError) {
|
16683 | hasLoggedError = true;
|
16684 | warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
|
16685 | }
|
16686 | }
|
16687 | };
|
16688 |
|
16689 | onCommitFiberUnmount = function (fiber) {
|
16690 | try {
|
16691 | hook.onCommitFiberUnmount(rendererID, fiber);
|
16692 | } catch (err) {
|
16693 | if (true && !hasLoggedError) {
|
16694 | hasLoggedError = true;
|
16695 | warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
|
16696 | }
|
16697 | }
|
16698 | };
|
16699 | } catch (err) {
|
16700 |
|
16701 | {
|
16702 | warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
|
16703 | }
|
16704 | }
|
16705 |
|
16706 |
|
16707 | return true;
|
16708 | }
|
16709 | function onCommitRoot(root, expirationTime) {
|
16710 | if (typeof onCommitFiberRoot === 'function') {
|
16711 | onCommitFiberRoot(root, expirationTime);
|
16712 | }
|
16713 | }
|
16714 | function onCommitUnmount(fiber) {
|
16715 | if (typeof onCommitFiberUnmount === 'function') {
|
16716 | onCommitFiberUnmount(fiber);
|
16717 | }
|
16718 | }
|
16719 |
|
16720 | var hasBadMapPolyfill;
|
16721 |
|
16722 | {
|
16723 | hasBadMapPolyfill = false;
|
16724 |
|
16725 | try {
|
16726 | var nonExtensibleObject = Object.preventExtensions({});
|
16727 | var testMap = new Map([[nonExtensibleObject, null]]);
|
16728 | var testSet = new Set([nonExtensibleObject]);
|
16729 |
|
16730 |
|
16731 |
|
16732 | testMap.set(0, 0);
|
16733 | testSet.add(0);
|
16734 | } catch (e) {
|
16735 |
|
16736 | hasBadMapPolyfill = true;
|
16737 | }
|
16738 | }
|
16739 |
|
16740 | var debugCounter = 1;
|
16741 |
|
16742 | function FiberNode(tag, pendingProps, key, mode) {
|
16743 |
|
16744 | this.tag = tag;
|
16745 | this.key = key;
|
16746 | this.elementType = null;
|
16747 | this.type = null;
|
16748 | this.stateNode = null;
|
16749 |
|
16750 | this.return = null;
|
16751 | this.child = null;
|
16752 | this.sibling = null;
|
16753 | this.index = 0;
|
16754 | this.ref = null;
|
16755 | this.pendingProps = pendingProps;
|
16756 | this.memoizedProps = null;
|
16757 | this.updateQueue = null;
|
16758 | this.memoizedState = null;
|
16759 | this.dependencies = null;
|
16760 | this.mode = mode;
|
16761 |
|
16762 | this.effectTag = NoEffect;
|
16763 | this.nextEffect = null;
|
16764 | this.firstEffect = null;
|
16765 | this.lastEffect = null;
|
16766 | this.expirationTime = NoWork;
|
16767 | this.childExpirationTime = NoWork;
|
16768 | this.alternate = null;
|
16769 |
|
16770 | if (enableProfilerTimer) {
|
16771 |
|
16772 |
|
16773 |
|
16774 |
|
16775 |
|
16776 |
|
16777 |
|
16778 |
|
16779 |
|
16780 |
|
16781 |
|
16782 |
|
16783 | this.actualDuration = Number.NaN;
|
16784 | this.actualStartTime = Number.NaN;
|
16785 | this.selfBaseDuration = Number.NaN;
|
16786 | this.treeBaseDuration = Number.NaN;
|
16787 |
|
16788 |
|
16789 |
|
16790 | this.actualDuration = 0;
|
16791 | this.actualStartTime = -1;
|
16792 | this.selfBaseDuration = 0;
|
16793 | this.treeBaseDuration = 0;
|
16794 | }
|
16795 |
|
16796 |
|
16797 |
|
16798 | if (enableUserTimingAPI) {
|
16799 | this._debugID = debugCounter++;
|
16800 | this._debugIsCurrentlyTiming = false;
|
16801 | }
|
16802 |
|
16803 | {
|
16804 | this._debugSource = null;
|
16805 | this._debugOwner = null;
|
16806 | this._debugNeedsRemount = false;
|
16807 | this._debugHookTypes = null;
|
16808 |
|
16809 | if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
|
16810 | Object.preventExtensions(this);
|
16811 | }
|
16812 | }
|
16813 | }
|
16814 |
|
16815 |
|
16816 |
|
16817 |
|
16818 |
|
16819 |
|
16820 |
|
16821 |
|
16822 |
|
16823 |
|
16824 |
|
16825 |
|
16826 |
|
16827 |
|
16828 | var createFiber = function (tag, pendingProps, key, mode) {
|
16829 |
|
16830 | return new FiberNode(tag, pendingProps, key, mode);
|
16831 | };
|
16832 |
|
16833 | function shouldConstruct(Component) {
|
16834 | var prototype = Component.prototype;
|
16835 | return !!(prototype && prototype.isReactComponent);
|
16836 | }
|
16837 |
|
16838 | function isSimpleFunctionComponent(type) {
|
16839 | return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
|
16840 | }
|
16841 | function resolveLazyComponentTag(Component) {
|
16842 | if (typeof Component === 'function') {
|
16843 | return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
|
16844 | } else if (Component !== undefined && Component !== null) {
|
16845 | var $$typeof = Component.$$typeof;
|
16846 |
|
16847 | if ($$typeof === REACT_FORWARD_REF_TYPE) {
|
16848 | return ForwardRef;
|
16849 | }
|
16850 |
|
16851 | if ($$typeof === REACT_MEMO_TYPE) {
|
16852 | return MemoComponent;
|
16853 | }
|
16854 | }
|
16855 |
|
16856 | return IndeterminateComponent;
|
16857 | }
|
16858 |
|
16859 | function createWorkInProgress(current, pendingProps, expirationTime) {
|
16860 | var workInProgress = current.alternate;
|
16861 |
|
16862 | if (workInProgress === null) {
|
16863 |
|
16864 |
|
16865 |
|
16866 |
|
16867 |
|
16868 | workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
|
16869 | workInProgress.elementType = current.elementType;
|
16870 | workInProgress.type = current.type;
|
16871 | workInProgress.stateNode = current.stateNode;
|
16872 |
|
16873 | {
|
16874 |
|
16875 | workInProgress._debugID = current._debugID;
|
16876 | workInProgress._debugSource = current._debugSource;
|
16877 | workInProgress._debugOwner = current._debugOwner;
|
16878 | workInProgress._debugHookTypes = current._debugHookTypes;
|
16879 | }
|
16880 |
|
16881 | workInProgress.alternate = current;
|
16882 | current.alternate = workInProgress;
|
16883 | } else {
|
16884 | workInProgress.pendingProps = pendingProps;
|
16885 |
|
16886 |
|
16887 | workInProgress.effectTag = NoEffect;
|
16888 |
|
16889 | workInProgress.nextEffect = null;
|
16890 | workInProgress.firstEffect = null;
|
16891 | workInProgress.lastEffect = null;
|
16892 |
|
16893 | if (enableProfilerTimer) {
|
16894 |
|
16895 |
|
16896 |
|
16897 |
|
16898 | workInProgress.actualDuration = 0;
|
16899 | workInProgress.actualStartTime = -1;
|
16900 | }
|
16901 | }
|
16902 |
|
16903 | workInProgress.childExpirationTime = current.childExpirationTime;
|
16904 | workInProgress.expirationTime = current.expirationTime;
|
16905 | workInProgress.child = current.child;
|
16906 | workInProgress.memoizedProps = current.memoizedProps;
|
16907 | workInProgress.memoizedState = current.memoizedState;
|
16908 | workInProgress.updateQueue = current.updateQueue;
|
16909 |
|
16910 |
|
16911 | var currentDependencies = current.dependencies;
|
16912 | workInProgress.dependencies = currentDependencies === null ? null : {
|
16913 | expirationTime: currentDependencies.expirationTime,
|
16914 | firstContext: currentDependencies.firstContext,
|
16915 | responders: currentDependencies.responders
|
16916 | };
|
16917 |
|
16918 | workInProgress.sibling = current.sibling;
|
16919 | workInProgress.index = current.index;
|
16920 | workInProgress.ref = current.ref;
|
16921 |
|
16922 | if (enableProfilerTimer) {
|
16923 | workInProgress.selfBaseDuration = current.selfBaseDuration;
|
16924 | workInProgress.treeBaseDuration = current.treeBaseDuration;
|
16925 | }
|
16926 |
|
16927 | {
|
16928 | workInProgress._debugNeedsRemount = current._debugNeedsRemount;
|
16929 |
|
16930 | switch (workInProgress.tag) {
|
16931 | case IndeterminateComponent:
|
16932 | case FunctionComponent:
|
16933 | case SimpleMemoComponent:
|
16934 | workInProgress.type = resolveFunctionForHotReloading(current.type);
|
16935 | break;
|
16936 |
|
16937 | case ClassComponent:
|
16938 | workInProgress.type = resolveClassForHotReloading(current.type);
|
16939 | break;
|
16940 |
|
16941 | case ForwardRef:
|
16942 | workInProgress.type = resolveForwardRefForHotReloading(current.type);
|
16943 | break;
|
16944 |
|
16945 | default:
|
16946 | break;
|
16947 | }
|
16948 | }
|
16949 |
|
16950 | return workInProgress;
|
16951 | }
|
16952 |
|
16953 | function resetWorkInProgress(workInProgress, renderExpirationTime) {
|
16954 |
|
16955 |
|
16956 |
|
16957 |
|
16958 |
|
16959 |
|
16960 |
|
16961 |
|
16962 | workInProgress.effectTag &= Placement;
|
16963 |
|
16964 | workInProgress.nextEffect = null;
|
16965 | workInProgress.firstEffect = null;
|
16966 | workInProgress.lastEffect = null;
|
16967 | var current = workInProgress.alternate;
|
16968 |
|
16969 | if (current === null) {
|
16970 |
|
16971 | workInProgress.childExpirationTime = NoWork;
|
16972 | workInProgress.expirationTime = renderExpirationTime;
|
16973 | workInProgress.child = null;
|
16974 | workInProgress.memoizedProps = null;
|
16975 | workInProgress.memoizedState = null;
|
16976 | workInProgress.updateQueue = null;
|
16977 | workInProgress.dependencies = null;
|
16978 |
|
16979 | if (enableProfilerTimer) {
|
16980 |
|
16981 |
|
16982 | workInProgress.selfBaseDuration = 0;
|
16983 | workInProgress.treeBaseDuration = 0;
|
16984 | }
|
16985 | } else {
|
16986 |
|
16987 | workInProgress.childExpirationTime = current.childExpirationTime;
|
16988 | workInProgress.expirationTime = current.expirationTime;
|
16989 | workInProgress.child = current.child;
|
16990 | workInProgress.memoizedProps = current.memoizedProps;
|
16991 | workInProgress.memoizedState = current.memoizedState;
|
16992 | workInProgress.updateQueue = current.updateQueue;
|
16993 |
|
16994 |
|
16995 | var currentDependencies = current.dependencies;
|
16996 | workInProgress.dependencies = currentDependencies === null ? null : {
|
16997 | expirationTime: currentDependencies.expirationTime,
|
16998 | firstContext: currentDependencies.firstContext,
|
16999 | responders: currentDependencies.responders
|
17000 | };
|
17001 |
|
17002 | if (enableProfilerTimer) {
|
17003 |
|
17004 |
|
17005 | workInProgress.selfBaseDuration = current.selfBaseDuration;
|
17006 | workInProgress.treeBaseDuration = current.treeBaseDuration;
|
17007 | }
|
17008 | }
|
17009 |
|
17010 | return workInProgress;
|
17011 | }
|
17012 | function createHostRootFiber(tag) {
|
17013 | var mode;
|
17014 |
|
17015 | if (tag === ConcurrentRoot) {
|
17016 | mode = ConcurrentMode | BatchedMode | StrictMode;
|
17017 | } else if (tag === BatchedRoot) {
|
17018 | mode = BatchedMode | StrictMode;
|
17019 | } else {
|
17020 | mode = NoMode;
|
17021 | }
|
17022 |
|
17023 | if (enableProfilerTimer && isDevToolsPresent) {
|
17024 |
|
17025 |
|
17026 |
|
17027 | mode |= ProfileMode;
|
17028 | }
|
17029 |
|
17030 | return createFiber(HostRoot, null, null, mode);
|
17031 | }
|
17032 | function createFiberFromTypeAndProps(type, // React$ElementType
|
17033 | key, pendingProps, owner, mode, expirationTime) {
|
17034 | var fiber;
|
17035 | var fiberTag = IndeterminateComponent;
|
17036 |
|
17037 | var resolvedType = type;
|
17038 |
|
17039 | if (typeof type === 'function') {
|
17040 | if (shouldConstruct(type)) {
|
17041 | fiberTag = ClassComponent;
|
17042 |
|
17043 | {
|
17044 | resolvedType = resolveClassForHotReloading(resolvedType);
|
17045 | }
|
17046 | } else {
|
17047 | {
|
17048 | resolvedType = resolveFunctionForHotReloading(resolvedType);
|
17049 | }
|
17050 | }
|
17051 | } else if (typeof type === 'string') {
|
17052 | fiberTag = HostComponent;
|
17053 | } else {
|
17054 | getTag: switch (type) {
|
17055 | case REACT_FRAGMENT_TYPE:
|
17056 | return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
|
17057 |
|
17058 | case REACT_CONCURRENT_MODE_TYPE:
|
17059 | fiberTag = Mode;
|
17060 | mode |= ConcurrentMode | BatchedMode | StrictMode;
|
17061 | break;
|
17062 |
|
17063 | case REACT_STRICT_MODE_TYPE:
|
17064 | fiberTag = Mode;
|
17065 | mode |= StrictMode;
|
17066 | break;
|
17067 |
|
17068 | case REACT_PROFILER_TYPE:
|
17069 | return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
|
17070 |
|
17071 | case REACT_SUSPENSE_TYPE:
|
17072 | return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
|
17073 |
|
17074 | case REACT_SUSPENSE_LIST_TYPE:
|
17075 | return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
|
17076 |
|
17077 | default:
|
17078 | {
|
17079 | if (typeof type === 'object' && type !== null) {
|
17080 | switch (type.$$typeof) {
|
17081 | case REACT_PROVIDER_TYPE:
|
17082 | fiberTag = ContextProvider;
|
17083 | break getTag;
|
17084 |
|
17085 | case REACT_CONTEXT_TYPE:
|
17086 |
|
17087 | fiberTag = ContextConsumer;
|
17088 | break getTag;
|
17089 |
|
17090 | case REACT_FORWARD_REF_TYPE:
|
17091 | fiberTag = ForwardRef;
|
17092 |
|
17093 | {
|
17094 | resolvedType = resolveForwardRefForHotReloading(resolvedType);
|
17095 | }
|
17096 |
|
17097 | break getTag;
|
17098 |
|
17099 | case REACT_MEMO_TYPE:
|
17100 | fiberTag = MemoComponent;
|
17101 | break getTag;
|
17102 |
|
17103 | case REACT_LAZY_TYPE:
|
17104 | fiberTag = LazyComponent;
|
17105 | resolvedType = null;
|
17106 | break getTag;
|
17107 |
|
17108 | case REACT_FUNDAMENTAL_TYPE:
|
17109 | if (enableFundamentalAPI) {
|
17110 | return createFiberFromFundamental(type, pendingProps, mode, expirationTime, key);
|
17111 | }
|
17112 |
|
17113 | break;
|
17114 |
|
17115 | case REACT_SCOPE_TYPE:
|
17116 | if (enableScopeAPI) {
|
17117 | return createFiberFromScope(type, pendingProps, mode, expirationTime, key);
|
17118 | }
|
17119 |
|
17120 | }
|
17121 | }
|
17122 |
|
17123 | var info = '';
|
17124 |
|
17125 | {
|
17126 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
17127 | 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.';
|
17128 | }
|
17129 |
|
17130 | var ownerName = owner ? getComponentName(owner.type) : null;
|
17131 |
|
17132 | if (ownerName) {
|
17133 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
17134 | }
|
17135 | }
|
17136 |
|
17137 | {
|
17138 | {
|
17139 | throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info);
|
17140 | }
|
17141 | }
|
17142 | }
|
17143 | }
|
17144 | }
|
17145 |
|
17146 | fiber = createFiber(fiberTag, pendingProps, key, mode);
|
17147 | fiber.elementType = type;
|
17148 | fiber.type = resolvedType;
|
17149 | fiber.expirationTime = expirationTime;
|
17150 | return fiber;
|
17151 | }
|
17152 | function createFiberFromElement(element, mode, expirationTime) {
|
17153 | var owner = null;
|
17154 |
|
17155 | {
|
17156 | owner = element._owner;
|
17157 | }
|
17158 |
|
17159 | var type = element.type;
|
17160 | var key = element.key;
|
17161 | var pendingProps = element.props;
|
17162 | var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
|
17163 |
|
17164 | {
|
17165 | fiber._debugSource = element._source;
|
17166 | fiber._debugOwner = element._owner;
|
17167 | }
|
17168 |
|
17169 | return fiber;
|
17170 | }
|
17171 | function createFiberFromFragment(elements, mode, expirationTime, key) {
|
17172 | var fiber = createFiber(Fragment, elements, key, mode);
|
17173 | fiber.expirationTime = expirationTime;
|
17174 | return fiber;
|
17175 | }
|
17176 | function createFiberFromFundamental(fundamentalComponent, pendingProps, mode, expirationTime, key) {
|
17177 | var fiber = createFiber(FundamentalComponent, pendingProps, key, mode);
|
17178 | fiber.elementType = fundamentalComponent;
|
17179 | fiber.type = fundamentalComponent;
|
17180 | fiber.expirationTime = expirationTime;
|
17181 | return fiber;
|
17182 | }
|
17183 |
|
17184 | function createFiberFromScope(scope, pendingProps, mode, expirationTime, key) {
|
17185 | var fiber = createFiber(ScopeComponent, pendingProps, key, mode);
|
17186 | fiber.type = scope;
|
17187 | fiber.elementType = scope;
|
17188 | fiber.expirationTime = expirationTime;
|
17189 | return fiber;
|
17190 | }
|
17191 |
|
17192 | function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
|
17193 | {
|
17194 | if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
|
17195 | warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
|
17196 | }
|
17197 | }
|
17198 |
|
17199 | var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
17200 |
|
17201 | fiber.elementType = REACT_PROFILER_TYPE;
|
17202 | fiber.type = REACT_PROFILER_TYPE;
|
17203 | fiber.expirationTime = expirationTime;
|
17204 | return fiber;
|
17205 | }
|
17206 |
|
17207 | function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
|
17208 | var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
|
17209 |
|
17210 |
|
17211 |
|
17212 | fiber.type = REACT_SUSPENSE_TYPE;
|
17213 | fiber.elementType = REACT_SUSPENSE_TYPE;
|
17214 | fiber.expirationTime = expirationTime;
|
17215 | return fiber;
|
17216 | }
|
17217 | function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
|
17218 | var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
|
17219 |
|
17220 | {
|
17221 |
|
17222 |
|
17223 |
|
17224 | fiber.type = REACT_SUSPENSE_LIST_TYPE;
|
17225 | }
|
17226 |
|
17227 | fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
|
17228 | fiber.expirationTime = expirationTime;
|
17229 | return fiber;
|
17230 | }
|
17231 | function createFiberFromText(content, mode, expirationTime) {
|
17232 | var fiber = createFiber(HostText, content, null, mode);
|
17233 | fiber.expirationTime = expirationTime;
|
17234 | return fiber;
|
17235 | }
|
17236 | function createFiberFromHostInstanceForDeletion() {
|
17237 | var fiber = createFiber(HostComponent, null, null, NoMode);
|
17238 |
|
17239 | fiber.elementType = 'DELETED';
|
17240 | fiber.type = 'DELETED';
|
17241 | return fiber;
|
17242 | }
|
17243 | function createFiberFromDehydratedFragment(dehydratedNode) {
|
17244 | var fiber = createFiber(DehydratedFragment, null, null, NoMode);
|
17245 | fiber.stateNode = dehydratedNode;
|
17246 | return fiber;
|
17247 | }
|
17248 | function createFiberFromPortal(portal, mode, expirationTime) {
|
17249 | var pendingProps = portal.children !== null ? portal.children : [];
|
17250 | var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
|
17251 | fiber.expirationTime = expirationTime;
|
17252 | fiber.stateNode = {
|
17253 | containerInfo: portal.containerInfo,
|
17254 | pendingChildren: null,
|
17255 |
|
17256 | implementation: portal.implementation
|
17257 | };
|
17258 | return fiber;
|
17259 | }
|
17260 |
|
17261 | function assignFiberPropertiesInDEV(target, source) {
|
17262 | if (target === null) {
|
17263 |
|
17264 |
|
17265 | target = createFiber(IndeterminateComponent, null, null, NoMode);
|
17266 | }
|
17267 |
|
17268 |
|
17269 |
|
17270 |
|
17271 |
|
17272 |
|
17273 | target.tag = source.tag;
|
17274 | target.key = source.key;
|
17275 | target.elementType = source.elementType;
|
17276 | target.type = source.type;
|
17277 | target.stateNode = source.stateNode;
|
17278 | target.return = source.return;
|
17279 | target.child = source.child;
|
17280 | target.sibling = source.sibling;
|
17281 | target.index = source.index;
|
17282 | target.ref = source.ref;
|
17283 | target.pendingProps = source.pendingProps;
|
17284 | target.memoizedProps = source.memoizedProps;
|
17285 | target.updateQueue = source.updateQueue;
|
17286 | target.memoizedState = source.memoizedState;
|
17287 | target.dependencies = source.dependencies;
|
17288 | target.mode = source.mode;
|
17289 | target.effectTag = source.effectTag;
|
17290 | target.nextEffect = source.nextEffect;
|
17291 | target.firstEffect = source.firstEffect;
|
17292 | target.lastEffect = source.lastEffect;
|
17293 | target.expirationTime = source.expirationTime;
|
17294 | target.childExpirationTime = source.childExpirationTime;
|
17295 | target.alternate = source.alternate;
|
17296 |
|
17297 | if (enableProfilerTimer) {
|
17298 | target.actualDuration = source.actualDuration;
|
17299 | target.actualStartTime = source.actualStartTime;
|
17300 | target.selfBaseDuration = source.selfBaseDuration;
|
17301 | target.treeBaseDuration = source.treeBaseDuration;
|
17302 | }
|
17303 |
|
17304 | target._debugID = source._debugID;
|
17305 | target._debugSource = source._debugSource;
|
17306 | target._debugOwner = source._debugOwner;
|
17307 | target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
|
17308 | target._debugNeedsRemount = source._debugNeedsRemount;
|
17309 | target._debugHookTypes = source._debugHookTypes;
|
17310 | return target;
|
17311 | }
|
17312 |
|
17313 | function FiberRootNode(containerInfo, tag, hydrate) {
|
17314 | this.tag = tag;
|
17315 | this.current = null;
|
17316 | this.containerInfo = containerInfo;
|
17317 | this.pendingChildren = null;
|
17318 | this.pingCache = null;
|
17319 | this.finishedExpirationTime = NoWork;
|
17320 | this.finishedWork = null;
|
17321 | this.timeoutHandle = noTimeout;
|
17322 | this.context = null;
|
17323 | this.pendingContext = null;
|
17324 | this.hydrate = hydrate;
|
17325 | this.callbackNode = null;
|
17326 | this.callbackPriority = NoPriority;
|
17327 | this.firstPendingTime = NoWork;
|
17328 | this.firstSuspendedTime = NoWork;
|
17329 | this.lastSuspendedTime = NoWork;
|
17330 | this.nextKnownPendingLevel = NoWork;
|
17331 | this.lastPingedTime = NoWork;
|
17332 | this.lastExpiredTime = NoWork;
|
17333 |
|
17334 | if (enableSchedulerTracing) {
|
17335 | this.interactionThreadID = unstable_getThreadID();
|
17336 | this.memoizedInteractions = new Set();
|
17337 | this.pendingInteractionMap = new Map();
|
17338 | }
|
17339 |
|
17340 | if (enableSuspenseCallback) {
|
17341 | this.hydrationCallbacks = null;
|
17342 | }
|
17343 | }
|
17344 |
|
17345 | function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
|
17346 | var root = new FiberRootNode(containerInfo, tag, hydrate);
|
17347 |
|
17348 | if (enableSuspenseCallback) {
|
17349 | root.hydrationCallbacks = hydrationCallbacks;
|
17350 | }
|
17351 |
|
17352 |
|
17353 |
|
17354 | var uninitializedFiber = createHostRootFiber(tag);
|
17355 | root.current = uninitializedFiber;
|
17356 | uninitializedFiber.stateNode = root;
|
17357 | return root;
|
17358 | }
|
17359 | function isRootSuspendedAtTime(root, expirationTime) {
|
17360 | var firstSuspendedTime = root.firstSuspendedTime;
|
17361 | var lastSuspendedTime = root.lastSuspendedTime;
|
17362 | return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime;
|
17363 | }
|
17364 | function markRootSuspendedAtTime(root, expirationTime) {
|
17365 | var firstSuspendedTime = root.firstSuspendedTime;
|
17366 | var lastSuspendedTime = root.lastSuspendedTime;
|
17367 |
|
17368 | if (firstSuspendedTime < expirationTime) {
|
17369 | root.firstSuspendedTime = expirationTime;
|
17370 | }
|
17371 |
|
17372 | if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
|
17373 | root.lastSuspendedTime = expirationTime;
|
17374 | }
|
17375 |
|
17376 | if (expirationTime <= root.lastPingedTime) {
|
17377 | root.lastPingedTime = NoWork;
|
17378 | }
|
17379 |
|
17380 | if (expirationTime <= root.lastExpiredTime) {
|
17381 | root.lastExpiredTime = NoWork;
|
17382 | }
|
17383 | }
|
17384 | function markRootUpdatedAtTime(root, expirationTime) {
|
17385 |
|
17386 | var firstPendingTime = root.firstPendingTime;
|
17387 |
|
17388 | if (expirationTime > firstPendingTime) {
|
17389 | root.firstPendingTime = expirationTime;
|
17390 | }
|
17391 |
|
17392 |
|
17393 |
|
17394 | var firstSuspendedTime = root.firstSuspendedTime;
|
17395 |
|
17396 | if (firstSuspendedTime !== NoWork) {
|
17397 | if (expirationTime >= firstSuspendedTime) {
|
17398 |
|
17399 | root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
|
17400 | } else if (expirationTime >= root.lastSuspendedTime) {
|
17401 | root.lastSuspendedTime = expirationTime + 1;
|
17402 | }
|
17403 |
|
17404 |
|
17405 |
|
17406 | if (expirationTime > root.nextKnownPendingLevel) {
|
17407 | root.nextKnownPendingLevel = expirationTime;
|
17408 | }
|
17409 | }
|
17410 | }
|
17411 | function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) {
|
17412 |
|
17413 | root.firstPendingTime = remainingExpirationTime;
|
17414 |
|
17415 |
|
17416 | if (finishedExpirationTime <= root.lastSuspendedTime) {
|
17417 |
|
17418 | root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
|
17419 | } else if (finishedExpirationTime <= root.firstSuspendedTime) {
|
17420 |
|
17421 |
|
17422 |
|
17423 | root.firstSuspendedTime = finishedExpirationTime - 1;
|
17424 | }
|
17425 |
|
17426 | if (finishedExpirationTime <= root.lastPingedTime) {
|
17427 |
|
17428 | root.lastPingedTime = NoWork;
|
17429 | }
|
17430 |
|
17431 | if (finishedExpirationTime <= root.lastExpiredTime) {
|
17432 |
|
17433 | root.lastExpiredTime = NoWork;
|
17434 | }
|
17435 | }
|
17436 | function markRootExpiredAtTime(root, expirationTime) {
|
17437 | var lastExpiredTime = root.lastExpiredTime;
|
17438 |
|
17439 | if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
|
17440 | root.lastExpiredTime = expirationTime;
|
17441 | }
|
17442 | }
|
17443 |
|
17444 |
|
17445 |
|
17446 |
|
17447 |
|
17448 | var ReactFiberInstrumentation = {
|
17449 | debugTool: null
|
17450 | };
|
17451 | var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
|
17452 |
|
17453 | var didWarnAboutNestedUpdates;
|
17454 | {
|
17455 | didWarnAboutNestedUpdates = false;
|
17456 |
|
17457 | }
|
17458 |
|
17459 | function getContextForSubtree(parentComponent) {
|
17460 | if (!parentComponent) {
|
17461 | return emptyContextObject;
|
17462 | }
|
17463 |
|
17464 | var fiber = get(parentComponent);
|
17465 | var parentContext = findCurrentUnmaskedContext(fiber);
|
17466 |
|
17467 | if (fiber.tag === ClassComponent) {
|
17468 | var Component = fiber.type;
|
17469 |
|
17470 | if (isContextProvider(Component)) {
|
17471 | return processChildContext(fiber, Component, parentContext);
|
17472 | }
|
17473 | }
|
17474 |
|
17475 | return parentContext;
|
17476 | }
|
17477 |
|
17478 | function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
|
17479 | return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks);
|
17480 | }
|
17481 | function updateContainer(element, container, parentComponent, callback) {
|
17482 | var current$$1 = container.current;
|
17483 | var currentTime = requestCurrentTimeForUpdate();
|
17484 |
|
17485 | {
|
17486 |
|
17487 | if ('undefined' !== typeof jest) {
|
17488 | warnIfUnmockedScheduler(current$$1);
|
17489 | warnIfNotScopedWithMatchingAct(current$$1);
|
17490 | }
|
17491 | }
|
17492 |
|
17493 | var suspenseConfig = requestCurrentSuspenseConfig();
|
17494 | var expirationTime = computeExpirationForFiber(currentTime, current$$1, suspenseConfig);
|
17495 |
|
17496 | {
|
17497 | if (ReactFiberInstrumentation_1.debugTool) {
|
17498 | if (current$$1.alternate === null) {
|
17499 | ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
|
17500 | } else if (element === null) {
|
17501 | ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
|
17502 | } else {
|
17503 | ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
|
17504 | }
|
17505 | }
|
17506 | }
|
17507 |
|
17508 | var context = getContextForSubtree(parentComponent);
|
17509 |
|
17510 | if (container.context === null) {
|
17511 | container.context = context;
|
17512 | } else {
|
17513 | container.pendingContext = context;
|
17514 | }
|
17515 |
|
17516 | {
|
17517 | if (phase === 'render' && current$1 !== null && !didWarnAboutNestedUpdates) {
|
17518 | didWarnAboutNestedUpdates = true;
|
17519 | warningWithoutStack$1(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current$1.type) || 'Unknown');
|
17520 | }
|
17521 | }
|
17522 |
|
17523 | var update = createUpdate(expirationTime, suspenseConfig);
|
17524 |
|
17525 |
|
17526 | update.payload = {
|
17527 | element: element
|
17528 | };
|
17529 | callback = callback === undefined ? null : callback;
|
17530 |
|
17531 | if (callback !== null) {
|
17532 | !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
|
17533 | update.callback = callback;
|
17534 | }
|
17535 |
|
17536 | enqueueUpdate(current$$1, update);
|
17537 | scheduleWork(current$$1, expirationTime);
|
17538 | return expirationTime;
|
17539 | }
|
17540 |
|
17541 |
|
17542 |
|
17543 |
|
17544 |
|
17545 |
|
17546 |
|
17547 |
|
17548 | var shouldSuspendImpl = function (fiber) {
|
17549 | return false;
|
17550 | };
|
17551 |
|
17552 | function shouldSuspend(fiber) {
|
17553 | return shouldSuspendImpl(fiber);
|
17554 | }
|
17555 | var overrideHookState = null;
|
17556 | var overrideProps = null;
|
17557 | var scheduleUpdate = null;
|
17558 | var setSuspenseHandler = null;
|
17559 |
|
17560 | {
|
17561 | var copyWithSetImpl = function (obj, path, idx, value) {
|
17562 | if (idx >= path.length) {
|
17563 | return value;
|
17564 | }
|
17565 |
|
17566 | var key = path[idx];
|
17567 | var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
|
17568 |
|
17569 | updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
|
17570 | return updated;
|
17571 | };
|
17572 |
|
17573 | var copyWithSet = function (obj, path, value) {
|
17574 | return copyWithSetImpl(obj, path, 0, value);
|
17575 | };
|
17576 |
|
17577 |
|
17578 | overrideHookState = function (fiber, id, path, value) {
|
17579 |
|
17580 |
|
17581 | var currentHook = fiber.memoizedState;
|
17582 |
|
17583 | while (currentHook !== null && id > 0) {
|
17584 | currentHook = currentHook.next;
|
17585 | id--;
|
17586 | }
|
17587 |
|
17588 | if (currentHook !== null) {
|
17589 | var newState = copyWithSet(currentHook.memoizedState, path, value);
|
17590 | currentHook.memoizedState = newState;
|
17591 | currentHook.baseState = newState;
|
17592 |
|
17593 |
|
17594 |
|
17595 |
|
17596 |
|
17597 | fiber.memoizedProps = _assign({}, fiber.memoizedProps);
|
17598 | scheduleWork(fiber, Sync);
|
17599 | }
|
17600 | };
|
17601 |
|
17602 |
|
17603 | overrideProps = function (fiber, path, value) {
|
17604 | fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
|
17605 |
|
17606 | if (fiber.alternate) {
|
17607 | fiber.alternate.pendingProps = fiber.pendingProps;
|
17608 | }
|
17609 |
|
17610 | scheduleWork(fiber, Sync);
|
17611 | };
|
17612 |
|
17613 | scheduleUpdate = function (fiber) {
|
17614 | scheduleWork(fiber, Sync);
|
17615 | };
|
17616 |
|
17617 | setSuspenseHandler = function (newShouldSuspendImpl) {
|
17618 | shouldSuspendImpl = newShouldSuspendImpl;
|
17619 | };
|
17620 | }
|
17621 |
|
17622 | function injectIntoDevTools(devToolsConfig) {
|
17623 | var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
|
17624 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
17625 | return injectInternals(_assign({}, devToolsConfig, {
|
17626 | overrideHookState: overrideHookState,
|
17627 | overrideProps: overrideProps,
|
17628 | setSuspenseHandler: setSuspenseHandler,
|
17629 | scheduleUpdate: scheduleUpdate,
|
17630 | currentDispatcherRef: ReactCurrentDispatcher,
|
17631 | findHostInstanceByFiber: function (fiber) {
|
17632 | var hostFiber = findCurrentHostFiber(fiber);
|
17633 |
|
17634 | if (hostFiber === null) {
|
17635 | return null;
|
17636 | }
|
17637 |
|
17638 | return hostFiber.stateNode;
|
17639 | },
|
17640 | findFiberByHostInstance: function (instance) {
|
17641 | if (!findFiberByHostInstance) {
|
17642 |
|
17643 | return null;
|
17644 | }
|
17645 |
|
17646 | return findFiberByHostInstance(instance);
|
17647 | },
|
17648 |
|
17649 | findHostInstancesForRefresh: findHostInstancesForRefresh,
|
17650 | scheduleRefresh: scheduleRefresh,
|
17651 | scheduleRoot: scheduleRoot,
|
17652 | setRefreshHandler: setRefreshHandler,
|
17653 |
|
17654 | getCurrentFiber: function () {
|
17655 | return current$1;
|
17656 | }
|
17657 | }));
|
17658 | }
|
17659 |
|
17660 |
|
17661 |
|
17662 |
|
17663 | var container = _class({
|
17664 |
|
17665 | grab: function(){
|
17666 | for (var i = 0; i < arguments.length; i++) arguments[i].inject(this);
|
17667 | return this;
|
17668 | },
|
17669 |
|
17670 | empty: function(){
|
17671 | var node;
|
17672 | while (node = this.firstChild) node.eject();
|
17673 | return this;
|
17674 | }
|
17675 |
|
17676 | });
|
17677 |
|
17678 | function elementFrom(node){
|
17679 | if (node.toElement) return node.toElement();
|
17680 | if (node.getDOMNode) return node.getDOMNode();
|
17681 | if (node.getNode) return node.getNode();
|
17682 | return node;
|
17683 | }
|
17684 |
|
17685 | var native_1 = _class({
|
17686 |
|
17687 |
|
17688 |
|
17689 | toElement: function(){
|
17690 | return this.element;
|
17691 | },
|
17692 |
|
17693 | getDOMNode: function(){
|
17694 | return this.toElement();
|
17695 | },
|
17696 |
|
17697 | getNode: function(){
|
17698 | return this.toElement();
|
17699 | },
|
17700 |
|
17701 |
|
17702 |
|
17703 | inject: function(container){
|
17704 | (container.containerElement || elementFrom(container))
|
17705 | .appendChild(this.element);
|
17706 | return this;
|
17707 | },
|
17708 |
|
17709 | injectBefore: function(sibling){
|
17710 | var element = elementFrom(sibling);
|
17711 | element.parentNode.insertBefore(this.element, element);
|
17712 | return this;
|
17713 | },
|
17714 |
|
17715 | eject: function(){
|
17716 | var element = this.element, parent = element.parentNode;
|
17717 | if (parent) parent.removeChild(element);
|
17718 | return this;
|
17719 | },
|
17720 |
|
17721 |
|
17722 |
|
17723 | subscribe: function(type, fn, bind){
|
17724 | if (typeof type != 'string'){
|
17725 | var subscriptions = [];
|
17726 | for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
|
17727 | return function(){
|
17728 | for (var i = 0, l = subscriptions.length; i < l; i++)
|
17729 | subscriptions[i]();
|
17730 | return this;
|
17731 | };
|
17732 | } else {
|
17733 | if (!bind) bind = this;
|
17734 | var bound;
|
17735 | if (typeof fn === 'function'){
|
17736 | bound = fn.bind ? fn.bind(bind)
|
17737 | : function(){ return fn.apply(bind, arguments); };
|
17738 | } else {
|
17739 | bound = fn;
|
17740 | }
|
17741 | var element = this.element;
|
17742 | if (element.addEventListener){
|
17743 | element.addEventListener(type, bound, false);
|
17744 | return function(){
|
17745 | element.removeEventListener(type, bound, false);
|
17746 | return this;
|
17747 | };
|
17748 | } else {
|
17749 | element.attachEvent('on' + type, bound);
|
17750 | return function(){
|
17751 | element.detachEvent('on' + type, bound);
|
17752 | return this;
|
17753 | };
|
17754 | }
|
17755 | }
|
17756 | }
|
17757 |
|
17758 | });
|
17759 |
|
17760 | var fps = 1000 / 60;
|
17761 | var invalids = [];
|
17762 | var renderTimer;
|
17763 | var renderInvalids = function(){
|
17764 | clearTimeout(renderTimer);
|
17765 | renderTimer = null;
|
17766 | var canvases = invalids;
|
17767 | invalids = [];
|
17768 | for (var i = 0, l = canvases.length; i < l; i++){
|
17769 | var c = canvases[i];
|
17770 | c._valid = true;
|
17771 | c.render();
|
17772 | }
|
17773 | };
|
17774 |
|
17775 | var resolution = typeof window !== 'undefined' && window.devicePixelRatio || 1;
|
17776 |
|
17777 | var previousHit = null;
|
17778 | var previousHitSurface = null;
|
17779 |
|
17780 | var CanvasSurface = _class(native_1, container, {
|
17781 |
|
17782 | initialize: function(width, height, existingElement){
|
17783 | var element = this.element = existingElement || document.createElement('canvas');
|
17784 | var context = this.context = element.getContext('2d');
|
17785 | this._valid = true;
|
17786 | if (width != null && height != null) this.resize(width, height);
|
17787 |
|
17788 | element.addEventListener('mousemove', this, false);
|
17789 | element.addEventListener('mouseout', this, false);
|
17790 | element.addEventListener('mouseover', this, false);
|
17791 | element.addEventListener('mouseup', this, false);
|
17792 | element.addEventListener('mousedown', this, false);
|
17793 | element.addEventListener('click', this, false);
|
17794 | },
|
17795 |
|
17796 | handleEvent: function(event){
|
17797 | if (event.clientX == null) return;
|
17798 | var element = this.element,
|
17799 | rect = element.getBoundingClientRect(),
|
17800 | x = event.clientX - rect.left - element.clientLeft,
|
17801 | y = event.clientY - rect.top - element.clientTop,
|
17802 | hit = this.hitTest(x, y);
|
17803 |
|
17804 | if (hit !== previousHit){
|
17805 | if (previousHit){
|
17806 | previousHit.dispatch({
|
17807 | type: 'mouseout',
|
17808 | target: previousHit,
|
17809 | relatedTarget: hit,
|
17810 | sourceEvent: event
|
17811 | });
|
17812 | }
|
17813 | if (hit){
|
17814 | hit.dispatch({
|
17815 | type: 'mouseover',
|
17816 | target: hit,
|
17817 | relatedTarget: previousHit,
|
17818 | sourceEvent: event
|
17819 | });
|
17820 | }
|
17821 | previousHit = hit;
|
17822 | previousHitSurface = this;
|
17823 | this.refreshCursor();
|
17824 | }
|
17825 |
|
17826 | if (hit) hit.dispatch(event);
|
17827 | },
|
17828 |
|
17829 | refreshCursor: function(){
|
17830 | if (previousHitSurface !== this) return;
|
17831 | var hit = previousHit, hitCursor = '', hitTooltip = '';
|
17832 | while (hit){
|
17833 | if (!hitCursor && hit._cursor){
|
17834 | hitCursor = hit._cursor;
|
17835 | if (hitTooltip) break;
|
17836 | }
|
17837 | if (!hitTooltip && hit._tooltip){
|
17838 | hitTooltip = hit._tooltip;
|
17839 | if (hitCursor) break;
|
17840 | }
|
17841 | hit = hit.parentNode;
|
17842 | }
|
17843 |
|
17844 | this.element.style.cursor = hitCursor;
|
17845 | this.element.title = hitTooltip;
|
17846 | },
|
17847 |
|
17848 | resize: function(width, height){
|
17849 | var element = this.element;
|
17850 | element.setAttribute('width', width * resolution);
|
17851 | element.setAttribute('height', height * resolution);
|
17852 | element.style.width = width + 'px';
|
17853 | element.style.height = height + 'px';
|
17854 | this.width = width;
|
17855 | this.height = height;
|
17856 | return this;
|
17857 | },
|
17858 |
|
17859 | invalidate: function(left, top, width, height){
|
17860 | if (this._valid){
|
17861 | this._valid = false;
|
17862 | invalids.push(this);
|
17863 | if (!renderTimer){
|
17864 | if (window.mozRequestAnimationFrame){
|
17865 | renderTimer = true;
|
17866 | window.mozRequestAnimationFrame(renderInvalids);
|
17867 | } else {
|
17868 | renderTimer = setTimeout(renderInvalids, fps);
|
17869 | }
|
17870 | }
|
17871 | }
|
17872 | return this;
|
17873 | },
|
17874 |
|
17875 | hitTest: function(x, y){
|
17876 | if (x < 0 || y < 0 || x > this.width || y > this.height) return null;
|
17877 | var node = this.lastChild;
|
17878 | while (node){
|
17879 | var hit = node.hitTest(x, y);
|
17880 | if (hit) return hit;
|
17881 | node = node.previousSibling;
|
17882 | }
|
17883 | return null;
|
17884 | },
|
17885 |
|
17886 | render: function(){
|
17887 | var node = this.firstChild, context = this.context;
|
17888 | context.setTransform(resolution, 0, 0, resolution, 0, 0);
|
17889 | context.clearRect(0, 0, this.width, this.height);
|
17890 | while (node){
|
17891 | node.renderTo(context, resolution, 0, 0, resolution, 0, 0);
|
17892 | node = node.nextSibling;
|
17893 | }
|
17894 | this.refreshCursor();
|
17895 | }
|
17896 |
|
17897 | });
|
17898 |
|
17899 | CanvasSurface.tagName = 'canvas';
|
17900 |
|
17901 | var surface = CanvasSurface;
|
17902 |
|
17903 | var path$2 = _class({
|
17904 |
|
17905 | initialize: function(path){
|
17906 | this.reset().push(path);
|
17907 | },
|
17908 |
|
17909 |
|
17910 |
|
17911 | push: function(){
|
17912 | var p = Array.prototype.join.call(arguments, ' ')
|
17913 | .match(/[a-df-z]|[\-+]?(?:[\d\.]e[\-+]?|[^\s\-+,a-z])+/ig);
|
17914 | if (!p) return this;
|
17915 |
|
17916 | var last, cmd = p[0], i = 1;
|
17917 | while (cmd){
|
17918 | switch (cmd){
|
17919 | case 'm': this.move(p[i++], p[i++]); break;
|
17920 | case 'l': this.line(p[i++], p[i++]); break;
|
17921 | case 'c': this.curve(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
|
17922 | case 's': this.curve(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
17923 | case 'q': this.curve(p[i++], p[i++], p[i++], p[i++]); break;
|
17924 | case 't': this.curve(p[i++], p[i++]); break;
|
17925 | case 'a': this.arc(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
|
17926 | case 'h': this.line(p[i++], 0); break;
|
17927 | case 'v': this.line(0, p[i++]); break;
|
17928 |
|
17929 | case 'M': this.moveTo(p[i++], p[i++]); break;
|
17930 | case 'L': this.lineTo(p[i++], p[i++]); break;
|
17931 | case 'C': this.curveTo(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
|
17932 | case 'S': this.curveTo(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
17933 | case 'Q': this.curveTo(p[i++], p[i++], p[i++], p[i++]); break;
|
17934 | case 'T': this.curveTo(p[i++], p[i++]); break;
|
17935 | case 'A': this.arcTo(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
|
17936 | case 'H': this.lineTo(p[i++], this.penY); break;
|
17937 | case 'V': this.lineTo(this.penX, p[i++]); break;
|
17938 |
|
17939 | case 'Z': case 'z': this.close(); break;
|
17940 | default: cmd = last; i--; continue;
|
17941 | }
|
17942 |
|
17943 | last = cmd;
|
17944 | if (last == 'm') last = 'l';
|
17945 | else if (last == 'M') last = 'L';
|
17946 | cmd = p[i++];
|
17947 | }
|
17948 | return this;
|
17949 | },
|
17950 |
|
17951 |
|
17952 |
|
17953 | reset: function(){
|
17954 | this.penX = this.penY = 0;
|
17955 | this.penDownX = this.penDownY = null;
|
17956 | this._pivotX = this._pivotY = 0;
|
17957 | this.onReset();
|
17958 | return this;
|
17959 | },
|
17960 |
|
17961 | move: function(x,y){
|
17962 | this.onMove(this.penX, this.penY, this._pivotX = this.penX += (+x), this._pivotY = this.penY += (+y));
|
17963 | return this;
|
17964 | },
|
17965 | moveTo: function(x,y){
|
17966 | this.onMove(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
|
17967 | return this;
|
17968 | },
|
17969 |
|
17970 | line: function(x,y){
|
17971 | return this.lineTo(this.penX + (+x), this.penY + (+y));
|
17972 | },
|
17973 | lineTo: function(x,y){
|
17974 | if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
|
17975 | this.onLine(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
|
17976 | return this;
|
17977 | },
|
17978 |
|
17979 | curve: function(c1x, c1y, c2x, c2y, ex, ey){
|
17980 | var x = this.penX, y = this.penY;
|
17981 | return this.curveTo(
|
17982 | x + (+c1x), y + (+c1y),
|
17983 | c2x == null ? null : x + (+c2x),
|
17984 | c2y == null ? null : y + (+c2y),
|
17985 | ex == null ? null : x + (+ex),
|
17986 | ey == null ? null : y + (+ey)
|
17987 | );
|
17988 | },
|
17989 | curveTo: function(c1x, c1y, c2x, c2y, ex, ey){
|
17990 | var x = this.penX, y = this.penY;
|
17991 | if (c2x == null){
|
17992 | c2x = +c1x; c2y = +c1y;
|
17993 | c1x = (x * 2) - (this._pivotX || 0); c1y = (y * 2) - (this._pivotY || 0);
|
17994 | }
|
17995 | if (ex == null){
|
17996 | this._pivotX = +c1x; this._pivotY = +c1y;
|
17997 | ex = +c2x; ey = +c2y;
|
17998 | c2x = (ex + (+c1x) * 2) / 3; c2y = (ey + (+c1y) * 2) / 3;
|
17999 | c1x = (x + (+c1x) * 2) / 3; c1y = (y + (+c1y) * 2) / 3;
|
18000 | } else {
|
18001 | this._pivotX = +c2x; this._pivotY = +c2y;
|
18002 | }
|
18003 | if (this.penDownX == null){ this.penDownX = x; this.penDownY = y; }
|
18004 | this.onBezierCurve(x, y, +c1x, +c1y, +c2x, +c2y, this.penX = +ex, this.penY = +ey);
|
18005 | return this;
|
18006 | },
|
18007 |
|
18008 | arc: function(x, y, rx, ry, outer, counterClockwise, rotation){
|
18009 | return this.arcTo(this.penX + (+x), this.penY + (+y), rx, ry, outer, counterClockwise, rotation);
|
18010 | },
|
18011 | arcTo: function(x, y, rx, ry, outer, counterClockwise, rotation){
|
18012 | ry = Math.abs(+ry || +rx || (+y - this.penY));
|
18013 | rx = Math.abs(+rx || (+x - this.penX));
|
18014 |
|
18015 | if (!rx || !ry || (x == this.penX && y == this.penY)) return this.lineTo(x, y);
|
18016 |
|
18017 | var tX = this.penX, tY = this.penY, clockwise = !+counterClockwise, large = !!+outer;
|
18018 |
|
18019 | var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad);
|
18020 | x -= tX; y -= tY;
|
18021 |
|
18022 |
|
18023 | var cx = cos * x / 2 + sin * y / 2,
|
18024 | cy = -sin * x / 2 + cos * y / 2,
|
18025 | rxry = rx * rx * ry * ry,
|
18026 | rycx = ry * ry * cx * cx,
|
18027 | rxcy = rx * rx * cy * cy,
|
18028 | a = rxry - rxcy - rycx;
|
18029 |
|
18030 | if (a < 0){
|
18031 | a = Math.sqrt(1 - a / rxry);
|
18032 | rx *= a; ry *= a;
|
18033 | cx = x / 2; cy = y / 2;
|
18034 | } else {
|
18035 | a = Math.sqrt(a / (rxcy + rycx));
|
18036 | if (large == clockwise) a = -a;
|
18037 | var cxd = -a * cy * rx / ry,
|
18038 | cyd = a * cx * ry / rx;
|
18039 | cx = cos * cxd - sin * cyd + x / 2;
|
18040 | cy = sin * cxd + cos * cyd + y / 2;
|
18041 | }
|
18042 |
|
18043 |
|
18044 | var xx = cos / rx, yx = sin / rx,
|
18045 | xy = -sin / ry, yy = cos / ry;
|
18046 |
|
18047 |
|
18048 | var sa = Math.atan2(xy * -cx + yy * -cy, xx * -cx + yx * -cy),
|
18049 | ea = Math.atan2(xy * (x - cx) + yy * (y - cy), xx * (x - cx) + yx * (y - cy));
|
18050 |
|
18051 | cx += tX; cy += tY;
|
18052 | x += tX; y += tY;
|
18053 |
|
18054 |
|
18055 | if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
|
18056 | this.onArc(
|
18057 | tX, tY, this._pivotX = this.penX = x, this._pivotY = this.penY = y,
|
18058 | cx, cy, rx, ry, sa, ea, !clockwise, rotation
|
18059 | );
|
18060 | return this;
|
18061 | },
|
18062 |
|
18063 | counterArc: function(x, y, rx, ry, outer){
|
18064 | return this.arc(x, y, rx, ry, outer, true);
|
18065 | },
|
18066 | counterArcTo: function(x, y, rx, ry, outer){
|
18067 | return this.arcTo(x, y, rx, ry, outer, true);
|
18068 | },
|
18069 |
|
18070 | close: function(){
|
18071 | if (this.penDownX != null){
|
18072 | this.onClose(this.penX, this.penY, this.penX = this.penDownX, this.penY = this.penDownY);
|
18073 | this.penDownX = null;
|
18074 | }
|
18075 | return this;
|
18076 | },
|
18077 |
|
18078 |
|
18079 |
|
18080 | onReset: function(){
|
18081 | },
|
18082 |
|
18083 | onMove: function(sx, sy, ex, ey){
|
18084 | },
|
18085 |
|
18086 | onLine: function(sx, sy, ex, ey){
|
18087 | this.onBezierCurve(sx, sy, sx, sy, ex, ey, ex, ey);
|
18088 | },
|
18089 |
|
18090 | onBezierCurve: function(sx, sy, c1x, c1y, c2x, c2y, ex, ey){
|
18091 | var gx = ex - sx, gy = ey - sy,
|
18092 | g = gx * gx + gy * gy,
|
18093 | v1, v2, cx, cy, u;
|
18094 |
|
18095 | cx = c1x - sx; cy = c1y - sy;
|
18096 | u = cx * gx + cy * gy;
|
18097 |
|
18098 | if (u > g){
|
18099 | cx -= gx;
|
18100 | cy -= gy;
|
18101 | } else if (u > 0 && g != 0){
|
18102 | cx -= u/g * gx;
|
18103 | cy -= u/g * gy;
|
18104 | }
|
18105 |
|
18106 | v1 = cx * cx + cy * cy;
|
18107 |
|
18108 | cx = c2x - sx; cy = c2y - sy;
|
18109 | u = cx * gx + cy * gy;
|
18110 |
|
18111 | if (u > g){
|
18112 | cx -= gx;
|
18113 | cy -= gy;
|
18114 | } else if (u > 0 && g != 0){
|
18115 | cx -= u/g * gx;
|
18116 | cy -= u/g * gy;
|
18117 | }
|
18118 |
|
18119 | v2 = cx * cx + cy * cy;
|
18120 |
|
18121 | if (v1 < 0.01 && v2 < 0.01){
|
18122 | this.onLine(sx, sy, ex, ey);
|
18123 | return;
|
18124 | }
|
18125 |
|
18126 |
|
18127 | if (isNaN(v1) || isNaN(v2)){
|
18128 | throw new Error('Bad input');
|
18129 | }
|
18130 |
|
18131 |
|
18132 | var s1x = (c1x + c2x) * 0.5, s1y = (c1y + c2y) * 0.5,
|
18133 | l1x = (c1x + sx) * 0.5, l1y = (c1y + sy) * 0.5,
|
18134 | l2x = (l1x + s1x) * 0.5, l2y = (l1y + s1y) * 0.5,
|
18135 | r2x = (ex + c2x) * 0.5, r2y = (ey + c2y) * 0.5,
|
18136 | r1x = (r2x + s1x) * 0.5, r1y = (r2y + s1y) * 0.5,
|
18137 | l2r1x = (l2x + r1x) * 0.5, l2r1y = (l2y + r1y) * 0.5;
|
18138 |
|
18139 |
|
18140 | this.onBezierCurve(sx, sy, l1x, l1y, l2x, l2y, l2r1x, l2r1y);
|
18141 | this.onBezierCurve(l2r1x, l2r1y, r1x, r1y, r2x, r2y, ex, ey);
|
18142 | },
|
18143 |
|
18144 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
18145 |
|
18146 | var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad),
|
18147 | xx = cos * rx, yx = -sin * ry,
|
18148 | xy = sin * rx, yy = cos * ry;
|
18149 |
|
18150 |
|
18151 | var arc = ea - sa;
|
18152 | if (arc < 0 && !ccw) arc += Math.PI * 2;
|
18153 | else if (arc > 0 && ccw) arc -= Math.PI * 2;
|
18154 |
|
18155 | var n = Math.ceil(Math.abs(arc / (Math.PI / 2))),
|
18156 | step = arc / n,
|
18157 | k = (4 / 3) * Math.tan(step / 4);
|
18158 |
|
18159 | var x = Math.cos(sa), y = Math.sin(sa);
|
18160 |
|
18161 | for (var i = 0; i < n; i++){
|
18162 | var cp1x = x - k * y, cp1y = y + k * x;
|
18163 |
|
18164 | sa += step;
|
18165 | x = Math.cos(sa); y = Math.sin(sa);
|
18166 |
|
18167 | var cp2x = x + k * y, cp2y = y - k * x;
|
18168 |
|
18169 | this.onBezierCurve(
|
18170 | sx, sy,
|
18171 | cx + xx * cp1x + yx * cp1y, cy + xy * cp1x + yy * cp1y,
|
18172 | cx + xx * cp2x + yx * cp2y, cy + xy * cp2x + yy * cp2y,
|
18173 | (sx = (cx + xx * x + yx * y)), (sy = (cy + xy * x + yy * y))
|
18174 | );
|
18175 | }
|
18176 | },
|
18177 |
|
18178 | onClose: function(sx, sy, ex, ey){
|
18179 | this.onLine(sx, sy, ex, ey);
|
18180 | }
|
18181 |
|
18182 | });
|
18183 |
|
18184 | var CanvasPath = _class(path$2, {
|
18185 |
|
18186 | initialize: function(path){
|
18187 | this.reset();
|
18188 | if (path instanceof CanvasPath){
|
18189 | this.path = path.path.slice(0);
|
18190 | } else if (path){
|
18191 | if (path.applyToPath)
|
18192 | path.applyToPath(this);
|
18193 | else
|
18194 | this.push(path);
|
18195 | }
|
18196 | },
|
18197 |
|
18198 | onReset: function(){
|
18199 | this.path = [];
|
18200 | },
|
18201 |
|
18202 | onMove: function(sx, sy, x, y){
|
18203 | this.path.push(function(context){
|
18204 | context.moveTo(x, y);
|
18205 | });
|
18206 | },
|
18207 |
|
18208 | onLine: function(sx, sy, x, y){
|
18209 | this.path.push(function(context){
|
18210 | context.lineTo(x, y);
|
18211 | });
|
18212 | },
|
18213 |
|
18214 | onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
|
18215 | this.path.push(function(context){
|
18216 | context.bezierCurveTo(p1x, p1y, p2x, p2y, x, y);
|
18217 | });
|
18218 | },
|
18219 |
|
18220 | _arcToBezier: path$2.prototype.onArc,
|
18221 |
|
18222 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
18223 | if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
|
18224 | this.path.push(function(context){
|
18225 | context.arc(cx, cy, rx, sa, ea, ccw);
|
18226 | });
|
18227 | },
|
18228 |
|
18229 | onClose: function(){
|
18230 | this.path.push(function(context){
|
18231 | context.closePath();
|
18232 | });
|
18233 | },
|
18234 |
|
18235 | toCommands: function(){
|
18236 | return this.path.slice(0);
|
18237 | }
|
18238 |
|
18239 | });
|
18240 |
|
18241 | var path = CanvasPath;
|
18242 |
|
18243 | var colors = {
|
18244 | maroon: '#800000', red: '#ff0000', orange: '#ffA500', yellow: '#ffff00', olive: '#808000',
|
18245 | purple: '#800080', fuchsia: "#ff00ff", white: '#ffffff', lime: '#00ff00', green: '#008000',
|
18246 | navy: '#000080', blue: '#0000ff', aqua: '#00ffff', teal: '#008080',
|
18247 | black: '#000000', silver: '#c0c0c0', gray: '#808080'
|
18248 | };
|
18249 |
|
18250 | var map = function(array, fn){
|
18251 | var results = [];
|
18252 | for (var i = 0, l = array.length; i < l; i++)
|
18253 | results[i] = fn(array[i], i);
|
18254 | return results;
|
18255 | };
|
18256 |
|
18257 | var Color = function(color, type){
|
18258 |
|
18259 | if (color.isColor){
|
18260 |
|
18261 | this.red = color.red;
|
18262 | this.green = color.green;
|
18263 | this.blue = color.blue;
|
18264 | this.alpha = color.alpha;
|
18265 |
|
18266 | } else {
|
18267 |
|
18268 | var namedColor = colors[color];
|
18269 | if (namedColor){
|
18270 | color = namedColor;
|
18271 | type = 'hex';
|
18272 | }
|
18273 |
|
18274 | switch (typeof color){
|
18275 | case 'string': if (!type) type = (type = color.match(/^rgb|^hsb|^hsl/)) ? type[0] : 'hex'; break;
|
18276 | case 'object': type = type || 'rgb'; color = color.toString(); break;
|
18277 | case 'number': type = 'hex'; color = color.toString(16); break;
|
18278 | }
|
18279 |
|
18280 | color = Color['parse' + type.toUpperCase()](color);
|
18281 | this.red = color[0];
|
18282 | this.green = color[1];
|
18283 | this.blue = color[2];
|
18284 | this.alpha = color[3];
|
18285 | }
|
18286 |
|
18287 | this.isColor = true;
|
18288 |
|
18289 | };
|
18290 |
|
18291 | var limit = function(number, min, max){
|
18292 | return Math.min(max, Math.max(min, number));
|
18293 | };
|
18294 |
|
18295 | var listMatch = /([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,?\s*([-.\d]*\%?)/;
|
18296 | var hexMatch = /^#?([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{0,2})$/i;
|
18297 |
|
18298 | Color.parseRGB = function(color){
|
18299 | return map(color.match(listMatch).slice(1), function(bit, i){
|
18300 | if (bit) bit = parseFloat(bit) * (bit[bit.length - 1] == '%' ? 2.55 : 1);
|
18301 | return (i < 3) ? Math.round(((bit %= 256) < 0) ? bit + 256 : bit) : limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
18302 | });
|
18303 | };
|
18304 |
|
18305 | Color.parseHEX = function(color){
|
18306 | if (color.length == 1) color = color + color + color;
|
18307 | return map(color.match(hexMatch).slice(1), function(bit, i){
|
18308 | if (i == 3) return (bit) ? parseInt(bit, 16) / 255 : 1;
|
18309 | return parseInt((bit.length == 1) ? bit + bit : bit, 16);
|
18310 | });
|
18311 | };
|
18312 |
|
18313 | Color.parseHSB = function(color){
|
18314 | var hsb = map(color.match(listMatch).slice(1), function(bit, i){
|
18315 | if (bit) bit = parseFloat(bit);
|
18316 | if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
|
18317 | else if (i < 3) return limit(Math.round(bit), 0, 100);
|
18318 | else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
18319 | });
|
18320 |
|
18321 | var a = hsb[3];
|
18322 | var br = Math.round(hsb[2] / 100 * 255);
|
18323 | if (hsb[1] == 0) return [br, br, br, a];
|
18324 |
|
18325 | var hue = hsb[0];
|
18326 | var f = hue % 60;
|
18327 | var p = Math.round((hsb[2] * (100 - hsb[1])) / 10000 * 255);
|
18328 | var q = Math.round((hsb[2] * (6000 - hsb[1] * f)) / 600000 * 255);
|
18329 | var t = Math.round((hsb[2] * (6000 - hsb[1] * (60 - f))) / 600000 * 255);
|
18330 |
|
18331 | switch (Math.floor(hue / 60)){
|
18332 | case 0: return [br, t, p, a];
|
18333 | case 1: return [q, br, p, a];
|
18334 | case 2: return [p, br, t, a];
|
18335 | case 3: return [p, q, br, a];
|
18336 | case 4: return [t, p, br, a];
|
18337 | default: return [br, p, q, a];
|
18338 | }
|
18339 | };
|
18340 |
|
18341 | Color.parseHSL = function(color){
|
18342 | var hsb = map(color.match(listMatch).slice(1), function(bit, i){
|
18343 | if (bit) bit = parseFloat(bit);
|
18344 | if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
|
18345 | else if (i < 3) return limit(Math.round(bit), 0, 100);
|
18346 | else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
18347 | });
|
18348 |
|
18349 | var h = hsb[0] / 60;
|
18350 | var s = hsb[1] / 100;
|
18351 | var l = hsb[2] / 100;
|
18352 | var a = hsb[3];
|
18353 |
|
18354 | var c = (1 - Math.abs(2 * l - 1)) * s;
|
18355 | var x = c * (1 - Math.abs(h % 2 - 1));
|
18356 | var m = l - c / 2;
|
18357 |
|
18358 | var p = Math.round((c + m) * 255);
|
18359 | var q = Math.round((x + m) * 255);
|
18360 | var t = Math.round((m) * 255);
|
18361 |
|
18362 | switch (Math.floor(h)){
|
18363 | case 0: return [p, q, t, a];
|
18364 | case 1: return [q, p, t, a];
|
18365 | case 2: return [t, p, q, a];
|
18366 | case 3: return [t, q, p, a];
|
18367 | case 4: return [q, t, p, a];
|
18368 | default: return [p, t, q, a];
|
18369 | }
|
18370 | };
|
18371 |
|
18372 | var toString = function(type, array){
|
18373 | if (array[3] != 1) type += 'a';
|
18374 | else array.pop();
|
18375 | return type + '(' + array.join(', ') + ')';
|
18376 | };
|
18377 |
|
18378 | Color.prototype = {
|
18379 |
|
18380 | toHSB: function(array){
|
18381 | var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
|
18382 |
|
18383 | var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
|
18384 | var hue = 0, saturation = (delta != 0) ? delta / max : 0, brightness = max / 255;
|
18385 | if (saturation){
|
18386 | var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
|
18387 | hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
|
18388 | if ((hue /= 6) < 0) hue++;
|
18389 | }
|
18390 |
|
18391 | var hsb = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(brightness * 100), alpha];
|
18392 |
|
18393 | return (array) ? hsb : toString('hsb', hsb);
|
18394 | },
|
18395 |
|
18396 | toHSL: function(array){
|
18397 | var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
|
18398 |
|
18399 | var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
|
18400 | var hue = 0, saturation = (delta != 0) ? delta / (255 - Math.abs((max + min) - 255)) : 0, lightness = (max + min) / 512;
|
18401 | if (saturation){
|
18402 | var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
|
18403 | hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
|
18404 | if ((hue /= 6) < 0) hue++;
|
18405 | }
|
18406 |
|
18407 | var hsl = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(lightness * 100), alpha];
|
18408 |
|
18409 | return (array) ? hsl : toString('hsl', hsl);
|
18410 | },
|
18411 |
|
18412 | toHEX: function(array){
|
18413 |
|
18414 | var a = this.alpha;
|
18415 | var alpha = ((a = Math.round((a * 255)).toString(16)).length == 1) ? a + a : a;
|
18416 |
|
18417 | var hex = map([this.red, this.green, this.blue], function(bit){
|
18418 | bit = bit.toString(16);
|
18419 | return (bit.length == 1) ? '0' + bit : bit;
|
18420 | });
|
18421 |
|
18422 | return (array) ? hex.concat(alpha) : '#' + hex.join('') + ((alpha == 'ff') ? '' : alpha);
|
18423 | },
|
18424 |
|
18425 | toRGB: function(array){
|
18426 | var rgb = [this.red, this.green, this.blue, this.alpha];
|
18427 | return (array) ? rgb : toString('rgb', rgb);
|
18428 | }
|
18429 |
|
18430 | };
|
18431 |
|
18432 | Color.prototype.toString = Color.prototype.toRGB;
|
18433 |
|
18434 | Color.hex = function(hex){
|
18435 | return new Color(hex, 'hex');
|
18436 | };
|
18437 |
|
18438 | if (commonjsGlobal.hex == null) commonjsGlobal.hex = Color.hex;
|
18439 |
|
18440 | Color.hsb = function(h, s, b, a){
|
18441 | return new Color([h || 0, s || 0, b || 0, (a == null) ? 1 : a], 'hsb');
|
18442 | };
|
18443 |
|
18444 | if (commonjsGlobal.hsb == null) commonjsGlobal.hsb = Color.hsb;
|
18445 |
|
18446 | Color.hsl = function(h, s, l, a){
|
18447 | return new Color([h || 0, s || 0, l || 0, (a == null) ? 1 : a], 'hsl');
|
18448 | };
|
18449 |
|
18450 | if (commonjsGlobal.hsl == null) commonjsGlobal.hsl = Color.hsl;
|
18451 |
|
18452 | Color.rgb = function(r, g, b, a){
|
18453 | return new Color([r || 0, g || 0, b || 0, (a == null) ? 1 : a], 'rgb');
|
18454 | };
|
18455 |
|
18456 | if (commonjsGlobal.rgb == null) commonjsGlobal.rgb = Color.rgb;
|
18457 |
|
18458 | Color.detach = function(color){
|
18459 | color = new Color(color);
|
18460 | return [Color.rgb(color.red, color.green, color.blue).toString(), color.alpha];
|
18461 | };
|
18462 |
|
18463 | var color = Color;
|
18464 |
|
18465 | var dummy = _class({
|
18466 |
|
18467 |
|
18468 |
|
18469 | _resetPlacement: function(){
|
18470 | var container = this.parentNode;
|
18471 | if (container){
|
18472 | var previous = this.previousSibling, next = this.nextSibling;
|
18473 | if (previous){
|
18474 | previous.nextSibling = next;
|
18475 | } else {
|
18476 | container.firstChild = next;
|
18477 | }
|
18478 | if (next){
|
18479 | next.previousSibling = previous;
|
18480 | } else {
|
18481 | container.lastChild = this.previousSibling;
|
18482 | }
|
18483 | }
|
18484 | this.previousSibling = null;
|
18485 | this.nextSibling = null;
|
18486 | this.parentNode = null;
|
18487 | return this;
|
18488 | },
|
18489 |
|
18490 | inject: function(container){
|
18491 | this._resetPlacement();
|
18492 | var last = container.lastChild;
|
18493 | if (last){
|
18494 | last.nextSibling = this;
|
18495 | this.previousSibling = last;
|
18496 | } else {
|
18497 | container.firstChild = this;
|
18498 | }
|
18499 | container.lastChild = this;
|
18500 | this.parentNode = container;
|
18501 | this._place();
|
18502 | return this;
|
18503 | },
|
18504 |
|
18505 | injectBefore: function(sibling){
|
18506 | this._resetPlacement();
|
18507 | var container = sibling.parentNode;
|
18508 | if (!container) return this;
|
18509 | var previous = sibling.previousSibling;
|
18510 | if (previous){
|
18511 | previous.nextSibling = this;
|
18512 | this.previousSibling = previous;
|
18513 | } else {
|
18514 | container.firstChild = this;
|
18515 | }
|
18516 | sibling.previousSibling = this;
|
18517 | this.nextSibling = sibling;
|
18518 | this.parentNode = container;
|
18519 | this._place();
|
18520 | return this;
|
18521 | },
|
18522 |
|
18523 | eject: function(){
|
18524 | this._resetPlacement();
|
18525 | this._place();
|
18526 | return this;
|
18527 | },
|
18528 |
|
18529 | _place: function(){},
|
18530 |
|
18531 |
|
18532 |
|
18533 | dispatch: function(event){
|
18534 | var events = this._events,
|
18535 | listeners = events && events[event.type];
|
18536 | if (listeners){
|
18537 | listeners = listeners.slice(0);
|
18538 | for (var i = 0, l = listeners.length; i < l; i++){
|
18539 | var fn = listeners[i], result;
|
18540 | if (typeof fn == 'function')
|
18541 | result = fn.call(this, event);
|
18542 | else
|
18543 | result = fn.handleEvent(event);
|
18544 | if (result === false) event.preventDefault();
|
18545 | }
|
18546 | }
|
18547 | if (this.parentNode && this.parentNode.dispatch){
|
18548 | this.parentNode.dispatch(event);
|
18549 | }
|
18550 | },
|
18551 |
|
18552 | subscribe: function(type, fn, bind){
|
18553 | if (typeof type != 'string'){
|
18554 | var subscriptions = [];
|
18555 | for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
|
18556 | return function(){
|
18557 | for (var i = 0, l = subscriptions.length; i < l; i++)
|
18558 | subscriptions[i]();
|
18559 | return this;
|
18560 | };
|
18561 | } else {
|
18562 | var bound = typeof fn === 'function' ? fn.bind(bind || this) : fn,
|
18563 | events = this._events || (this._events = {}),
|
18564 | listeners = events[type] || (events[type] = []);
|
18565 | listeners.push(bound);
|
18566 | return function(){
|
18567 |
|
18568 | for (var i = 0, l = listeners.length; i < l; i++){
|
18569 | if (listeners[i] === bound){
|
18570 | listeners.splice(i, 1);
|
18571 | break;
|
18572 | }
|
18573 | }
|
18574 | }
|
18575 | }
|
18576 | }
|
18577 |
|
18578 | });
|
18579 |
|
18580 | var CanvasNode = _class(transform, dummy, {
|
18581 |
|
18582 | invalidate: function(){
|
18583 | if (this.parentNode) this.parentNode.invalidate();
|
18584 | if (this._layer) this._layerCache = null;
|
18585 | return this;
|
18586 | },
|
18587 |
|
18588 | _place: function(){
|
18589 | this.invalidate();
|
18590 | },
|
18591 |
|
18592 | _transform: function(){
|
18593 | this.invalidate();
|
18594 | },
|
18595 |
|
18596 | blend: function(opacity){
|
18597 | if (opacity >= 1 && this._layer) this._layer = null;
|
18598 | this._opacity = opacity;
|
18599 | if (this.parentNode) this.parentNode.invalidate();
|
18600 | return this;
|
18601 | },
|
18602 |
|
18603 |
|
18604 |
|
18605 | hide: function(){
|
18606 | this._invisible = true;
|
18607 | if (this.parentNode) this.parentNode.invalidate();
|
18608 | return this;
|
18609 | },
|
18610 |
|
18611 | show: function(){
|
18612 | this._invisible = false;
|
18613 | if (this.parentNode) this.parentNode.invalidate();
|
18614 | return this;
|
18615 | },
|
18616 |
|
18617 |
|
18618 |
|
18619 | indicate: function(cursor, tooltip){
|
18620 | this._cursor = cursor;
|
18621 | this._tooltip = tooltip;
|
18622 | return this.invalidate();
|
18623 | },
|
18624 |
|
18625 | hitTest: function(x, y){
|
18626 | if (this._invisible) return null;
|
18627 | var point = this.inversePoint(x, y);
|
18628 | if (!point) return null;
|
18629 | return this.localHitTest(point.x, point.y);
|
18630 | },
|
18631 |
|
18632 |
|
18633 |
|
18634 | renderTo: function(context, xx, yx, xy, yy, x, y){
|
18635 | var opacity = this._opacity;
|
18636 | if (opacity == null || opacity >= 1){
|
18637 | return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
18638 | }
|
18639 |
|
18640 |
|
18641 |
|
18642 | var layer = this._layer, canvas, isDirty = true,
|
18643 | w = context.canvas.width, h = context.canvas.height;
|
18644 | if (layer){
|
18645 | layer.setTransform(1, 0, 0, 1, 0, 0);
|
18646 | canvas = layer.canvas;
|
18647 | if (canvas.width < w || canvas.height < h){
|
18648 | canvas.width = w;
|
18649 | canvas.height = h;
|
18650 | } else {
|
18651 | var c = this._layerCache;
|
18652 | if (c && c.xx === xx && c.yx === yx && c.xy === xy
|
18653 | && c.yy === yy && c.x === x && c.y === y){
|
18654 | isDirty = false;
|
18655 | } else {
|
18656 | layer.clearRect(0, 0, w, h);
|
18657 | }
|
18658 | }
|
18659 | } else {
|
18660 | canvas = document.createElement('canvas');
|
18661 | canvas.width = w;
|
18662 | canvas.height = h;
|
18663 | this._layer = layer = canvas.getContext('2d');
|
18664 | }
|
18665 |
|
18666 | if (isDirty){
|
18667 | this.renderLayerTo(layer, xx, yx, xy, yy, x, y);
|
18668 | this._layerCache = {
|
18669 | xx: xx,
|
18670 | yx: yx,
|
18671 | xy: xy,
|
18672 | yy: yy,
|
18673 | x: x,
|
18674 | y: y
|
18675 | };
|
18676 | }
|
18677 |
|
18678 | context.globalAlpha = opacity;
|
18679 | context.setTransform(1, 0, 0, 1, 0, 0);
|
18680 | context.drawImage(
|
18681 | canvas,
|
18682 | 0, 0, w, h,
|
18683 | 0, 0, w, h
|
18684 | );
|
18685 | context.globalAlpha = 1;
|
18686 | }
|
18687 |
|
18688 | });
|
18689 |
|
18690 | var node = CanvasNode;
|
18691 |
|
18692 | var genericCanvas = typeof document !== 'undefined' && document.createElement('canvas');
|
18693 | var genericContext = genericCanvas && genericCanvas.getContext && genericCanvas.getContext('2d');
|
18694 |
|
18695 | function recolorImage(img, color1, color2){
|
18696 |
|
18697 | color1 = color.detach(color1);
|
18698 | color2 = color.detach(color2);
|
18699 | var canvas = document.createElement('canvas'),
|
18700 | context = canvas.getContext('2d');
|
18701 | canvas.width = img.width;
|
18702 | canvas.height = img.height;
|
18703 | context.fillStyle = color2[0];
|
18704 | context.fillRect(0, 0, img.width, img.height);
|
18705 | context.globalCompositeOperation = 'lighter';
|
18706 | context.drawImage(img, 0, 0);
|
18707 | return canvas;
|
18708 | }
|
18709 |
|
18710 | var Base = _class(node, {
|
18711 |
|
18712 | initialize: function(){
|
18713 | this._fill = null;
|
18714 | this._pendingFill = null;
|
18715 | this._fillTransform = null;
|
18716 | this._stroke = null;
|
18717 | this._strokeCap = null;
|
18718 | this._strokeDash = null;
|
18719 | this._strokeJoin = null;
|
18720 | this._strokeWidth = null;
|
18721 | },
|
18722 |
|
18723 |
|
18724 |
|
18725 | _addColors: function(gradient, stops){
|
18726 |
|
18727 |
|
18728 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++)
|
18729 | gradient.addColorStop(i / l, new color(stops[i]).toString());
|
18730 | else for (var offset in stops)
|
18731 | gradient.addColorStop(offset, new color(stops[offset]).toString());
|
18732 | return gradient;
|
18733 | },
|
18734 |
|
18735 |
|
18736 | fill: function(color$$1){
|
18737 | if (arguments.length > 1) return this.fillLinear(arguments);
|
18738 | if (this._pendingFill) this._pendingFill();
|
18739 | this._fill = color$$1 ? new color(color$$1).toString() : null;
|
18740 | return this.invalidate();
|
18741 | },
|
18742 |
|
18743 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
18744 | if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
|
18745 | if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
|
18746 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
|
18747 | if (radiusX == null) radiusX = (this.width || 0) * 0.5;
|
18748 | if (centerX == null) centerX = focusX;
|
18749 | if (centerY == null) centerY = focusY;
|
18750 |
|
18751 | centerX += centerX - focusX;
|
18752 | centerY += centerY - focusY;
|
18753 |
|
18754 | if (radiusX === 0 || radiusX === '0') return this.fillLinear(stops);
|
18755 | var ys = radiusY / radiusX;
|
18756 |
|
18757 | if (this._pendingFill) this._pendingFill();
|
18758 |
|
18759 | var gradient = genericContext.createRadialGradient(focusX, focusY / ys, 0, centerX, centerY / ys, radiusX * 2);
|
18760 |
|
18761 |
|
18762 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++){
|
18763 | gradient.addColorStop(i / l / 2, new color(stops[i]).toString());
|
18764 | gradient.addColorStop(1 - i / l / 2, new color(stops[i]).toString());
|
18765 | } else for (var offset in stops){
|
18766 | gradient.addColorStop(offset / 2, new color(stops[offset]).toString());
|
18767 | gradient.addColorStop(1- offset / 2, new color(stops[offset]).toString());
|
18768 | }
|
18769 |
|
18770 | this._fill = gradient;
|
18771 | this._fillTransform = new transform(1, 0, 0, ys);
|
18772 | return this.invalidate();
|
18773 | },
|
18774 |
|
18775 | fillLinear: function(stops, x1, y1, x2, y2){
|
18776 | if (arguments.length < 5){
|
18777 | var angle = ((x1 == null) ? 270 : x1) * Math.PI / 180;
|
18778 |
|
18779 | var x = Math.cos(angle), y = -Math.sin(angle),
|
18780 | l = (Math.abs(x) + Math.abs(y)) / 2,
|
18781 | w = this.width || 1, h = this.height || 1;
|
18782 |
|
18783 | x *= l; y *= l;
|
18784 |
|
18785 | x1 = 0.5 - x;
|
18786 | x2 = 0.5 + x;
|
18787 | y1 = 0.5 - y;
|
18788 | y2 = 0.5 + y;
|
18789 | this._fillTransform = new transform(w, 0, 0, h);
|
18790 | } else {
|
18791 | this._fillTransform = null;
|
18792 | }
|
18793 | if (this._pendingFill) this._pendingFill();
|
18794 | var gradient = genericContext.createLinearGradient(x1, y1, x2, y2);
|
18795 | this._addColors(gradient, stops);
|
18796 | this._fill = gradient;
|
18797 | return this.invalidate();
|
18798 | },
|
18799 |
|
18800 | fillImage: function(url, width, height, left, top, color1, color2){
|
18801 | if (this._pendingFill) this._pendingFill();
|
18802 | var img = url;
|
18803 | if (!(img instanceof Image)){
|
18804 | img = new Image();
|
18805 | img.src = url;
|
18806 | }
|
18807 | if (img.width && img.height){
|
18808 | return this._fillImage(img, width, height, left || 0, top || 0, color1, color2);
|
18809 | }
|
18810 |
|
18811 |
|
18812 | this._fill = null;
|
18813 | var self = this,
|
18814 | callback = function(){
|
18815 | cancel();
|
18816 | self._fillImage(img, width, height, left || 0, top || 0, color1, color2);
|
18817 | },
|
18818 | cancel = function(){
|
18819 | img.removeEventListener('load', callback, false);
|
18820 | self._pendingFill = null;
|
18821 | };
|
18822 | this._pendingFill = cancel;
|
18823 | img.addEventListener('load', callback, false);
|
18824 | return this;
|
18825 | },
|
18826 |
|
18827 | _fillImage: function(img, width, height, left, top, color1, color2){
|
18828 | var w = width ? width / img.width : 1,
|
18829 | h = height ? height / img.height : 1;
|
18830 | if (color1 != null) img = recolorImage(img, color1, color2);
|
18831 | this._fill = genericContext.createPattern(img, 'repeat');
|
18832 | this._fillTransform = new transform(w, 0, 0, h, left || 0, top || 0);
|
18833 | return this.invalidate();
|
18834 | },
|
18835 |
|
18836 | stroke: function(color$$1, width, cap, join, dash){
|
18837 | this._stroke = color$$1 ? new color(color$$1).toString() : null;
|
18838 | this._strokeWidth = (width != null) ? width : 1;
|
18839 | this._strokeCap = (cap != null) ? cap : 'round';
|
18840 | this._strokeJoin = (join != null) ? join : 'round';
|
18841 | this._strokeDash = dash;
|
18842 | return this.invalidate();
|
18843 | },
|
18844 |
|
18845 |
|
18846 |
|
18847 | element_renderTo: node.prototype.renderTo,
|
18848 |
|
18849 | renderTo: function(context, xx, yx, xy, yy, x, y){
|
18850 | var opacity = this._opacity;
|
18851 | if (opacity == null || opacity >= 1){
|
18852 | return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
18853 | }
|
18854 | if (this._fill && this._stroke){
|
18855 | return this.element_renderTo(context, xx, yx, xy, yy, x, y);
|
18856 | }
|
18857 | context.globalAlpha = opacity;
|
18858 | var r = this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
18859 | context.globalAlpha = 1;
|
18860 | return r;
|
18861 | },
|
18862 |
|
18863 | renderLayerTo: function(context, xx, yx, xy, yy, x, y){
|
18864 | context.setTransform(xx, yx, xy, yy, x, y);
|
18865 | this.renderShapeTo(context);
|
18866 | }
|
18867 |
|
18868 | });
|
18869 |
|
18870 | Base._genericContext = genericContext;
|
18871 |
|
18872 | var base = Base;
|
18873 |
|
18874 | var shape = _class(base, {
|
18875 |
|
18876 | base_initialize: base.prototype.initialize,
|
18877 |
|
18878 | initialize: function(path$$1, width, height){
|
18879 | this.base_initialize();
|
18880 | this.width = width;
|
18881 | this.height = height;
|
18882 | if (path$$1 != null) this.draw(path$$1);
|
18883 | },
|
18884 |
|
18885 | draw: function(path$$1, width, height){
|
18886 | if (!(path$$1 instanceof path)) path$$1 = new path(path$$1);
|
18887 | this.path = path$$1;
|
18888 | this._commands = path$$1.toCommands();
|
18889 | if (width != null) this.width = width;
|
18890 | if (height != null) this.height = height;
|
18891 | return this.invalidate();
|
18892 | },
|
18893 |
|
18894 | localHitTest: function(x, y){
|
18895 | if (!this._fill) return null;
|
18896 | if (this.width == null || this.height == null){
|
18897 | var context = base._genericContext, commands = this._commands;
|
18898 | if (!commands) return null;
|
18899 | context.beginPath();
|
18900 | for (var i = 0, l = commands.length; i < l; i++)
|
18901 | commands[i](context);
|
18902 | return context.isPointInPath(x, y) ? this : null;
|
18903 | }
|
18904 | if (x > 0 && y > 0 && x < this.width && y < this.height){
|
18905 | return this;
|
18906 | }
|
18907 | return null;
|
18908 | },
|
18909 |
|
18910 | renderShapeTo: function(context){
|
18911 | if (this._invisible || !this._commands || (!this._fill && !this._stroke)) {
|
18912 | return null;
|
18913 | }
|
18914 | context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
|
18915 | var commands = this._commands,
|
18916 | fill = this._fill,
|
18917 | stroke = this._stroke,
|
18918 | dash = this._strokeDash;
|
18919 |
|
18920 | context.beginPath();
|
18921 |
|
18922 | if (dash) {
|
18923 | if (context.setLineDash) {
|
18924 | context.setLineDash(dash);
|
18925 | } else {
|
18926 |
|
18927 | context.mozDash = dash;
|
18928 | }
|
18929 |
|
18930 | } else {
|
18931 | if (context.setLineDash) {
|
18932 | context.setLineDash([]);
|
18933 | } else {
|
18934 | context.mozDash = null;
|
18935 | }
|
18936 | }
|
18937 |
|
18938 | for (var i = 0, l = commands.length; i < l; i++)
|
18939 | commands[i](context);
|
18940 |
|
18941 | if (fill){
|
18942 | var m = this._fillTransform;
|
18943 | if (m){
|
18944 | context.save();
|
18945 | context.transform(m.xx, m.yx, m.xy, m.yy, m.x, m.y);
|
18946 | context.fillStyle = fill;
|
18947 | context.fill();
|
18948 | context.restore();
|
18949 | } else {
|
18950 | context.fillStyle = fill;
|
18951 | context.fill();
|
18952 | }
|
18953 | }
|
18954 | if (stroke){
|
18955 | context.strokeStyle = stroke;
|
18956 | context.lineWidth = this._strokeWidth;
|
18957 | context.lineCap = this._strokeCap;
|
18958 | context.lineJoin = this._strokeJoin;
|
18959 | context.stroke();
|
18960 | }
|
18961 | }
|
18962 |
|
18963 | });
|
18964 |
|
18965 | var group = _class(node, container, {
|
18966 |
|
18967 | initialize: function(width, height){
|
18968 | this.width = width;
|
18969 | this.height = height;
|
18970 | },
|
18971 |
|
18972 | localHitTest: function(x, y){
|
18973 | var node$$2 = this.lastChild;
|
18974 | while (node$$2){
|
18975 | var hit = node$$2.hitTest(x, y);
|
18976 | if (hit) return hit;
|
18977 | node$$2 = node$$2.previousSibling;
|
18978 | }
|
18979 | return null;
|
18980 | },
|
18981 |
|
18982 | renderLayerTo: function(context, xx, yx, xy, yy, x, y){
|
18983 | if (this._invisible) return;
|
18984 |
|
18985 | x = xx * this.x + xy * this.y + x;
|
18986 | y = yx * this.x + yy * this.y + y;
|
18987 |
|
18988 | var t = xx;
|
18989 | xx = t * this.xx + xy * this.yx;
|
18990 | xy = t * this.xy + xy * this.yy;
|
18991 | t = yx;
|
18992 | yx = t * this.xx + yy * this.yx;
|
18993 | yy = t * this.xy + yy * this.yy;
|
18994 |
|
18995 | var node$$2 = this.firstChild;
|
18996 | while (node$$2){
|
18997 | node$$2.renderTo(context, xx, yx, xy, yy, x, y);
|
18998 | node$$2 = node$$2.nextSibling;
|
18999 | }
|
19000 | }
|
19001 |
|
19002 | });
|
19003 |
|
19004 | var clippingrectangle = _class(node, container, {
|
19005 |
|
19006 | initialize: function(width, height){
|
19007 | this.width = width;
|
19008 | this.height = height;
|
19009 | },
|
19010 |
|
19011 | localHitTest: function(x, y) {
|
19012 | var node$$2 = this.lastChild;
|
19013 | while (node$$2){
|
19014 | var hit = node$$2.hitTest(x, y);
|
19015 | if (hit) return hit;
|
19016 | node$$2 = node$$2.previousSibling;
|
19017 | }
|
19018 | return null;
|
19019 | },
|
19020 |
|
19021 | renderLayerTo: function(context, xx, yx, xy, yy, x, y) {
|
19022 | context.setTransform(xx, yx, xy, yy, x, y);
|
19023 | context.save();
|
19024 |
|
19025 | context.beginPath();
|
19026 | context.rect(this.x, this.y, this.width, this.height);
|
19027 | context.clip();
|
19028 |
|
19029 | var node$$2 = this.firstChild;
|
19030 | while(node$$2) {
|
19031 | node$$2.renderTo(context, xx, yx, xy, yy, x, y);
|
19032 | node$$2 = node$$2.nextSibling;
|
19033 | }
|
19034 | context.restore();
|
19035 | }
|
19036 | });
|
19037 |
|
19038 | var fontAnchors = { middle: 'center' };
|
19039 |
|
19040 | var text = _class(base, {
|
19041 |
|
19042 | base_initialize: base.prototype.initialize,
|
19043 |
|
19044 | initialize: function(text, font, alignment, path){
|
19045 | this.base_initialize();
|
19046 | this.draw.apply(this, arguments);
|
19047 | },
|
19048 |
|
19049 | draw: function(text, font, alignment, path){
|
19050 | var em;
|
19051 | if (typeof font == 'string'){
|
19052 | em = Number(/(\d+)/.exec(font)[0]);
|
19053 | } else if (font){
|
19054 | em = parseFloat(font.fontSize || font['font-size'] || '12');
|
19055 | font = (font.fontStyle || font['font-style'] || '') + ' ' +
|
19056 | (font.fontVariant || font['font-variant'] || '') + ' ' +
|
19057 | (font.fontWeight || font['font-weight'] || '') + ' ' +
|
19058 | em + 'px ' +
|
19059 | (font.fontFamily || font['font-family'] || 'Arial');
|
19060 | } else {
|
19061 | font = this._font;
|
19062 | }
|
19063 |
|
19064 | var lines = text && text.split(/\r?\n/);
|
19065 | this._font = font;
|
19066 | this._fontSize = em;
|
19067 | this._text = lines;
|
19068 | this._alignment = fontAnchors[alignment] || alignment || 'left';
|
19069 |
|
19070 | var context = base._genericContext;
|
19071 |
|
19072 | context.font = this._font;
|
19073 | context.textAlign = this._alignment;
|
19074 | context.textBaseline = 'middle';
|
19075 |
|
19076 | lines = this._text;
|
19077 | var l = lines.length, width = 0;
|
19078 | for (var i = 0; i < l; i++){
|
19079 | var w = context.measureText(lines[i]).width;
|
19080 | if (w > width) width = w;
|
19081 | }
|
19082 | this.width = width;
|
19083 | this.height = l ? l * 1.1 * em : 0;
|
19084 | return this.invalidate();
|
19085 | },
|
19086 |
|
19087 |
|
19088 |
|
19089 | localHitTest: function(x, y){
|
19090 | if (!this._fill) return null;
|
19091 | if (x > 0 && y > 0 && x < this.width && y < this.height){
|
19092 | return this;
|
19093 | }
|
19094 | return null;
|
19095 | },
|
19096 |
|
19097 |
|
19098 |
|
19099 | renderShapeTo: function(context){
|
19100 | if (this._invisible || !this._text || (!this._fill && !this._stroke)) {
|
19101 | return null;
|
19102 | }
|
19103 | context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
|
19104 | var fill = this._fill,
|
19105 | stroke = this._stroke,
|
19106 | text = this._text,
|
19107 | dash = this._strokeDash;
|
19108 |
|
19109 | context.font = this._font;
|
19110 | context.textAlign = this._alignment;
|
19111 | context.textBaseline = 'middle';
|
19112 |
|
19113 | var em = this._fontSize,
|
19114 | y = em / 2,
|
19115 | lineHeight = 1.1 * em,
|
19116 | lines = text,
|
19117 | l = lines.length;
|
19118 |
|
19119 | if (fill){
|
19120 | context.fillStyle = fill;
|
19121 | for (var i = 0; i < l; i++)
|
19122 | context.fillText(lines[i], 0, y + i * lineHeight);
|
19123 | }
|
19124 | if (stroke){
|
19125 | if (dash) {
|
19126 | if (context.setLineDash) {
|
19127 | context.setLineDash(dash);
|
19128 | } else {
|
19129 |
|
19130 | context.mozDash = dash;
|
19131 | }
|
19132 |
|
19133 | } else {
|
19134 | if (context.setLineDash) {
|
19135 | context.setLineDash([]);
|
19136 | } else {
|
19137 | context.mozDash = null;
|
19138 | }
|
19139 | }
|
19140 |
|
19141 | context.strokeStyle = stroke;
|
19142 | context.lineWidth = this._strokeWidth;
|
19143 | context.lineCap = this._strokeCap;
|
19144 | context.lineJoin = this._strokeJoin;
|
19145 | for (i = 0; i < l; i++)
|
19146 | context.strokeText(lines[i], 0, y + i * lineHeight);
|
19147 | }
|
19148 | }
|
19149 |
|
19150 | });
|
19151 |
|
19152 | var VMLCSS = 'behavior:url(#default#VML);display:inline-block;position:absolute;left:0px;top:0px;';
|
19153 |
|
19154 | var styleSheet;
|
19155 | var styledTags = {};
|
19156 | var styleTag = function(tag){
|
19157 | if (styleSheet) styledTags[tag] = styleSheet.addRule('av\\:' + tag, VMLCSS);
|
19158 | };
|
19159 |
|
19160 | var init = function(document){
|
19161 |
|
19162 | var namespaces;
|
19163 | try {
|
19164 | namespaces = document.namespaces;
|
19165 | } catch (e) {
|
19166 | }
|
19167 | if (!namespaces) return false;
|
19168 |
|
19169 | namespaces.add('av', 'urn:schemas-microsoft-com:vml');
|
19170 | namespaces.add('ao', 'urn:schemas-microsoft-com:office:office');
|
19171 |
|
19172 | styleSheet = document.createStyleSheet();
|
19173 | styleSheet.addRule('vml', 'display:inline-block;position:relative;overflow:hidden;');
|
19174 |
|
19175 |
|
19176 |
|
19177 |
|
19178 |
|
19179 |
|
19180 |
|
19181 | styleTag('vml');
|
19182 |
|
19183 | return true;
|
19184 |
|
19185 | };
|
19186 |
|
19187 | var createElement = function(tag){
|
19188 | if (!(tag in styledTags)) styleTag(tag);
|
19189 | return document.createElement('av:' + tag);
|
19190 | };
|
19191 |
|
19192 | var dom = {
|
19193 | init: init,
|
19194 | createElement: createElement
|
19195 | };
|
19196 |
|
19197 | var precision = 100;
|
19198 |
|
19199 | var VMLSurface = _class(native_1, container, {
|
19200 |
|
19201 | initialize: function VMLSurface(width, height, existingElement){
|
19202 | this.element = existingElement || document.createElement('vml');
|
19203 | this.containerElement = dom.createElement('group');
|
19204 | this.element.appendChild(this.containerElement);
|
19205 | if (width != null && height != null) this.resize(width, height);
|
19206 | },
|
19207 |
|
19208 | resize: function(width, height){
|
19209 | this.width = width;
|
19210 | this.height = height;
|
19211 |
|
19212 | var style = this.element.style;
|
19213 | style.pixelWidth = width;
|
19214 | style.pixelHeight = height;
|
19215 |
|
19216 | style = this.containerElement.style;
|
19217 | style.width = width;
|
19218 | style.height = height;
|
19219 |
|
19220 | var halfPixel = (0.5 * precision);
|
19221 |
|
19222 | this.containerElement.coordorigin = halfPixel + ',' + halfPixel;
|
19223 | this.containerElement.coordsize = (width * precision) + ',' + (height * precision);
|
19224 |
|
19225 | return this;
|
19226 | }
|
19227 |
|
19228 | });
|
19229 |
|
19230 | VMLSurface.tagName = 'av:vml';
|
19231 |
|
19232 | var surface$2 = VMLSurface;
|
19233 |
|
19234 | var precision$1 = 100;
|
19235 |
|
19236 | var round = Math.round;
|
19237 |
|
19238 | var VMLPath = _class(path$2, {
|
19239 |
|
19240 | initialize: function(path){
|
19241 | this.reset();
|
19242 | if (path instanceof VMLPath){
|
19243 | this.path = [Array.prototype.join.call(path.path, ' ')];
|
19244 | } else if (path){
|
19245 | if (path.applyToPath)
|
19246 | path.applyToPath(this);
|
19247 | else
|
19248 | this.push(path);
|
19249 | }
|
19250 | },
|
19251 |
|
19252 | onReset: function(){
|
19253 | this.path = [];
|
19254 | },
|
19255 |
|
19256 | onMove: function(sx, sy, x, y){
|
19257 | this.path.push('m', round(x * precision$1), round(y * precision$1));
|
19258 | },
|
19259 |
|
19260 | onLine: function(sx, sy, x, y){
|
19261 | this.path.push('l', round(x * precision$1), round(y * precision$1));
|
19262 | },
|
19263 |
|
19264 | onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
|
19265 | this.path.push('c',
|
19266 | round(p1x * precision$1), round(p1y * precision$1),
|
19267 | round(p2x * precision$1), round(p2y * precision$1),
|
19268 | round(x * precision$1), round(y * precision$1)
|
19269 | );
|
19270 | },
|
19271 |
|
19272 | _arcToBezier: path$2.prototype.onArc,
|
19273 |
|
19274 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
19275 | if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
|
19276 | cx *= precision$1;
|
19277 | cy *= precision$1;
|
19278 | rx *= precision$1;
|
19279 | this.path.push(ccw ? 'at' : 'wa',
|
19280 | round(cx - rx), round(cy - rx),
|
19281 | round(cx + rx), round(cy + rx),
|
19282 | round(sx * precision$1), round(sy * precision$1),
|
19283 | round(ex * precision$1), round(ey * precision$1)
|
19284 | );
|
19285 | },
|
19286 |
|
19287 | onClose: function(){
|
19288 | this.path.push('x');
|
19289 | },
|
19290 |
|
19291 | toVML: function(){
|
19292 | return this.path.join(' ');
|
19293 | }
|
19294 |
|
19295 | });
|
19296 |
|
19297 | VMLPath.prototype.toString = VMLPath.prototype.toVML;
|
19298 |
|
19299 | var path$4 = VMLPath;
|
19300 |
|
19301 | var shadow = _class(dummy, native_1, {
|
19302 |
|
19303 | dummy_inject: dummy.prototype.inject,
|
19304 | dummy_injectBefore: dummy.prototype.injectBefore,
|
19305 | dummy_eject: dummy.prototype.eject,
|
19306 | native_inject: native_1.prototype.inject,
|
19307 | native_injectBefore: native_1.prototype.injectBefore,
|
19308 | native_eject: native_1.prototype.eject,
|
19309 |
|
19310 | inject: function(container){
|
19311 | this.dummy_inject(container);
|
19312 | this.native_inject(container);
|
19313 | return this;
|
19314 | },
|
19315 |
|
19316 | injectBefore: function(sibling){
|
19317 | this.dummy_injectBefore(sibling);
|
19318 | this.native_injectBefore(sibling);
|
19319 | return this;
|
19320 | },
|
19321 |
|
19322 | eject: function(){
|
19323 | this.dummy_eject();
|
19324 | this.native_eject();
|
19325 | return this;
|
19326 | }
|
19327 |
|
19328 | });
|
19329 |
|
19330 | var node$2 = _class(shadow, transform, {
|
19331 |
|
19332 | initialize: function(tag){
|
19333 |
|
19334 | var element = this.element = dom.createElement(tag);
|
19335 |
|
19336 | },
|
19337 |
|
19338 | _place: function(){
|
19339 | if (this.parentNode){
|
19340 | this._transform();
|
19341 | }
|
19342 | },
|
19343 |
|
19344 |
|
19345 |
|
19346 | hide: function(){
|
19347 | this.element.style.display = 'none';
|
19348 | return this;
|
19349 | },
|
19350 |
|
19351 | show: function(){
|
19352 | this.element.style.display = '';
|
19353 | return this;
|
19354 | },
|
19355 |
|
19356 |
|
19357 |
|
19358 | indicate: function(cursor, tooltip){
|
19359 | if (cursor) this.element.style.cursor = cursor;
|
19360 | if (tooltip) this.element.title = tooltip;
|
19361 | return this;
|
19362 | }
|
19363 |
|
19364 | });
|
19365 |
|
19366 | var precision$3 = 100;
|
19367 |
|
19368 | var defaultBox = { left: 0, top: 0, width: 500, height: 500 };
|
19369 |
|
19370 | var base$2 = _class(node$2, {
|
19371 |
|
19372 | element_initialize: node$2.prototype.initialize,
|
19373 |
|
19374 | initialize: function(tag){
|
19375 | this.element_initialize(tag);
|
19376 | var element = this.element;
|
19377 |
|
19378 | var skew = this.skewElement = dom.createElement('skew');
|
19379 | skew.on = true;
|
19380 | element.appendChild(skew);
|
19381 |
|
19382 | var fill = this.fillElement = dom.createElement('fill');
|
19383 | fill.on = false;
|
19384 | element.appendChild(fill);
|
19385 |
|
19386 | var stroke = this.strokeElement = dom.createElement('stroke');
|
19387 | stroke.on = false;
|
19388 | element.appendChild(stroke);
|
19389 | },
|
19390 |
|
19391 |
|
19392 |
|
19393 | _transform: function(){
|
19394 | var container = this.parentNode;
|
19395 |
|
19396 |
|
19397 | var m = container ? new transform(container._activeTransform).transform(this) : this;
|
19398 |
|
19399 |
|
19400 |
|
19401 | var box = this._boxCoords || this._size || defaultBox;
|
19402 |
|
19403 | var originX = box.left || 0,
|
19404 | originY = box.top || 0,
|
19405 | width = box.width || 1,
|
19406 | height = box.height || 1;
|
19407 |
|
19408 |
|
19409 | var flip = m.yx / m.xx > m.yy / m.xy;
|
19410 | if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = !flip;
|
19411 | flip = flip ? -1 : 1;
|
19412 |
|
19413 | m = new transform().scale(flip, 1).transform(m);
|
19414 |
|
19415 |
|
19416 | var rotation = Math.atan2(-m.xy, m.yy) * 180 / Math.PI;
|
19417 |
|
19418 |
|
19419 | var rad = rotation * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
|
19420 |
|
19421 | var transform$$2 = new transform(
|
19422 | (m.xx * cos - m.xy * sin),
|
19423 | (m.yx * cos - m.yy * sin) * flip,
|
19424 | (m.xy * cos + m.xx * sin) * flip,
|
19425 | (m.yy * cos + m.yx * sin)
|
19426 | );
|
19427 |
|
19428 | var rotationTransform = new transform().rotate(rotation, 0, 0);
|
19429 |
|
19430 | var shapeToBox = new transform().rotate(-rotation, 0, 0).transform(m).moveTo(0,0);
|
19431 |
|
19432 |
|
19433 | width *= Math.abs(shapeToBox.xx);
|
19434 | height *= Math.abs(shapeToBox.yy);
|
19435 |
|
19436 |
|
19437 | var left = m.x, top = m.y;
|
19438 |
|
19439 |
|
19440 | var vx = -width / 2, vy = -height / 2;
|
19441 | var point = rotationTransform.point(vx, vy);
|
19442 | left -= point.x - vx;
|
19443 | top -= point.y - vy;
|
19444 |
|
19445 |
|
19446 | var rsm = new transform(m).moveTo(0,0);
|
19447 | point = rsm.point(originX, originY);
|
19448 | left += point.x;
|
19449 | top += point.y;
|
19450 |
|
19451 | if (flip < 0) left = -left - width;
|
19452 |
|
19453 |
|
19454 | var point0 = rsm.point(-originX, -originY);
|
19455 | var point1 = rotationTransform.point(width, height);
|
19456 | var point2 = rotationTransform.point(width, 0);
|
19457 | var point3 = rotationTransform.point(0, height);
|
19458 |
|
19459 | var minX = Math.min(0, point1.x, point2.x, point3.x),
|
19460 | maxX = Math.max(0, point1.x, point2.x, point3.x),
|
19461 | minY = Math.min(0, point1.y, point2.y, point3.y),
|
19462 | maxY = Math.max(0, point1.y, point2.y, point3.y);
|
19463 |
|
19464 | var transformOriginX = (point0.x - point1.x / 2) / (maxX - minX) * flip,
|
19465 | transformOriginY = (point0.y - point1.y / 2) / (maxY - minY);
|
19466 |
|
19467 |
|
19468 | point = shapeToBox.point(originX, originY);
|
19469 | originX = point.x;
|
19470 | originY = point.y;
|
19471 |
|
19472 |
|
19473 | var strokeWidth = this._strokeWidth;
|
19474 | if (strokeWidth){
|
19475 |
|
19476 |
|
19477 | var vx = m.xx + m.xy, vy = m.yy + m.yx;
|
19478 | strokeWidth *= Math.sqrt(vx * vx + vy * vy) / Math.sqrt(2);
|
19479 | }
|
19480 |
|
19481 |
|
19482 | originX *= precision$3;
|
19483 | originY *= precision$3;
|
19484 | left *= precision$3;
|
19485 | top *= precision$3;
|
19486 | width *= precision$3;
|
19487 | height *= precision$3;
|
19488 |
|
19489 |
|
19490 | var element = this.element;
|
19491 | element.coordorigin = originX + ',' + originY;
|
19492 | element.coordsize = width + ',' + height;
|
19493 | element.style.left = left + 'px';
|
19494 | element.style.top = top + 'px';
|
19495 | element.style.width = width;
|
19496 | element.style.height = height;
|
19497 | element.style.rotation = rotation.toFixed(8);
|
19498 | element.style.flip = flip < 0 ? 'x' : '';
|
19499 |
|
19500 |
|
19501 | var skew = this.skewElement;
|
19502 | skew.matrix = [transform$$2.xx.toFixed(4), transform$$2.xy.toFixed(4), transform$$2.yx.toFixed(4), transform$$2.yy.toFixed(4), 0, 0];
|
19503 | skew.origin = transformOriginX + ',' + transformOriginY;
|
19504 |
|
19505 |
|
19506 | this.strokeElement.weight = strokeWidth + 'px';
|
19507 | },
|
19508 |
|
19509 |
|
19510 |
|
19511 | _createGradient: function(style, stops){
|
19512 | var fill = this.fillElement;
|
19513 |
|
19514 |
|
19515 | this.element.removeChild(fill);
|
19516 |
|
19517 | fill.type = style;
|
19518 | fill.method = 'none';
|
19519 | fill.rotate = true;
|
19520 |
|
19521 | var colors = [], color1, color2;
|
19522 |
|
19523 | var addColor = function(offset, color$$2){
|
19524 | color$$2 = color.detach(color$$2);
|
19525 | if (color1 == null) color1 = color2 = color$$2;
|
19526 | else color2 = color$$2;
|
19527 | colors.push(offset + ' ' + color$$2[0]);
|
19528 | };
|
19529 |
|
19530 |
|
19531 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++) addColor(i / l, stops[i]);
|
19532 | else for (var offset in stops) addColor(offset, stops[offset]);
|
19533 |
|
19534 | fill.color = color1[0];
|
19535 | fill.color2 = color2[0];
|
19536 |
|
19537 |
|
19538 | fill.colors = colors;
|
19539 |
|
19540 |
|
19541 | fill.opacity = color2[1];
|
19542 | fill['ao:opacity2'] = color1[1];
|
19543 |
|
19544 | fill.on = true;
|
19545 | this.element.appendChild(fill);
|
19546 | return fill;
|
19547 | },
|
19548 |
|
19549 | _setColor: function(type, color$$2){
|
19550 | var element = type == 'fill' ? this.fillElement : this.strokeElement;
|
19551 | if (color$$2 == null){
|
19552 | element.on = false;
|
19553 | } else {
|
19554 | color$$2 = color.detach(color$$2);
|
19555 | element.color = color$$2[0];
|
19556 | element.opacity = color$$2[1];
|
19557 | element.on = true;
|
19558 | }
|
19559 | },
|
19560 |
|
19561 | fill: function(color$$2){
|
19562 | if (arguments.length > 1){
|
19563 | this.fillLinear(arguments);
|
19564 | } else {
|
19565 | this._boxCoords = defaultBox;
|
19566 | var fill = this.fillElement;
|
19567 | fill.type = 'solid';
|
19568 | fill.color2 = '';
|
19569 | fill['ao:opacity2'] = '';
|
19570 | if (fill.colors) fill.colors.value = '';
|
19571 | this._setColor('fill', color$$2);
|
19572 | }
|
19573 | return this;
|
19574 | },
|
19575 |
|
19576 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
19577 | var fill = this._createGradient('gradientradial', stops);
|
19578 | if (focusX == null) focusX = this.left + this.width * 0.5;
|
19579 | if (focusY == null) focusY = this.top + this.height * 0.5;
|
19580 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5);
|
19581 | if (radiusX == null) radiusX = this.width * 0.5;
|
19582 | if (centerX == null) centerX = focusX;
|
19583 | if (centerY == null) centerY = focusY;
|
19584 |
|
19585 | centerX += centerX - focusX;
|
19586 | centerY += centerY - focusY;
|
19587 |
|
19588 | var box = this._boxCoords = {
|
19589 | left: centerX - radiusX * 2,
|
19590 | top: centerY - radiusY * 2,
|
19591 | width: radiusX * 4,
|
19592 | height: radiusY * 4
|
19593 | };
|
19594 | focusX -= box.left;
|
19595 | focusY -= box.top;
|
19596 | focusX /= box.width;
|
19597 | focusY /= box.height;
|
19598 |
|
19599 | fill.focussize = '0 0';
|
19600 | fill.focusposition = focusX + ',' + focusY;
|
19601 | fill.focus = '50%';
|
19602 |
|
19603 | this._transform();
|
19604 |
|
19605 | return this;
|
19606 | },
|
19607 |
|
19608 | fillLinear: function(stops, x1, y1, x2, y2){
|
19609 | var fill = this._createGradient('gradient', stops);
|
19610 | fill.focus = '100%';
|
19611 | if (arguments.length == 5){
|
19612 | var w = Math.abs(x2 - x1), h = Math.abs(y2 - y1);
|
19613 | this._boxCoords = {
|
19614 | left: Math.min(x1, x2),
|
19615 | top: Math.min(y1, y2),
|
19616 | width: w < 1 ? h : w,
|
19617 | height: h < 1 ? w : h
|
19618 | };
|
19619 | fill.angle = (360 + Math.atan2((x2 - x1) / h, (y2 - y1) / w) * 180 / Math.PI) % 360;
|
19620 | } else {
|
19621 | this._boxCoords = null;
|
19622 | fill.angle = (x1 == null) ? 0 : (90 + x1) % 360;
|
19623 | }
|
19624 | this._transform();
|
19625 | return this;
|
19626 | },
|
19627 |
|
19628 | fillImage: function(url, width, height, left, top, color1, color2){
|
19629 | var fill = this.fillElement;
|
19630 | if (color1 != null){
|
19631 | color1 = color.detach(color1);
|
19632 | if (color2 != null) color2 = color.detach(color2);
|
19633 | fill.type = 'pattern';
|
19634 | fill.color = color1[0];
|
19635 | fill.color2 = color2 == null ? color1[0] : color2[0];
|
19636 | fill.opacity = color2 == null ? 0 : color2[1];
|
19637 | fill['ao:opacity2'] = color1[1];
|
19638 | } else {
|
19639 | fill.type = 'tile';
|
19640 | fill.color = '';
|
19641 | fill.color2 = '';
|
19642 | fill.opacity = 1;
|
19643 | fill['ao:opacity2'] = 1;
|
19644 | }
|
19645 | if (fill.colors) fill.colors.value = '';
|
19646 | fill.rotate = true;
|
19647 | fill.src = url;
|
19648 |
|
19649 | fill.size = '1,1';
|
19650 | fill.position = '0,0';
|
19651 | fill.origin = '0,0';
|
19652 | fill.aspect = 'ignore';
|
19653 | fill.on = true;
|
19654 |
|
19655 | if (!left) left = 0;
|
19656 | if (!top) top = 0;
|
19657 | this._boxCoords = width ? { left: left + 0.5, top: top + 0.5, width: width, height: height } : null;
|
19658 | this._transform();
|
19659 | return this;
|
19660 | },
|
19661 |
|
19662 |
|
19663 |
|
19664 | stroke: function(color$$2, width, cap, join){
|
19665 | var stroke = this.strokeElement;
|
19666 | this._strokeWidth = (width != null) ? width : 1;
|
19667 | stroke.weight = (width != null) ? width + 'px' : 1;
|
19668 | stroke.endcap = (cap != null) ? ((cap == 'butt') ? 'flat' : cap) : 'round';
|
19669 | stroke.joinstyle = (join != null) ? join : 'round';
|
19670 |
|
19671 | this._setColor('stroke', color$$2);
|
19672 | return this;
|
19673 | }
|
19674 |
|
19675 | });
|
19676 |
|
19677 | var precision$2 = 100;
|
19678 |
|
19679 | var shape$2 = _class(base$2, {
|
19680 |
|
19681 | base_initialize: base$2.prototype.initialize,
|
19682 |
|
19683 | initialize: function(path, width, height){
|
19684 | this.base_initialize('shape');
|
19685 |
|
19686 | var p = this.pathElement = dom.createElement('path');
|
19687 | p.gradientshapeok = true;
|
19688 | this.element.appendChild(p);
|
19689 |
|
19690 | this.width = width;
|
19691 | this.height = height;
|
19692 |
|
19693 | if (path != null) this.draw(path);
|
19694 | },
|
19695 |
|
19696 |
|
19697 |
|
19698 | draw: function(path, width, height){
|
19699 |
|
19700 | if (!(path instanceof path$4)) path = new path$4(path);
|
19701 | this._vml = path.toVML();
|
19702 |
|
19703 |
|
19704 | if (width != null) this.width = width;
|
19705 | if (height != null) this.height = height;
|
19706 |
|
19707 | if (!this._boxCoords) this._transform();
|
19708 | this._redraw(this._prefix, this._suffix);
|
19709 |
|
19710 | return this;
|
19711 | },
|
19712 |
|
19713 |
|
19714 |
|
19715 | _redraw: function(prefix, suffix){
|
19716 | var vml = this._vml || '';
|
19717 |
|
19718 | this._prefix = prefix;
|
19719 | this._suffix = suffix;
|
19720 | if (prefix){
|
19721 | vml = [
|
19722 | prefix, vml, suffix,
|
19723 |
|
19724 | 'ns e', vml, 'nf'
|
19725 | ].join(' ');
|
19726 | }
|
19727 |
|
19728 | this.element.path = vml + 'e';
|
19729 | },
|
19730 |
|
19731 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
19732 | var fill = this._createGradient('gradientradial', stops);
|
19733 | if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
|
19734 | if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
|
19735 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
|
19736 | if (radiusX == null) radiusX = (this.width || 0) * 0.5;
|
19737 | if (centerX == null) centerX = focusX;
|
19738 | if (centerY == null) centerY = focusY;
|
19739 |
|
19740 | centerX += centerX - focusX;
|
19741 | centerY += centerY - focusY;
|
19742 |
|
19743 | var cx = Math.round(centerX * precision$2),
|
19744 | cy = Math.round(centerY * precision$2),
|
19745 |
|
19746 | rx = Math.round(radiusX * 2 * precision$2),
|
19747 | ry = Math.round(radiusY * 2 * precision$2),
|
19748 |
|
19749 | arc = ['wa', cx - rx, cy - ry, cx + rx, cy + ry].join(' ');
|
19750 |
|
19751 | this._redraw(
|
19752 |
|
19753 | ['m', cx, cy - ry, 'l', cx, cy - ry].join(' '),
|
19754 |
|
19755 | [
|
19756 | 'm', cx, cy - ry,
|
19757 | arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry,
|
19758 | arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry
|
19759 | ].join(' ')
|
19760 | );
|
19761 |
|
19762 | this._boxCoords = { left: focusX - 2, top: focusY - 2, width: 4, height: 4 };
|
19763 |
|
19764 | fill.focusposition = '0.5,0.5';
|
19765 | fill.focussize = '0 0';
|
19766 | fill.focus = '50%';
|
19767 |
|
19768 | this._transform();
|
19769 |
|
19770 | return this;
|
19771 | }
|
19772 |
|
19773 | });
|
19774 |
|
19775 | var group$2 = _class(node$2, container, {
|
19776 |
|
19777 | element_initialize: node$2.prototype.initialize,
|
19778 |
|
19779 | initialize: function(width, height){
|
19780 | this.element_initialize('group');
|
19781 | this.width = width;
|
19782 | this.height = height;
|
19783 | },
|
19784 |
|
19785 | _transform: function(){
|
19786 | var element = this.element;
|
19787 | element.coordorigin = '0,0';
|
19788 | element.coordsize = '1000,1000';
|
19789 | element.style.left = 0;
|
19790 | element.style.top = 0;
|
19791 | element.style.width = 1000;
|
19792 | element.style.height = 1000;
|
19793 | element.style.rotation = 0;
|
19794 |
|
19795 | var container$$2 = this.parentNode;
|
19796 | this._activeTransform = container$$2 ? new transform(container$$2._activeTransform).transform(this) : this;
|
19797 | var node = this.firstChild;
|
19798 | while (node){
|
19799 | node._transform();
|
19800 | node = node.nextSibling;
|
19801 | }
|
19802 | }
|
19803 |
|
19804 | });
|
19805 |
|
19806 | var clippingrectangle$2 = _class(node$2, container, {
|
19807 |
|
19808 | element_initialize: node$2.prototype.initialize,
|
19809 |
|
19810 | initialize: function(width, height){
|
19811 | this.element_initialize('clippingrectangle');
|
19812 | this.width = width;
|
19813 | this.height = height;
|
19814 | },
|
19815 |
|
19816 | _transform: function(){
|
19817 | var element = this.element;
|
19818 | element.clip = true;
|
19819 | element.coordorigin = -this.x + ',' + (-1 * this.y);
|
19820 | element.coordsize = this.width + ',' + this.height;
|
19821 |
|
19822 |
|
19823 | element.style.clipLeft = this.x;
|
19824 | element.style.clipRight = this.width + this.x;
|
19825 | element.style.clipTop = this.y;
|
19826 | element.style.left = -this.x;
|
19827 | element.style.top = -this.y;
|
19828 | element.style.width = this.width + this.x;
|
19829 | element.style.height = this.height + this.y;
|
19830 | element.style.rotation = 0;
|
19831 |
|
19832 | var container$$2 = this.parentNode;
|
19833 | this._activeTransform = container$$2 ? new transform(container$$2._activeTransform).transform(this) : this;
|
19834 | var node = this.firstChild;
|
19835 | while (node){
|
19836 | node._transform();
|
19837 | node = node.nextSibling;
|
19838 | }
|
19839 | }
|
19840 |
|
19841 | });
|
19842 |
|
19843 | var fontAnchors$1 = { start: 'left', middle: 'center', end: 'right' };
|
19844 |
|
19845 | var text$2 = _class(base$2, {
|
19846 |
|
19847 | base_initialize: base$2.prototype.initialize,
|
19848 |
|
19849 | initialize: function(text, font, alignment, path){
|
19850 | this.base_initialize('shape');
|
19851 |
|
19852 | var p = this.pathElement = dom.createElement('path');
|
19853 | p.textpathok = true;
|
19854 | this.element.appendChild(p);
|
19855 |
|
19856 | p = this.textPathElement = dom.createElement("textpath");
|
19857 | p.on = true;
|
19858 | p.style['v-text-align'] = 'left';
|
19859 | this.element.appendChild(p);
|
19860 |
|
19861 | this.draw.apply(this, arguments);
|
19862 | },
|
19863 |
|
19864 | draw: function(text, font, alignment, path){
|
19865 | var element = this.element,
|
19866 | textPath = this.textPathElement,
|
19867 | style = textPath.style;
|
19868 |
|
19869 | textPath.string = text;
|
19870 |
|
19871 | if (font){
|
19872 | if (typeof font == 'string'){
|
19873 | style.font = font;
|
19874 | } else {
|
19875 | for (var key in font){
|
19876 | var ckey = key.camelCase ? key.camelCase() : key;
|
19877 | if (ckey == 'fontFamily') style[ckey] = "'" + font[key] + "'";
|
19878 |
|
19879 |
|
19880 |
|
19881 |
|
19882 | else style[ckey] = font[key];
|
19883 | }
|
19884 | }
|
19885 | }
|
19886 |
|
19887 | if (alignment) style['v-text-align'] = fontAnchors$1[alignment] || alignment;
|
19888 |
|
19889 | if (path){
|
19890 | this.currentPath = path = new path$4(path);
|
19891 | this.element.path = path.toVML();
|
19892 | } else if (!this.currentPath){
|
19893 | var i = -1, offsetRows = '\n';
|
19894 | while ((i = text.indexOf('\n', i + 1)) > -1) offsetRows += '\n';
|
19895 | textPath.string = offsetRows + textPath.string;
|
19896 | this.element.path = 'm0,0l1,0';
|
19897 | }
|
19898 |
|
19899 |
|
19900 |
|
19901 |
|
19902 | element = element.cloneNode(true);
|
19903 | style = element.style;
|
19904 |
|
19905 |
|
19906 | element.coordorigin = '0,0';
|
19907 | element.coordsize = '10000,10000';
|
19908 | style.left = '0px';
|
19909 | style.top = '0px';
|
19910 | style.width = '10000px';
|
19911 | style.height = '10000px';
|
19912 | style.rotation = 0;
|
19913 | element.removeChild(element.firstChild);
|
19914 |
|
19915 |
|
19916 |
|
19917 | var canvas = new surface$2(1, 1),
|
19918 | group = new group$2(),
|
19919 | body = element.ownerDocument.body;
|
19920 |
|
19921 | canvas.inject(body);
|
19922 | group.element.appendChild(element);
|
19923 | group.inject(canvas);
|
19924 |
|
19925 | var ebb = element.getBoundingClientRect(),
|
19926 | cbb = canvas.toElement().getBoundingClientRect();
|
19927 |
|
19928 | canvas.eject();
|
19929 |
|
19930 | this.left = ebb.left - cbb.left;
|
19931 | this.top = ebb.top - cbb.top;
|
19932 | this.width = ebb.right - ebb.left;
|
19933 | this.height = ebb.bottom - ebb.top;
|
19934 | this.right = ebb.right - cbb.left;
|
19935 | this.bottom = ebb.bottom - cbb.top;
|
19936 |
|
19937 | this._transform();
|
19938 |
|
19939 |
|
19940 | return this;
|
19941 | }
|
19942 |
|
19943 | });
|
19944 |
|
19945 | var fastNoSideEffects = createCommonjsModule(function (module, exports) {
|
19946 | var hasCanvas = function(){
|
19947 |
|
19948 | var canvas = document.createElement('canvas');
|
19949 | return canvas && !!canvas.getContext;
|
19950 |
|
19951 | };
|
19952 |
|
19953 | if (hasCanvas()) {
|
19954 | exports.Surface = surface;
|
19955 | exports.Path = path;
|
19956 | exports.Shape = shape;
|
19957 | exports.Group = group;
|
19958 | exports.ClippingRectangle = clippingrectangle;
|
19959 | exports.Text = text;
|
19960 | } else {
|
19961 | exports.Surface = surface$2;
|
19962 | exports.Path = path$4;
|
19963 | exports.Shape = shape$2;
|
19964 | exports.Group = group$2;
|
19965 | exports.ClippingRectangle = clippingrectangle$2;
|
19966 | exports.Text = text$2;
|
19967 |
|
19968 | var DOM$$1 = dom;
|
19969 | if (typeof document !== 'undefined') DOM$$1.init(document);
|
19970 | }
|
19971 | });
|
19972 |
|
19973 | var fastNoSideEffects_1 = fastNoSideEffects.Surface;
|
19974 | var fastNoSideEffects_2 = fastNoSideEffects.Path;
|
19975 | var fastNoSideEffects_3 = fastNoSideEffects.Shape;
|
19976 | var fastNoSideEffects_4 = fastNoSideEffects.Group;
|
19977 | var fastNoSideEffects_5 = fastNoSideEffects.ClippingRectangle;
|
19978 | var fastNoSideEffects_6 = fastNoSideEffects.Text;
|
19979 |
|
19980 | current.setCurrent(
|
19981 | fastNoSideEffects);
|
19982 |
|
19983 |
|
19984 | var slice = Array.prototype.slice;
|
19985 |
|
19986 | var LinearGradient =
|
19987 |
|
19988 | function () {
|
19989 | function LinearGradient(stops, x1, y1, x2, y2) {
|
19990 | this._args = slice.call(arguments);
|
19991 | }
|
19992 |
|
19993 | var _proto = LinearGradient.prototype;
|
19994 |
|
19995 | _proto.applyFill = function applyFill(node) {
|
19996 | node.fillLinear.apply(node, this._args);
|
19997 | };
|
19998 |
|
19999 | return LinearGradient;
|
20000 | }();
|
20001 |
|
20002 | var RadialGradient =
|
20003 |
|
20004 | function () {
|
20005 | function RadialGradient(stops, fx, fy, rx, ry, cx, cy) {
|
20006 | this._args = slice.call(arguments);
|
20007 | }
|
20008 |
|
20009 | var _proto2 = RadialGradient.prototype;
|
20010 |
|
20011 | _proto2.applyFill = function applyFill(node) {
|
20012 | node.fillRadial.apply(node, this._args);
|
20013 | };
|
20014 |
|
20015 | return RadialGradient;
|
20016 | }();
|
20017 |
|
20018 | var Pattern =
|
20019 |
|
20020 | function () {
|
20021 | function Pattern(url, width, height, left, top) {
|
20022 | this._args = slice.call(arguments);
|
20023 | }
|
20024 |
|
20025 | var _proto3 = Pattern.prototype;
|
20026 |
|
20027 | _proto3.applyFill = function applyFill(node) {
|
20028 | node.fillImage.apply(node, this._args);
|
20029 | };
|
20030 |
|
20031 | return Pattern;
|
20032 | }();
|
20033 |
|
20034 |
|
20035 |
|
20036 | var Surface =
|
20037 |
|
20038 | function (_React$Component) {
|
20039 | _inheritsLoose(Surface, _React$Component);
|
20040 |
|
20041 | function Surface() {
|
20042 | return _React$Component.apply(this, arguments) || this;
|
20043 | }
|
20044 |
|
20045 | var _proto4 = Surface.prototype;
|
20046 |
|
20047 | _proto4.componentDidMount = function componentDidMount() {
|
20048 | var _this$props = this.props,
|
20049 | height = _this$props.height,
|
20050 | width = _this$props.width;
|
20051 | this._surface = current.Surface(+width, +height, this._tagRef);
|
20052 | this._mountNode = createContainer(this._surface, LegacyRoot, false, null);
|
20053 | updateContainer(this.props.children, this._mountNode, this);
|
20054 | };
|
20055 |
|
20056 | _proto4.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
20057 | var props = this.props;
|
20058 |
|
20059 | if (props.height !== prevProps.height || props.width !== prevProps.width) {
|
20060 | this._surface.resize(+props.width, +props.height);
|
20061 | }
|
20062 |
|
20063 | updateContainer(this.props.children, this._mountNode, this);
|
20064 |
|
20065 | if (this._surface.render) {
|
20066 | this._surface.render();
|
20067 | }
|
20068 | };
|
20069 |
|
20070 | _proto4.componentWillUnmount = function componentWillUnmount() {
|
20071 | updateContainer(null, this._mountNode, this);
|
20072 | };
|
20073 |
|
20074 | _proto4.render = function render() {
|
20075 | var _this = this;
|
20076 |
|
20077 |
|
20078 |
|
20079 |
|
20080 |
|
20081 | var props = this.props;
|
20082 |
|
20083 | var Tag = current.Surface.tagName;
|
20084 | return React.createElement(Tag, {
|
20085 | ref: function (ref) {
|
20086 | return _this._tagRef = ref;
|
20087 | },
|
20088 | accessKey: props.accessKey,
|
20089 | className: props.className,
|
20090 | draggable: props.draggable,
|
20091 | role: props.role,
|
20092 | style: props.style,
|
20093 | tabIndex: props.tabIndex,
|
20094 | title: props.title
|
20095 | });
|
20096 | };
|
20097 |
|
20098 | return Surface;
|
20099 | }(React.Component);
|
20100 |
|
20101 | var Text =
|
20102 |
|
20103 | function (_React$Component2) {
|
20104 | _inheritsLoose(Text, _React$Component2);
|
20105 |
|
20106 | function Text(props) {
|
20107 | var _this2;
|
20108 |
|
20109 | _this2 = _React$Component2.call(this, props) || this;
|
20110 |
|
20111 |
|
20112 | ['height', 'width', 'x', 'y'].forEach(function (key) {
|
20113 | Object.defineProperty(_assertThisInitialized(_this2), key, {
|
20114 | get: function () {
|
20115 | return this._text ? this._text[key] : undefined;
|
20116 | }
|
20117 | });
|
20118 | });
|
20119 | return _this2;
|
20120 | }
|
20121 |
|
20122 | var _proto5 = Text.prototype;
|
20123 |
|
20124 | _proto5.render = function render() {
|
20125 | var _this3 = this;
|
20126 |
|
20127 |
|
20128 | var T = TYPES.TEXT;
|
20129 | return React.createElement(T, _extends({}, this.props, {
|
20130 | ref: function (t) {
|
20131 | return _this3._text = t;
|
20132 | }
|
20133 | }), childrenAsString(this.props.children));
|
20134 | };
|
20135 |
|
20136 | return Text;
|
20137 | }(React.Component);
|
20138 |
|
20139 | injectIntoDevTools({
|
20140 | findFiberByHostInstance: function () {
|
20141 | return null;
|
20142 | },
|
20143 | bundleType: 1,
|
20144 | version: ReactVersion,
|
20145 | rendererPackageName: 'react-art'
|
20146 | });
|
20147 |
|
20148 |
|
20149 | var ClippingRectangle = TYPES.CLIPPING_RECTANGLE;
|
20150 | var Group = TYPES.GROUP;
|
20151 | var Shape = TYPES.SHAPE;
|
20152 | var Path = current.Path;
|
20153 |
|
20154 |
|
20155 | var ReactART = Object.freeze({
|
20156 | ClippingRectangle: ClippingRectangle,
|
20157 | Group: Group,
|
20158 | Shape: Shape,
|
20159 | Path: Path,
|
20160 | LinearGradient: LinearGradient,
|
20161 | Pattern: Pattern,
|
20162 | RadialGradient: RadialGradient,
|
20163 | Surface: Surface,
|
20164 | Text: Text,
|
20165 | Transform: transform
|
20166 | });
|
20167 |
|
20168 | var reactArt = ReactART;
|
20169 |
|
20170 | return reactArt;
|
20171 |
|
20172 | })));
|