1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | (function (global, factory) {
|
11 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
12 | typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
13 | (global = global || self, factory(global.ReactART = {}, global.React));
|
14 | }(this, (function (exports, React) { 'use strict';
|
15 |
|
16 | function _extends() {
|
17 | _extends = Object.assign || function (target) {
|
18 | for (var i = 1; i < arguments.length; i++) {
|
19 | var source = arguments[i];
|
20 |
|
21 | for (var key in source) {
|
22 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
23 | target[key] = source[key];
|
24 | }
|
25 | }
|
26 | }
|
27 |
|
28 | return target;
|
29 | };
|
30 |
|
31 | return _extends.apply(this, arguments);
|
32 | }
|
33 |
|
34 | function _inheritsLoose(subClass, superClass) {
|
35 | subClass.prototype = Object.create(superClass.prototype);
|
36 | subClass.prototype.constructor = subClass;
|
37 | subClass.__proto__ = superClass;
|
38 | }
|
39 |
|
40 | function _assertThisInitialized(self) {
|
41 | if (self === void 0) {
|
42 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
43 | }
|
44 |
|
45 | return self;
|
46 | }
|
47 |
|
48 | var ReactVersion = '18.0.0-fc46dba67-20220329';
|
49 |
|
50 | var LegacyRoot = 0;
|
51 | var ConcurrentRoot = 1;
|
52 |
|
53 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
54 |
|
55 | var suppressWarning = false;
|
56 | function setSuppressWarning(newSuppressWarning) {
|
57 | {
|
58 | suppressWarning = newSuppressWarning;
|
59 | }
|
60 | }
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | function warn(format) {
|
67 | {
|
68 | if (!suppressWarning) {
|
69 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
70 | args[_key - 1] = arguments[_key];
|
71 | }
|
72 |
|
73 | printWarning('warn', format, args);
|
74 | }
|
75 | }
|
76 | }
|
77 | function error(format) {
|
78 | {
|
79 | if (!suppressWarning) {
|
80 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
81 | args[_key2 - 1] = arguments[_key2];
|
82 | }
|
83 |
|
84 | printWarning('error', format, args);
|
85 | }
|
86 | }
|
87 | }
|
88 |
|
89 | function printWarning(level, format, args) {
|
90 |
|
91 |
|
92 | {
|
93 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
94 | var stack = ReactDebugCurrentFrame.getStackAddendum();
|
95 |
|
96 | if (stack !== '') {
|
97 | format += '%s';
|
98 | args = args.concat([stack]);
|
99 | }
|
100 |
|
101 |
|
102 | var argsWithFormat = args.map(function (item) {
|
103 | return String(item);
|
104 | });
|
105 |
|
106 | argsWithFormat.unshift('Warning: ' + format);
|
107 |
|
108 |
|
109 |
|
110 | Function.prototype.apply.call(console[level], console, argsWithFormat);
|
111 | }
|
112 | }
|
113 |
|
114 | var assign = Object.assign;
|
115 |
|
116 | |
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 | function get(key) {
|
126 | return key._reactInternals;
|
127 | }
|
128 | function set(key, value) {
|
129 | key._reactInternals = value;
|
130 | }
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | var enableNewReconciler = false;
|
136 |
|
137 | var enableLazyContextPropagation = false;
|
138 |
|
139 | var enableLegacyHidden = false;
|
140 |
|
141 | var enableSuspenseAvoidThisFallback = false;
|
142 | var warnAboutStringRefs = false;
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 | var enableSchedulingProfiler = true;
|
149 |
|
150 | var enableProfilerTimer = true;
|
151 |
|
152 | var enableProfilerCommitHooks = true;
|
153 |
|
154 | var FunctionComponent = 0;
|
155 | var ClassComponent = 1;
|
156 | var IndeterminateComponent = 2;
|
157 |
|
158 | var HostRoot = 3;
|
159 |
|
160 | var HostPortal = 4;
|
161 |
|
162 | var HostComponent = 5;
|
163 | var HostText = 6;
|
164 | var Fragment = 7;
|
165 | var Mode = 8;
|
166 | var ContextConsumer = 9;
|
167 | var ContextProvider = 10;
|
168 | var ForwardRef = 11;
|
169 | var Profiler = 12;
|
170 | var SuspenseComponent = 13;
|
171 | var MemoComponent = 14;
|
172 | var SimpleMemoComponent = 15;
|
173 | var LazyComponent = 16;
|
174 | var IncompleteClassComponent = 17;
|
175 | var DehydratedFragment = 18;
|
176 | var SuspenseListComponent = 19;
|
177 | var ScopeComponent = 21;
|
178 | var OffscreenComponent = 22;
|
179 | var LegacyHiddenComponent = 23;
|
180 | var CacheComponent = 24;
|
181 | var TracingMarkerComponent = 25;
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 | var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
188 | var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
189 | var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
190 | var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
191 | var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
192 | var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
193 | var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
194 | var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
195 | var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
196 | var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
197 | var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
198 | var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
199 | var REACT_SCOPE_TYPE = Symbol.for('react.scope');
|
200 | var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for('react.debug_trace_mode');
|
201 | var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
202 | var REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden');
|
203 | var REACT_CACHE_TYPE = Symbol.for('react.cache');
|
204 | var REACT_TRACING_MARKER_TYPE = Symbol.for('react.tracing_marker');
|
205 | var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
206 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
207 | function getIteratorFn(maybeIterable) {
|
208 | if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
209 | return null;
|
210 | }
|
211 |
|
212 | var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
213 |
|
214 | if (typeof maybeIterator === 'function') {
|
215 | return maybeIterator;
|
216 | }
|
217 |
|
218 | return null;
|
219 | }
|
220 |
|
221 | function getWrappedName(outerType, innerType, wrapperName) {
|
222 | var displayName = outerType.displayName;
|
223 |
|
224 | if (displayName) {
|
225 | return displayName;
|
226 | }
|
227 |
|
228 | var functionName = innerType.displayName || innerType.name || '';
|
229 | return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
|
230 | }
|
231 |
|
232 |
|
233 | function getContextName(type) {
|
234 | return type.displayName || 'Context';
|
235 | }
|
236 |
|
237 |
|
238 | function getComponentNameFromType(type) {
|
239 | if (type == null) {
|
240 |
|
241 | return null;
|
242 | }
|
243 |
|
244 | {
|
245 | if (typeof type.tag === 'number') {
|
246 | error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
|
247 | }
|
248 | }
|
249 |
|
250 | if (typeof type === 'function') {
|
251 | return type.displayName || type.name || null;
|
252 | }
|
253 |
|
254 | if (typeof type === 'string') {
|
255 | return type;
|
256 | }
|
257 |
|
258 | switch (type) {
|
259 | case REACT_FRAGMENT_TYPE:
|
260 | return 'Fragment';
|
261 |
|
262 | case REACT_PORTAL_TYPE:
|
263 | return 'Portal';
|
264 |
|
265 | case REACT_PROFILER_TYPE:
|
266 | return 'Profiler';
|
267 |
|
268 | case REACT_STRICT_MODE_TYPE:
|
269 | return 'StrictMode';
|
270 |
|
271 | case REACT_SUSPENSE_TYPE:
|
272 | return 'Suspense';
|
273 |
|
274 | case REACT_SUSPENSE_LIST_TYPE:
|
275 | return 'SuspenseList';
|
276 |
|
277 | }
|
278 |
|
279 | if (typeof type === 'object') {
|
280 | switch (type.$$typeof) {
|
281 | case REACT_CONTEXT_TYPE:
|
282 | var context = type;
|
283 | return getContextName(context) + '.Consumer';
|
284 |
|
285 | case REACT_PROVIDER_TYPE:
|
286 | var provider = type;
|
287 | return getContextName(provider._context) + '.Provider';
|
288 |
|
289 | case REACT_FORWARD_REF_TYPE:
|
290 | return getWrappedName(type, type.render, 'ForwardRef');
|
291 |
|
292 | case REACT_MEMO_TYPE:
|
293 | var outerName = type.displayName || null;
|
294 |
|
295 | if (outerName !== null) {
|
296 | return outerName;
|
297 | }
|
298 |
|
299 | return getComponentNameFromType(type.type) || 'Memo';
|
300 |
|
301 | case REACT_LAZY_TYPE:
|
302 | {
|
303 | var lazyComponent = type;
|
304 | var payload = lazyComponent._payload;
|
305 | var init = lazyComponent._init;
|
306 |
|
307 | try {
|
308 | return getComponentNameFromType(init(payload));
|
309 | } catch (x) {
|
310 | return null;
|
311 | }
|
312 | }
|
313 |
|
314 |
|
315 | }
|
316 | }
|
317 |
|
318 | return null;
|
319 | }
|
320 |
|
321 | function getWrappedName$1(outerType, innerType, wrapperName) {
|
322 | var functionName = innerType.displayName || innerType.name || '';
|
323 | return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
324 | }
|
325 |
|
326 |
|
327 | function getContextName$1(type) {
|
328 | return type.displayName || 'Context';
|
329 | }
|
330 |
|
331 | function getComponentNameFromFiber(fiber) {
|
332 | var tag = fiber.tag,
|
333 | type = fiber.type;
|
334 |
|
335 | switch (tag) {
|
336 | case CacheComponent:
|
337 | return 'Cache';
|
338 |
|
339 | case ContextConsumer:
|
340 | var context = type;
|
341 | return getContextName$1(context) + '.Consumer';
|
342 |
|
343 | case ContextProvider:
|
344 | var provider = type;
|
345 | return getContextName$1(provider._context) + '.Provider';
|
346 |
|
347 | case DehydratedFragment:
|
348 | return 'DehydratedFragment';
|
349 |
|
350 | case ForwardRef:
|
351 | return getWrappedName$1(type, type.render, 'ForwardRef');
|
352 |
|
353 | case Fragment:
|
354 | return 'Fragment';
|
355 |
|
356 | case HostComponent:
|
357 |
|
358 | return type;
|
359 |
|
360 | case HostPortal:
|
361 | return 'Portal';
|
362 |
|
363 | case HostRoot:
|
364 | return 'Root';
|
365 |
|
366 | case HostText:
|
367 | return 'Text';
|
368 |
|
369 | case LazyComponent:
|
370 |
|
371 | return getComponentNameFromType(type);
|
372 |
|
373 | case Mode:
|
374 | if (type === REACT_STRICT_MODE_TYPE) {
|
375 |
|
376 | return 'StrictMode';
|
377 | }
|
378 |
|
379 | return 'Mode';
|
380 |
|
381 | case OffscreenComponent:
|
382 | return 'Offscreen';
|
383 |
|
384 | case Profiler:
|
385 | return 'Profiler';
|
386 |
|
387 | case ScopeComponent:
|
388 | return 'Scope';
|
389 |
|
390 | case SuspenseComponent:
|
391 | return 'Suspense';
|
392 |
|
393 | case SuspenseListComponent:
|
394 | return 'SuspenseList';
|
395 |
|
396 | case TracingMarkerComponent:
|
397 | return 'TracingMarker';
|
398 |
|
399 |
|
400 | case ClassComponent:
|
401 | case FunctionComponent:
|
402 | case IncompleteClassComponent:
|
403 | case IndeterminateComponent:
|
404 | case MemoComponent:
|
405 | case SimpleMemoComponent:
|
406 | if (typeof type === 'function') {
|
407 | return type.displayName || type.name || null;
|
408 | }
|
409 |
|
410 | if (typeof type === 'string') {
|
411 | return type;
|
412 | }
|
413 |
|
414 | break;
|
415 |
|
416 | }
|
417 |
|
418 | return null;
|
419 | }
|
420 |
|
421 |
|
422 | var NoFlags =
|
423 |
|
424 | 0;
|
425 | var PerformedWork =
|
426 |
|
427 | 1;
|
428 |
|
429 | var Placement =
|
430 |
|
431 | 2;
|
432 | var Update =
|
433 |
|
434 | 4;
|
435 | var PlacementAndUpdate =
|
436 |
|
437 | Placement | Update;
|
438 | var ChildDeletion =
|
439 |
|
440 | 16;
|
441 | var ContentReset =
|
442 |
|
443 | 32;
|
444 | var Callback =
|
445 |
|
446 | 64;
|
447 | var DidCapture =
|
448 |
|
449 | 128;
|
450 | var ForceClientRender =
|
451 |
|
452 | 256;
|
453 | var Ref =
|
454 |
|
455 | 512;
|
456 | var Snapshot =
|
457 |
|
458 | 1024;
|
459 | var Passive =
|
460 |
|
461 | 2048;
|
462 | var Hydrating =
|
463 |
|
464 | 4096;
|
465 | var HydratingAndUpdate =
|
466 |
|
467 | Hydrating | Update;
|
468 | var Visibility =
|
469 |
|
470 | 8192;
|
471 | var StoreConsistency =
|
472 |
|
473 | 16384;
|
474 | var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot | StoreConsistency;
|
475 |
|
476 | var HostEffectMask =
|
477 |
|
478 | 32767;
|
479 |
|
480 | var Incomplete =
|
481 |
|
482 | 32768;
|
483 | var ShouldCapture =
|
484 |
|
485 | 65536;
|
486 | var ForceUpdateForLegacySuspense =
|
487 |
|
488 | 131072;
|
489 | var Forked =
|
490 |
|
491 | 1048576;
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 | var RefStatic =
|
498 |
|
499 | 2097152;
|
500 | var LayoutStatic =
|
501 |
|
502 | 4194304;
|
503 | var PassiveStatic =
|
504 |
|
505 | 8388608;
|
506 |
|
507 |
|
508 |
|
509 | var MountLayoutDev =
|
510 |
|
511 | 16777216;
|
512 | var MountPassiveDev =
|
513 |
|
514 | 33554432;
|
515 |
|
516 |
|
517 | var BeforeMutationMask =
|
518 |
|
519 | Update | Snapshot | ( 0);
|
520 | var MutationMask = Placement | Update | ChildDeletion | ContentReset | Ref | Hydrating | Visibility;
|
521 | var LayoutMask = Update | Callback | Ref | Visibility;
|
522 |
|
523 | var PassiveMask = Passive | ChildDeletion;
|
524 |
|
525 |
|
526 |
|
527 | var StaticMask = LayoutStatic | PassiveStatic | RefStatic;
|
528 |
|
529 | var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
530 | function getNearestMountedFiber(fiber) {
|
531 | var node = fiber;
|
532 | var nearestMounted = fiber;
|
533 |
|
534 | if (!fiber.alternate) {
|
535 |
|
536 |
|
537 | var nextNode = node;
|
538 |
|
539 | do {
|
540 | node = nextNode;
|
541 |
|
542 | if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
|
543 |
|
544 |
|
545 |
|
546 | nearestMounted = node.return;
|
547 | }
|
548 |
|
549 | nextNode = node.return;
|
550 | } while (nextNode);
|
551 | } else {
|
552 | while (node.return) {
|
553 | node = node.return;
|
554 | }
|
555 | }
|
556 |
|
557 | if (node.tag === HostRoot) {
|
558 |
|
559 |
|
560 | return nearestMounted;
|
561 | }
|
562 |
|
563 |
|
564 |
|
565 | return null;
|
566 | }
|
567 | function isFiberMounted(fiber) {
|
568 | return getNearestMountedFiber(fiber) === fiber;
|
569 | }
|
570 | function isMounted(component) {
|
571 | {
|
572 | var owner = ReactCurrentOwner.current;
|
573 |
|
574 | if (owner !== null && owner.tag === ClassComponent) {
|
575 | var ownerFiber = owner;
|
576 | var instance = ownerFiber.stateNode;
|
577 |
|
578 | if (!instance._warnedAboutRefsInRender) {
|
579 | error('%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.', getComponentNameFromFiber(ownerFiber) || 'A component');
|
580 | }
|
581 |
|
582 | instance._warnedAboutRefsInRender = true;
|
583 | }
|
584 | }
|
585 |
|
586 | var fiber = get(component);
|
587 |
|
588 | if (!fiber) {
|
589 | return false;
|
590 | }
|
591 |
|
592 | return getNearestMountedFiber(fiber) === fiber;
|
593 | }
|
594 |
|
595 | function assertIsMounted(fiber) {
|
596 | if (getNearestMountedFiber(fiber) !== fiber) {
|
597 | throw new Error('Unable to find node on an unmounted component.');
|
598 | }
|
599 | }
|
600 |
|
601 | function findCurrentFiberUsingSlowPath(fiber) {
|
602 | var alternate = fiber.alternate;
|
603 |
|
604 | if (!alternate) {
|
605 |
|
606 | var nearestMounted = getNearestMountedFiber(fiber);
|
607 |
|
608 | if (nearestMounted === null) {
|
609 | throw new Error('Unable to find node on an unmounted component.');
|
610 | }
|
611 |
|
612 | if (nearestMounted !== fiber) {
|
613 | return null;
|
614 | }
|
615 |
|
616 | return fiber;
|
617 | }
|
618 |
|
619 |
|
620 |
|
621 |
|
622 | var a = fiber;
|
623 | var b = alternate;
|
624 |
|
625 | while (true) {
|
626 | var parentA = a.return;
|
627 |
|
628 | if (parentA === null) {
|
629 |
|
630 | break;
|
631 | }
|
632 |
|
633 | var parentB = parentA.alternate;
|
634 |
|
635 | if (parentB === null) {
|
636 |
|
637 |
|
638 |
|
639 |
|
640 | var nextParent = parentA.return;
|
641 |
|
642 | if (nextParent !== null) {
|
643 | a = b = nextParent;
|
644 | continue;
|
645 | }
|
646 |
|
647 |
|
648 | break;
|
649 | }
|
650 |
|
651 |
|
652 |
|
653 |
|
654 | if (parentA.child === parentB.child) {
|
655 | var child = parentA.child;
|
656 |
|
657 | while (child) {
|
658 | if (child === a) {
|
659 |
|
660 | assertIsMounted(parentA);
|
661 | return fiber;
|
662 | }
|
663 |
|
664 | if (child === b) {
|
665 |
|
666 | assertIsMounted(parentA);
|
667 | return alternate;
|
668 | }
|
669 |
|
670 | child = child.sibling;
|
671 | }
|
672 |
|
673 |
|
674 |
|
675 | throw new Error('Unable to find node on an unmounted component.');
|
676 | }
|
677 |
|
678 | if (a.return !== b.return) {
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | a = parentA;
|
684 | b = parentB;
|
685 | } else {
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 | var didFindChild = false;
|
692 | var _child = parentA.child;
|
693 |
|
694 | while (_child) {
|
695 | if (_child === a) {
|
696 | didFindChild = true;
|
697 | a = parentA;
|
698 | b = parentB;
|
699 | break;
|
700 | }
|
701 |
|
702 | if (_child === b) {
|
703 | didFindChild = true;
|
704 | b = parentA;
|
705 | a = parentB;
|
706 | break;
|
707 | }
|
708 |
|
709 | _child = _child.sibling;
|
710 | }
|
711 |
|
712 | if (!didFindChild) {
|
713 |
|
714 | _child = parentB.child;
|
715 |
|
716 | while (_child) {
|
717 | if (_child === a) {
|
718 | didFindChild = true;
|
719 | a = parentB;
|
720 | b = parentA;
|
721 | break;
|
722 | }
|
723 |
|
724 | if (_child === b) {
|
725 | didFindChild = true;
|
726 | b = parentB;
|
727 | a = parentA;
|
728 | break;
|
729 | }
|
730 |
|
731 | _child = _child.sibling;
|
732 | }
|
733 |
|
734 | if (!didFindChild) {
|
735 | throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.');
|
736 | }
|
737 | }
|
738 | }
|
739 |
|
740 | if (a.alternate !== b) {
|
741 | throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.');
|
742 | }
|
743 | }
|
744 |
|
745 |
|
746 |
|
747 | if (a.tag !== HostRoot) {
|
748 | throw new Error('Unable to find node on an unmounted component.');
|
749 | }
|
750 |
|
751 | if (a.stateNode.current === a) {
|
752 |
|
753 | return fiber;
|
754 | }
|
755 |
|
756 |
|
757 | return alternate;
|
758 | }
|
759 | function findCurrentHostFiber(parent) {
|
760 | var currentParent = findCurrentFiberUsingSlowPath(parent);
|
761 | return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null;
|
762 | }
|
763 |
|
764 | function findCurrentHostFiberImpl(node) {
|
765 |
|
766 | if (node.tag === HostComponent || node.tag === HostText) {
|
767 | return node;
|
768 | }
|
769 |
|
770 | var child = node.child;
|
771 |
|
772 | while (child !== null) {
|
773 | var match = findCurrentHostFiberImpl(child);
|
774 |
|
775 | if (match !== null) {
|
776 | return match;
|
777 | }
|
778 |
|
779 | child = child.sibling;
|
780 | }
|
781 |
|
782 | return null;
|
783 | }
|
784 |
|
785 | var isArrayImpl = Array.isArray;
|
786 |
|
787 | function isArray(a) {
|
788 | return isArrayImpl(a);
|
789 | }
|
790 |
|
791 | var _class = function(mixins){
|
792 | var proto = {};
|
793 | for (var i = 0, l = arguments.length; i < l; i++){
|
794 | var mixin = arguments[i];
|
795 | if (typeof mixin == 'function') mixin = mixin.prototype;
|
796 | for (var key in mixin) proto[key] = mixin[key];
|
797 | }
|
798 | if (!proto.initialize) proto.initialize = function(){};
|
799 | proto.constructor = function(a,b,c,d,e,f,g,h){
|
800 | return new proto.initialize(a,b,c,d,e,f,g,h);
|
801 | };
|
802 | proto.constructor.prototype = proto.initialize.prototype = proto;
|
803 | return proto.constructor;
|
804 | };
|
805 |
|
806 | function Transform(xx, yx, xy, yy, x, y){
|
807 | if (xx && typeof xx == 'object'){
|
808 | yx = xx.yx; yy = xx.yy; y = xx.y;
|
809 | xy = xx.xy; x = xx.x; xx = xx.xx;
|
810 | }
|
811 | this.xx = xx == null ? 1 : xx;
|
812 | this.yx = yx || 0;
|
813 | this.xy = xy || 0;
|
814 | this.yy = yy == null ? 1 : yy;
|
815 | this.x = (x == null ? this.x : x) || 0;
|
816 | this.y = (y == null ? this.y : y) || 0;
|
817 | this._transform();
|
818 | return this;
|
819 | }
|
820 | var transform = _class({
|
821 |
|
822 | initialize: Transform,
|
823 |
|
824 | _transform: function(){},
|
825 |
|
826 | xx: 1, yx: 0, x: 0,
|
827 | xy: 0, yy: 1, y: 0,
|
828 |
|
829 | transform: function(xx, yx, xy, yy, x, y){
|
830 | var m = this;
|
831 | if (xx && typeof xx == 'object'){
|
832 | yx = xx.yx; yy = xx.yy; y = xx.y;
|
833 | xy = xx.xy; x = xx.x; xx = xx.xx;
|
834 | }
|
835 | if (!x) x = 0;
|
836 | if (!y) y = 0;
|
837 | return this.transformTo(
|
838 | m.xx * xx + m.xy * yx,
|
839 | m.yx * xx + m.yy * yx,
|
840 | m.xx * xy + m.xy * yy,
|
841 | m.yx * xy + m.yy * yy,
|
842 | m.xx * x + m.xy * y + m.x,
|
843 | m.yx * x + m.yy * y + m.y
|
844 | );
|
845 | },
|
846 |
|
847 | transformTo: Transform,
|
848 |
|
849 | translate: function(x, y){
|
850 | return this.transform(1, 0, 0, 1, x, y);
|
851 | },
|
852 |
|
853 | move: function(x, y){
|
854 | this.x += x || 0;
|
855 | this.y += y || 0;
|
856 | this._transform();
|
857 | return this;
|
858 | },
|
859 |
|
860 | scale: function(x, y){
|
861 | if (y == null) y = x;
|
862 | return this.transform(x, 0, 0, y, 0, 0);
|
863 | },
|
864 |
|
865 | rotate: function(deg, x, y){
|
866 | if (x == null || y == null){
|
867 | x = (this.left || 0) + (this.width || 0) / 2;
|
868 | y = (this.top || 0) + (this.height || 0) / 2;
|
869 | }
|
870 |
|
871 | var rad = deg * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
|
872 |
|
873 | this.transform(1, 0, 0, 1, x, y);
|
874 | var m = this;
|
875 |
|
876 | return this.transformTo(
|
877 | cos * m.xx - sin * m.yx,
|
878 | sin * m.xx + cos * m.yx,
|
879 | cos * m.xy - sin * m.yy,
|
880 | sin * m.xy + cos * m.yy,
|
881 | m.x,
|
882 | m.y
|
883 | ).transform(1, 0, 0, 1, -x, -y);
|
884 | },
|
885 |
|
886 | moveTo: function(x, y){
|
887 | var m = this;
|
888 | return this.transformTo(m.xx, m.yx, m.xy, m.yy, x, y);
|
889 | },
|
890 |
|
891 | rotateTo: function(deg, x, y){
|
892 | var m = this;
|
893 | var flip = m.yx / m.xx > m.yy / m.xy ? -1 : 1;
|
894 | if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = -flip;
|
895 | return this.rotate(deg - Math.atan2(flip * m.yx, flip * m.xx) * 180 / Math.PI, x, y);
|
896 | },
|
897 |
|
898 | scaleTo: function(x, y){
|
899 |
|
900 | var m = this;
|
901 |
|
902 | var h = Math.sqrt(m.xx * m.xx + m.yx * m.yx);
|
903 | m.xx /= h; m.yx /= h;
|
904 |
|
905 | h = Math.sqrt(m.yy * m.yy + m.xy * m.xy);
|
906 | m.yy /= h; m.xy /= h;
|
907 |
|
908 | return this.scale(x, y);
|
909 | },
|
910 |
|
911 | resizeTo: function(width, height){
|
912 | var w = this.width, h = this.height;
|
913 | if (!w || !h) return this;
|
914 | return this.scaleTo(width / w, height / h);
|
915 | },
|
916 |
|
917 | |
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 | inversePoint: function(x, y){
|
932 | var a = this.xx, b = this.yx,
|
933 | c = this.xy, d = this.yy,
|
934 | e = this.x, f = this.y;
|
935 | var det = b * c - a * d;
|
936 | if (det == 0) return null;
|
937 | return {
|
938 | x: (d * (e - x) + c * (y - f)) / det,
|
939 | y: (a * (f - y) + b * (x - e)) / det
|
940 | };
|
941 | },
|
942 |
|
943 | point: function(x, y){
|
944 | var m = this;
|
945 | return {
|
946 | x: m.xx * x + m.xy * y + m.x,
|
947 | y: m.yx * x + m.yy * y + m.y
|
948 | };
|
949 | }
|
950 |
|
951 | });
|
952 |
|
953 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
954 |
|
955 | function createCommonjsModule(fn, module) {
|
956 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
957 | }
|
958 |
|
959 | var current = createCommonjsModule(function (module, exports) {
|
960 | function warning(){
|
961 | throw new Error('You must require a mode before requiring anything else.');
|
962 | }
|
963 |
|
964 | exports.Surface = warning;
|
965 | exports.Path = warning;
|
966 | exports.Shape = warning;
|
967 | exports.Group = warning;
|
968 | exports.ClippingRectangle = warning;
|
969 | exports.Text = warning;
|
970 |
|
971 | exports.setCurrent = function(mode){
|
972 | for (var key in mode){
|
973 | exports[key] = mode[key];
|
974 | }
|
975 | };
|
976 | });
|
977 | var current_1 = current.Surface;
|
978 | var current_2 = current.Path;
|
979 | var current_3 = current.Shape;
|
980 | var current_4 = current.Group;
|
981 | var current_5 = current.ClippingRectangle;
|
982 | var current_6 = current.Text;
|
983 | var current_7 = current.setCurrent;
|
984 |
|
985 | var TYPES = {
|
986 | CLIPPING_RECTANGLE: 'ClippingRectangle',
|
987 | GROUP: 'Group',
|
988 | SHAPE: 'Shape',
|
989 | TEXT: 'Text'
|
990 | };
|
991 | var EVENT_TYPES = {
|
992 | onClick: 'click',
|
993 | onMouseMove: 'mousemove',
|
994 | onMouseOver: 'mouseover',
|
995 | onMouseOut: 'mouseout',
|
996 | onMouseUp: 'mouseup',
|
997 | onMouseDown: 'mousedown'
|
998 | };
|
999 | function childrenAsString(children) {
|
1000 | if (!children) {
|
1001 | return '';
|
1002 | } else if (typeof children === 'string') {
|
1003 | return children;
|
1004 | } else if (children.length) {
|
1005 | return children.join('');
|
1006 | } else {
|
1007 | return '';
|
1008 | }
|
1009 | }
|
1010 |
|
1011 | var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
1012 | var _ReactInternals$Sched = ReactInternals.Scheduler,
|
1013 | unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback,
|
1014 | unstable_now = _ReactInternals$Sched.unstable_now,
|
1015 | unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback,
|
1016 | unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield,
|
1017 | unstable_requestPaint = _ReactInternals$Sched.unstable_requestPaint,
|
1018 | unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode,
|
1019 | unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority,
|
1020 | unstable_next = _ReactInternals$Sched.unstable_next,
|
1021 | unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution,
|
1022 | unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution,
|
1023 | unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel,
|
1024 | unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority,
|
1025 | unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority,
|
1026 | unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority,
|
1027 | unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority,
|
1028 | unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority,
|
1029 | unstable_forceFrameRate = _ReactInternals$Sched.unstable_forceFrameRate,
|
1030 | unstable_flushAllWithoutAsserting = _ReactInternals$Sched.unstable_flushAllWithoutAsserting,
|
1031 | unstable_yieldValue = _ReactInternals$Sched.unstable_yieldValue,
|
1032 | unstable_setDisableYieldValue = _ReactInternals$Sched.unstable_setDisableYieldValue;
|
1033 |
|
1034 |
|
1035 | var scheduleCallback = unstable_scheduleCallback;
|
1036 | var cancelCallback = unstable_cancelCallback;
|
1037 | var shouldYield = unstable_shouldYield;
|
1038 | var requestPaint = unstable_requestPaint;
|
1039 | var now = unstable_now;
|
1040 | var ImmediatePriority = unstable_ImmediatePriority;
|
1041 | var UserBlockingPriority = unstable_UserBlockingPriority;
|
1042 | var NormalPriority = unstable_NormalPriority;
|
1043 | var IdlePriority = unstable_IdlePriority;
|
1044 |
|
1045 |
|
1046 | var unstable_yieldValue$1 = unstable_yieldValue;
|
1047 | var unstable_setDisableYieldValue$1 = unstable_setDisableYieldValue;
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 | var disabledDepth = 0;
|
1054 | var prevLog;
|
1055 | var prevInfo;
|
1056 | var prevWarn;
|
1057 | var prevError;
|
1058 | var prevGroup;
|
1059 | var prevGroupCollapsed;
|
1060 | var prevGroupEnd;
|
1061 |
|
1062 | function disabledLog() {}
|
1063 |
|
1064 | disabledLog.__reactDisabledLog = true;
|
1065 | function disableLogs() {
|
1066 | {
|
1067 | if (disabledDepth === 0) {
|
1068 |
|
1069 | prevLog = console.log;
|
1070 | prevInfo = console.info;
|
1071 | prevWarn = console.warn;
|
1072 | prevError = console.error;
|
1073 | prevGroup = console.group;
|
1074 | prevGroupCollapsed = console.groupCollapsed;
|
1075 | prevGroupEnd = console.groupEnd;
|
1076 |
|
1077 | var props = {
|
1078 | configurable: true,
|
1079 | enumerable: true,
|
1080 | value: disabledLog,
|
1081 | writable: true
|
1082 | };
|
1083 |
|
1084 | Object.defineProperties(console, {
|
1085 | info: props,
|
1086 | log: props,
|
1087 | warn: props,
|
1088 | error: props,
|
1089 | group: props,
|
1090 | groupCollapsed: props,
|
1091 | groupEnd: props
|
1092 | });
|
1093 |
|
1094 | }
|
1095 |
|
1096 | disabledDepth++;
|
1097 | }
|
1098 | }
|
1099 | function reenableLogs() {
|
1100 | {
|
1101 | disabledDepth--;
|
1102 |
|
1103 | if (disabledDepth === 0) {
|
1104 |
|
1105 | var props = {
|
1106 | configurable: true,
|
1107 | enumerable: true,
|
1108 | writable: true
|
1109 | };
|
1110 |
|
1111 | Object.defineProperties(console, {
|
1112 | log: assign({}, props, {
|
1113 | value: prevLog
|
1114 | }),
|
1115 | info: assign({}, props, {
|
1116 | value: prevInfo
|
1117 | }),
|
1118 | warn: assign({}, props, {
|
1119 | value: prevWarn
|
1120 | }),
|
1121 | error: assign({}, props, {
|
1122 | value: prevError
|
1123 | }),
|
1124 | group: assign({}, props, {
|
1125 | value: prevGroup
|
1126 | }),
|
1127 | groupCollapsed: assign({}, props, {
|
1128 | value: prevGroupCollapsed
|
1129 | }),
|
1130 | groupEnd: assign({}, props, {
|
1131 | value: prevGroupEnd
|
1132 | })
|
1133 | });
|
1134 |
|
1135 | }
|
1136 |
|
1137 | if (disabledDepth < 0) {
|
1138 | error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
|
1139 | }
|
1140 | }
|
1141 | }
|
1142 |
|
1143 | var rendererID = null;
|
1144 | var injectedHook = null;
|
1145 | var injectedProfilingHooks = null;
|
1146 | var hasLoggedError = false;
|
1147 | var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
|
1148 | function injectInternals(internals) {
|
1149 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
|
1150 |
|
1151 | return false;
|
1152 | }
|
1153 |
|
1154 | var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
1155 |
|
1156 | if (hook.isDisabled) {
|
1157 |
|
1158 |
|
1159 |
|
1160 | return true;
|
1161 | }
|
1162 |
|
1163 | if (!hook.supportsFiber) {
|
1164 | {
|
1165 | error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://reactjs.org/link/react-devtools');
|
1166 | }
|
1167 |
|
1168 |
|
1169 | return true;
|
1170 | }
|
1171 |
|
1172 | try {
|
1173 | if (enableSchedulingProfiler) {
|
1174 |
|
1175 |
|
1176 |
|
1177 | internals = assign({}, internals, {
|
1178 | getLaneLabelMap: getLaneLabelMap,
|
1179 | injectProfilingHooks: injectProfilingHooks
|
1180 | });
|
1181 | }
|
1182 |
|
1183 | rendererID = hook.inject(internals);
|
1184 |
|
1185 | injectedHook = hook;
|
1186 | } catch (err) {
|
1187 |
|
1188 | {
|
1189 | error('React instrumentation encountered an error: %s.', err);
|
1190 | }
|
1191 | }
|
1192 |
|
1193 | if (hook.checkDCE) {
|
1194 |
|
1195 | return true;
|
1196 | } else {
|
1197 |
|
1198 | return false;
|
1199 | }
|
1200 | }
|
1201 | function onScheduleRoot(root, children) {
|
1202 | {
|
1203 | if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') {
|
1204 | try {
|
1205 | injectedHook.onScheduleFiberRoot(rendererID, root, children);
|
1206 | } catch (err) {
|
1207 | if ( !hasLoggedError) {
|
1208 | hasLoggedError = true;
|
1209 |
|
1210 | error('React instrumentation encountered an error: %s', err);
|
1211 | }
|
1212 | }
|
1213 | }
|
1214 | }
|
1215 | }
|
1216 | function onCommitRoot(root, eventPriority) {
|
1217 | if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') {
|
1218 | try {
|
1219 | var didError = (root.current.flags & DidCapture) === DidCapture;
|
1220 |
|
1221 | if (enableProfilerTimer) {
|
1222 | var schedulerPriority;
|
1223 |
|
1224 | switch (eventPriority) {
|
1225 | case DiscreteEventPriority:
|
1226 | schedulerPriority = ImmediatePriority;
|
1227 | break;
|
1228 |
|
1229 | case ContinuousEventPriority:
|
1230 | schedulerPriority = UserBlockingPriority;
|
1231 | break;
|
1232 |
|
1233 | case DefaultEventPriority:
|
1234 | schedulerPriority = NormalPriority;
|
1235 | break;
|
1236 |
|
1237 | case IdleEventPriority:
|
1238 | schedulerPriority = IdlePriority;
|
1239 | break;
|
1240 |
|
1241 | default:
|
1242 | schedulerPriority = NormalPriority;
|
1243 | break;
|
1244 | }
|
1245 |
|
1246 | injectedHook.onCommitFiberRoot(rendererID, root, schedulerPriority, didError);
|
1247 | } else {
|
1248 | injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError);
|
1249 | }
|
1250 | } catch (err) {
|
1251 | {
|
1252 | if (!hasLoggedError) {
|
1253 | hasLoggedError = true;
|
1254 |
|
1255 | error('React instrumentation encountered an error: %s', err);
|
1256 | }
|
1257 | }
|
1258 | }
|
1259 | }
|
1260 | }
|
1261 | function onPostCommitRoot(root) {
|
1262 | if (injectedHook && typeof injectedHook.onPostCommitFiberRoot === 'function') {
|
1263 | try {
|
1264 | injectedHook.onPostCommitFiberRoot(rendererID, root);
|
1265 | } catch (err) {
|
1266 | {
|
1267 | if (!hasLoggedError) {
|
1268 | hasLoggedError = true;
|
1269 |
|
1270 | error('React instrumentation encountered an error: %s', err);
|
1271 | }
|
1272 | }
|
1273 | }
|
1274 | }
|
1275 | }
|
1276 | function onCommitUnmount(fiber) {
|
1277 | if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') {
|
1278 | try {
|
1279 | injectedHook.onCommitFiberUnmount(rendererID, fiber);
|
1280 | } catch (err) {
|
1281 | {
|
1282 | if (!hasLoggedError) {
|
1283 | hasLoggedError = true;
|
1284 |
|
1285 | error('React instrumentation encountered an error: %s', err);
|
1286 | }
|
1287 | }
|
1288 | }
|
1289 | }
|
1290 | }
|
1291 | function setIsStrictModeForDevtools(newIsStrictMode) {
|
1292 | {
|
1293 | if (typeof unstable_yieldValue$1 === 'function') {
|
1294 |
|
1295 |
|
1296 |
|
1297 | unstable_setDisableYieldValue$1(newIsStrictMode);
|
1298 | setSuppressWarning(newIsStrictMode);
|
1299 | }
|
1300 |
|
1301 | if (injectedHook && typeof injectedHook.setStrictMode === 'function') {
|
1302 | try {
|
1303 | injectedHook.setStrictMode(rendererID, newIsStrictMode);
|
1304 | } catch (err) {
|
1305 | {
|
1306 | if (!hasLoggedError) {
|
1307 | hasLoggedError = true;
|
1308 |
|
1309 | error('React instrumentation encountered an error: %s', err);
|
1310 | }
|
1311 | }
|
1312 | }
|
1313 | }
|
1314 | }
|
1315 | }
|
1316 |
|
1317 | function injectProfilingHooks(profilingHooks) {
|
1318 | injectedProfilingHooks = profilingHooks;
|
1319 | }
|
1320 |
|
1321 | function getLaneLabelMap() {
|
1322 | {
|
1323 | var map = new Map();
|
1324 | var lane = 1;
|
1325 |
|
1326 | for (var index = 0; index < TotalLanes; index++) {
|
1327 | var label = getLabelForLane(lane);
|
1328 | map.set(lane, label);
|
1329 | lane *= 2;
|
1330 | }
|
1331 |
|
1332 | return map;
|
1333 | }
|
1334 | }
|
1335 |
|
1336 | function markCommitStarted(lanes) {
|
1337 | {
|
1338 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStarted === 'function') {
|
1339 | injectedProfilingHooks.markCommitStarted(lanes);
|
1340 | }
|
1341 | }
|
1342 | }
|
1343 | function markCommitStopped() {
|
1344 | {
|
1345 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStopped === 'function') {
|
1346 | injectedProfilingHooks.markCommitStopped();
|
1347 | }
|
1348 | }
|
1349 | }
|
1350 | function markComponentRenderStarted(fiber) {
|
1351 | {
|
1352 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStarted === 'function') {
|
1353 | injectedProfilingHooks.markComponentRenderStarted(fiber);
|
1354 | }
|
1355 | }
|
1356 | }
|
1357 | function markComponentRenderStopped() {
|
1358 | {
|
1359 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStopped === 'function') {
|
1360 | injectedProfilingHooks.markComponentRenderStopped();
|
1361 | }
|
1362 | }
|
1363 | }
|
1364 | function markComponentPassiveEffectMountStarted(fiber) {
|
1365 | {
|
1366 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStarted === 'function') {
|
1367 | injectedProfilingHooks.markComponentPassiveEffectMountStarted(fiber);
|
1368 | }
|
1369 | }
|
1370 | }
|
1371 | function markComponentPassiveEffectMountStopped() {
|
1372 | {
|
1373 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStopped === 'function') {
|
1374 | injectedProfilingHooks.markComponentPassiveEffectMountStopped();
|
1375 | }
|
1376 | }
|
1377 | }
|
1378 | function markComponentPassiveEffectUnmountStarted(fiber) {
|
1379 | {
|
1380 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStarted === 'function') {
|
1381 | injectedProfilingHooks.markComponentPassiveEffectUnmountStarted(fiber);
|
1382 | }
|
1383 | }
|
1384 | }
|
1385 | function markComponentPassiveEffectUnmountStopped() {
|
1386 | {
|
1387 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStopped === 'function') {
|
1388 | injectedProfilingHooks.markComponentPassiveEffectUnmountStopped();
|
1389 | }
|
1390 | }
|
1391 | }
|
1392 | function markComponentLayoutEffectMountStarted(fiber) {
|
1393 | {
|
1394 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStarted === 'function') {
|
1395 | injectedProfilingHooks.markComponentLayoutEffectMountStarted(fiber);
|
1396 | }
|
1397 | }
|
1398 | }
|
1399 | function markComponentLayoutEffectMountStopped() {
|
1400 | {
|
1401 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStopped === 'function') {
|
1402 | injectedProfilingHooks.markComponentLayoutEffectMountStopped();
|
1403 | }
|
1404 | }
|
1405 | }
|
1406 | function markComponentLayoutEffectUnmountStarted(fiber) {
|
1407 | {
|
1408 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStarted === 'function') {
|
1409 | injectedProfilingHooks.markComponentLayoutEffectUnmountStarted(fiber);
|
1410 | }
|
1411 | }
|
1412 | }
|
1413 | function markComponentLayoutEffectUnmountStopped() {
|
1414 | {
|
1415 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStopped === 'function') {
|
1416 | injectedProfilingHooks.markComponentLayoutEffectUnmountStopped();
|
1417 | }
|
1418 | }
|
1419 | }
|
1420 | function markComponentErrored(fiber, thrownValue, lanes) {
|
1421 | {
|
1422 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentErrored === 'function') {
|
1423 | injectedProfilingHooks.markComponentErrored(fiber, thrownValue, lanes);
|
1424 | }
|
1425 | }
|
1426 | }
|
1427 | function markComponentSuspended(fiber, wakeable, lanes) {
|
1428 | {
|
1429 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentSuspended === 'function') {
|
1430 | injectedProfilingHooks.markComponentSuspended(fiber, wakeable, lanes);
|
1431 | }
|
1432 | }
|
1433 | }
|
1434 | function markLayoutEffectsStarted(lanes) {
|
1435 | {
|
1436 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStarted === 'function') {
|
1437 | injectedProfilingHooks.markLayoutEffectsStarted(lanes);
|
1438 | }
|
1439 | }
|
1440 | }
|
1441 | function markLayoutEffectsStopped() {
|
1442 | {
|
1443 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStopped === 'function') {
|
1444 | injectedProfilingHooks.markLayoutEffectsStopped();
|
1445 | }
|
1446 | }
|
1447 | }
|
1448 | function markPassiveEffectsStarted(lanes) {
|
1449 | {
|
1450 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStarted === 'function') {
|
1451 | injectedProfilingHooks.markPassiveEffectsStarted(lanes);
|
1452 | }
|
1453 | }
|
1454 | }
|
1455 | function markPassiveEffectsStopped() {
|
1456 | {
|
1457 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStopped === 'function') {
|
1458 | injectedProfilingHooks.markPassiveEffectsStopped();
|
1459 | }
|
1460 | }
|
1461 | }
|
1462 | function markRenderStarted(lanes) {
|
1463 | {
|
1464 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderStarted === 'function') {
|
1465 | injectedProfilingHooks.markRenderStarted(lanes);
|
1466 | }
|
1467 | }
|
1468 | }
|
1469 | function markRenderYielded() {
|
1470 | {
|
1471 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderYielded === 'function') {
|
1472 | injectedProfilingHooks.markRenderYielded();
|
1473 | }
|
1474 | }
|
1475 | }
|
1476 | function markRenderStopped() {
|
1477 | {
|
1478 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderStopped === 'function') {
|
1479 | injectedProfilingHooks.markRenderStopped();
|
1480 | }
|
1481 | }
|
1482 | }
|
1483 | function markRenderScheduled(lane) {
|
1484 | {
|
1485 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderScheduled === 'function') {
|
1486 | injectedProfilingHooks.markRenderScheduled(lane);
|
1487 | }
|
1488 | }
|
1489 | }
|
1490 | function markForceUpdateScheduled(fiber, lane) {
|
1491 | {
|
1492 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markForceUpdateScheduled === 'function') {
|
1493 | injectedProfilingHooks.markForceUpdateScheduled(fiber, lane);
|
1494 | }
|
1495 | }
|
1496 | }
|
1497 | function markStateUpdateScheduled(fiber, lane) {
|
1498 | {
|
1499 | if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markStateUpdateScheduled === 'function') {
|
1500 | injectedProfilingHooks.markStateUpdateScheduled(fiber, lane);
|
1501 | }
|
1502 | }
|
1503 | }
|
1504 |
|
1505 | var NoMode =
|
1506 |
|
1507 | 0;
|
1508 |
|
1509 | var ConcurrentMode =
|
1510 |
|
1511 | 1;
|
1512 | var ProfileMode =
|
1513 |
|
1514 | 2;
|
1515 | var StrictLegacyMode =
|
1516 |
|
1517 | 8;
|
1518 | var StrictEffectsMode =
|
1519 |
|
1520 | 16;
|
1521 |
|
1522 |
|
1523 | var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback;
|
1524 |
|
1525 |
|
1526 |
|
1527 | var log = Math.log;
|
1528 | var LN2 = Math.LN2;
|
1529 |
|
1530 | function clz32Fallback(x) {
|
1531 | var asUint = x >>> 0;
|
1532 |
|
1533 | if (asUint === 0) {
|
1534 | return 32;
|
1535 | }
|
1536 |
|
1537 | return 31 - (log(asUint) / LN2 | 0) | 0;
|
1538 | }
|
1539 |
|
1540 |
|
1541 |
|
1542 | var TotalLanes = 31;
|
1543 | var NoLanes =
|
1544 |
|
1545 | 0;
|
1546 | var NoLane =
|
1547 |
|
1548 | 0;
|
1549 | var SyncLane =
|
1550 |
|
1551 | 1;
|
1552 | var InputContinuousHydrationLane =
|
1553 |
|
1554 | 2;
|
1555 | var InputContinuousLane =
|
1556 |
|
1557 | 4;
|
1558 | var DefaultHydrationLane =
|
1559 |
|
1560 | 8;
|
1561 | var DefaultLane =
|
1562 |
|
1563 | 16;
|
1564 | var TransitionHydrationLane =
|
1565 |
|
1566 | 32;
|
1567 | var TransitionLanes =
|
1568 |
|
1569 | 4194240;
|
1570 | var TransitionLane1 =
|
1571 |
|
1572 | 64;
|
1573 | var TransitionLane2 =
|
1574 |
|
1575 | 128;
|
1576 | var TransitionLane3 =
|
1577 |
|
1578 | 256;
|
1579 | var TransitionLane4 =
|
1580 |
|
1581 | 512;
|
1582 | var TransitionLane5 =
|
1583 |
|
1584 | 1024;
|
1585 | var TransitionLane6 =
|
1586 |
|
1587 | 2048;
|
1588 | var TransitionLane7 =
|
1589 |
|
1590 | 4096;
|
1591 | var TransitionLane8 =
|
1592 |
|
1593 | 8192;
|
1594 | var TransitionLane9 =
|
1595 |
|
1596 | 16384;
|
1597 | var TransitionLane10 =
|
1598 |
|
1599 | 32768;
|
1600 | var TransitionLane11 =
|
1601 |
|
1602 | 65536;
|
1603 | var TransitionLane12 =
|
1604 |
|
1605 | 131072;
|
1606 | var TransitionLane13 =
|
1607 |
|
1608 | 262144;
|
1609 | var TransitionLane14 =
|
1610 |
|
1611 | 524288;
|
1612 | var TransitionLane15 =
|
1613 |
|
1614 | 1048576;
|
1615 | var TransitionLane16 =
|
1616 |
|
1617 | 2097152;
|
1618 | var RetryLanes =
|
1619 |
|
1620 | 130023424;
|
1621 | var RetryLane1 =
|
1622 |
|
1623 | 4194304;
|
1624 | var RetryLane2 =
|
1625 |
|
1626 | 8388608;
|
1627 | var RetryLane3 =
|
1628 |
|
1629 | 16777216;
|
1630 | var RetryLane4 =
|
1631 |
|
1632 | 33554432;
|
1633 | var RetryLane5 =
|
1634 |
|
1635 | 67108864;
|
1636 | var SomeRetryLane = RetryLane1;
|
1637 | var SelectiveHydrationLane =
|
1638 |
|
1639 | 134217728;
|
1640 | var NonIdleLanes =
|
1641 |
|
1642 | 268435455;
|
1643 | var IdleHydrationLane =
|
1644 |
|
1645 | 268435456;
|
1646 | var IdleLane =
|
1647 |
|
1648 | 536870912;
|
1649 | var OffscreenLane =
|
1650 |
|
1651 | 1073741824;
|
1652 |
|
1653 |
|
1654 | function getLabelForLane(lane) {
|
1655 | {
|
1656 | if (lane & SyncLane) {
|
1657 | return 'Sync';
|
1658 | }
|
1659 |
|
1660 | if (lane & InputContinuousHydrationLane) {
|
1661 | return 'InputContinuousHydration';
|
1662 | }
|
1663 |
|
1664 | if (lane & InputContinuousLane) {
|
1665 | return 'InputContinuous';
|
1666 | }
|
1667 |
|
1668 | if (lane & DefaultHydrationLane) {
|
1669 | return 'DefaultHydration';
|
1670 | }
|
1671 |
|
1672 | if (lane & DefaultLane) {
|
1673 | return 'Default';
|
1674 | }
|
1675 |
|
1676 | if (lane & TransitionHydrationLane) {
|
1677 | return 'TransitionHydration';
|
1678 | }
|
1679 |
|
1680 | if (lane & TransitionLanes) {
|
1681 | return 'Transition';
|
1682 | }
|
1683 |
|
1684 | if (lane & RetryLanes) {
|
1685 | return 'Retry';
|
1686 | }
|
1687 |
|
1688 | if (lane & SelectiveHydrationLane) {
|
1689 | return 'SelectiveHydration';
|
1690 | }
|
1691 |
|
1692 | if (lane & IdleHydrationLane) {
|
1693 | return 'IdleHydration';
|
1694 | }
|
1695 |
|
1696 | if (lane & IdleLane) {
|
1697 | return 'Idle';
|
1698 | }
|
1699 |
|
1700 | if (lane & OffscreenLane) {
|
1701 | return 'Offscreen';
|
1702 | }
|
1703 | }
|
1704 | }
|
1705 | var NoTimestamp = -1;
|
1706 | var nextTransitionLane = TransitionLane1;
|
1707 | var nextRetryLane = RetryLane1;
|
1708 |
|
1709 | function getHighestPriorityLanes(lanes) {
|
1710 | switch (getHighestPriorityLane(lanes)) {
|
1711 | case SyncLane:
|
1712 | return SyncLane;
|
1713 |
|
1714 | case InputContinuousHydrationLane:
|
1715 | return InputContinuousHydrationLane;
|
1716 |
|
1717 | case InputContinuousLane:
|
1718 | return InputContinuousLane;
|
1719 |
|
1720 | case DefaultHydrationLane:
|
1721 | return DefaultHydrationLane;
|
1722 |
|
1723 | case DefaultLane:
|
1724 | return DefaultLane;
|
1725 |
|
1726 | case TransitionHydrationLane:
|
1727 | return TransitionHydrationLane;
|
1728 |
|
1729 | case TransitionLane1:
|
1730 | case TransitionLane2:
|
1731 | case TransitionLane3:
|
1732 | case TransitionLane4:
|
1733 | case TransitionLane5:
|
1734 | case TransitionLane6:
|
1735 | case TransitionLane7:
|
1736 | case TransitionLane8:
|
1737 | case TransitionLane9:
|
1738 | case TransitionLane10:
|
1739 | case TransitionLane11:
|
1740 | case TransitionLane12:
|
1741 | case TransitionLane13:
|
1742 | case TransitionLane14:
|
1743 | case TransitionLane15:
|
1744 | case TransitionLane16:
|
1745 | return lanes & TransitionLanes;
|
1746 |
|
1747 | case RetryLane1:
|
1748 | case RetryLane2:
|
1749 | case RetryLane3:
|
1750 | case RetryLane4:
|
1751 | case RetryLane5:
|
1752 | return lanes & RetryLanes;
|
1753 |
|
1754 | case SelectiveHydrationLane:
|
1755 | return SelectiveHydrationLane;
|
1756 |
|
1757 | case IdleHydrationLane:
|
1758 | return IdleHydrationLane;
|
1759 |
|
1760 | case IdleLane:
|
1761 | return IdleLane;
|
1762 |
|
1763 | case OffscreenLane:
|
1764 | return OffscreenLane;
|
1765 |
|
1766 | default:
|
1767 | {
|
1768 | error('Should have found matching lanes. This is a bug in React.');
|
1769 | }
|
1770 |
|
1771 |
|
1772 | return lanes;
|
1773 | }
|
1774 | }
|
1775 |
|
1776 | function getNextLanes(root, wipLanes) {
|
1777 |
|
1778 | var pendingLanes = root.pendingLanes;
|
1779 |
|
1780 | if (pendingLanes === NoLanes) {
|
1781 | return NoLanes;
|
1782 | }
|
1783 |
|
1784 | var nextLanes = NoLanes;
|
1785 | var suspendedLanes = root.suspendedLanes;
|
1786 | var pingedLanes = root.pingedLanes;
|
1787 |
|
1788 |
|
1789 | var nonIdlePendingLanes = pendingLanes & NonIdleLanes;
|
1790 |
|
1791 | if (nonIdlePendingLanes !== NoLanes) {
|
1792 | var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
|
1793 |
|
1794 | if (nonIdleUnblockedLanes !== NoLanes) {
|
1795 | nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
|
1796 | } else {
|
1797 | var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
|
1798 |
|
1799 | if (nonIdlePingedLanes !== NoLanes) {
|
1800 | nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
|
1801 | }
|
1802 | }
|
1803 | } else {
|
1804 |
|
1805 | var unblockedLanes = pendingLanes & ~suspendedLanes;
|
1806 |
|
1807 | if (unblockedLanes !== NoLanes) {
|
1808 | nextLanes = getHighestPriorityLanes(unblockedLanes);
|
1809 | } else {
|
1810 | if (pingedLanes !== NoLanes) {
|
1811 | nextLanes = getHighestPriorityLanes(pingedLanes);
|
1812 | }
|
1813 | }
|
1814 | }
|
1815 |
|
1816 | if (nextLanes === NoLanes) {
|
1817 |
|
1818 |
|
1819 | return NoLanes;
|
1820 | }
|
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 | if (wipLanes !== NoLanes && wipLanes !== nextLanes &&
|
1826 |
|
1827 | (wipLanes & suspendedLanes) === NoLanes) {
|
1828 | var nextLane = getHighestPriorityLane(nextLanes);
|
1829 | var wipLane = getHighestPriorityLane(wipLanes);
|
1830 |
|
1831 | if (
|
1832 |
|
1833 | nextLane >= wipLane ||
|
1834 |
|
1835 |
|
1836 | nextLane === DefaultLane && (wipLane & TransitionLanes) !== NoLanes) {
|
1837 |
|
1838 | return wipLanes;
|
1839 | }
|
1840 | }
|
1841 |
|
1842 | if ((nextLanes & InputContinuousLane) !== NoLanes) {
|
1843 |
|
1844 |
|
1845 |
|
1846 |
|
1847 | nextLanes |= pendingLanes & DefaultLane;
|
1848 | }
|
1849 |
|
1850 |
|
1851 |
|
1852 |
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 |
|
1864 |
|
1865 |
|
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 | var entangledLanes = root.entangledLanes;
|
1873 |
|
1874 | if (entangledLanes !== NoLanes) {
|
1875 | var entanglements = root.entanglements;
|
1876 | var lanes = nextLanes & entangledLanes;
|
1877 |
|
1878 | while (lanes > 0) {
|
1879 | var index = pickArbitraryLaneIndex(lanes);
|
1880 | var lane = 1 << index;
|
1881 | nextLanes |= entanglements[index];
|
1882 | lanes &= ~lane;
|
1883 | }
|
1884 | }
|
1885 |
|
1886 | return nextLanes;
|
1887 | }
|
1888 | function getMostRecentEventTime(root, lanes) {
|
1889 | var eventTimes = root.eventTimes;
|
1890 | var mostRecentEventTime = NoTimestamp;
|
1891 |
|
1892 | while (lanes > 0) {
|
1893 | var index = pickArbitraryLaneIndex(lanes);
|
1894 | var lane = 1 << index;
|
1895 | var eventTime = eventTimes[index];
|
1896 |
|
1897 | if (eventTime > mostRecentEventTime) {
|
1898 | mostRecentEventTime = eventTime;
|
1899 | }
|
1900 |
|
1901 | lanes &= ~lane;
|
1902 | }
|
1903 |
|
1904 | return mostRecentEventTime;
|
1905 | }
|
1906 |
|
1907 | function computeExpirationTime(lane, currentTime) {
|
1908 | switch (lane) {
|
1909 | case SyncLane:
|
1910 | case InputContinuousHydrationLane:
|
1911 | case InputContinuousLane:
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 |
|
1918 |
|
1919 |
|
1920 |
|
1921 | return currentTime + 250;
|
1922 |
|
1923 | case DefaultHydrationLane:
|
1924 | case DefaultLane:
|
1925 | case TransitionHydrationLane:
|
1926 | case TransitionLane1:
|
1927 | case TransitionLane2:
|
1928 | case TransitionLane3:
|
1929 | case TransitionLane4:
|
1930 | case TransitionLane5:
|
1931 | case TransitionLane6:
|
1932 | case TransitionLane7:
|
1933 | case TransitionLane8:
|
1934 | case TransitionLane9:
|
1935 | case TransitionLane10:
|
1936 | case TransitionLane11:
|
1937 | case TransitionLane12:
|
1938 | case TransitionLane13:
|
1939 | case TransitionLane14:
|
1940 | case TransitionLane15:
|
1941 | case TransitionLane16:
|
1942 | return currentTime + 5000;
|
1943 |
|
1944 | case RetryLane1:
|
1945 | case RetryLane2:
|
1946 | case RetryLane3:
|
1947 | case RetryLane4:
|
1948 | case RetryLane5:
|
1949 |
|
1950 |
|
1951 |
|
1952 |
|
1953 |
|
1954 | return NoTimestamp;
|
1955 |
|
1956 | case SelectiveHydrationLane:
|
1957 | case IdleHydrationLane:
|
1958 | case IdleLane:
|
1959 | case OffscreenLane:
|
1960 |
|
1961 | return NoTimestamp;
|
1962 |
|
1963 | default:
|
1964 | {
|
1965 | error('Should have found matching lanes. This is a bug in React.');
|
1966 | }
|
1967 |
|
1968 | return NoTimestamp;
|
1969 | }
|
1970 | }
|
1971 |
|
1972 | function markStarvedLanesAsExpired(root, currentTime) {
|
1973 |
|
1974 |
|
1975 |
|
1976 | var pendingLanes = root.pendingLanes;
|
1977 | var suspendedLanes = root.suspendedLanes;
|
1978 | var pingedLanes = root.pingedLanes;
|
1979 | var expirationTimes = root.expirationTimes;
|
1980 |
|
1981 |
|
1982 |
|
1983 | var lanes = pendingLanes;
|
1984 |
|
1985 | while (lanes > 0) {
|
1986 | var index = pickArbitraryLaneIndex(lanes);
|
1987 | var lane = 1 << index;
|
1988 | var expirationTime = expirationTimes[index];
|
1989 |
|
1990 | if (expirationTime === NoTimestamp) {
|
1991 |
|
1992 |
|
1993 |
|
1994 | if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) {
|
1995 |
|
1996 | expirationTimes[index] = computeExpirationTime(lane, currentTime);
|
1997 | }
|
1998 | } else if (expirationTime <= currentTime) {
|
1999 |
|
2000 | root.expiredLanes |= lane;
|
2001 | }
|
2002 |
|
2003 | lanes &= ~lane;
|
2004 | }
|
2005 | }
|
2006 | function getLanesToRetrySynchronouslyOnError(root) {
|
2007 | var everythingButOffscreen = root.pendingLanes & ~OffscreenLane;
|
2008 |
|
2009 | if (everythingButOffscreen !== NoLanes) {
|
2010 | return everythingButOffscreen;
|
2011 | }
|
2012 |
|
2013 | if (everythingButOffscreen & OffscreenLane) {
|
2014 | return OffscreenLane;
|
2015 | }
|
2016 |
|
2017 | return NoLanes;
|
2018 | }
|
2019 | function includesSyncLane(lanes) {
|
2020 | return (lanes & SyncLane) !== NoLanes;
|
2021 | }
|
2022 | function includesNonIdleWork(lanes) {
|
2023 | return (lanes & NonIdleLanes) !== NoLanes;
|
2024 | }
|
2025 | function includesOnlyRetries(lanes) {
|
2026 | return (lanes & RetryLanes) === lanes;
|
2027 | }
|
2028 | function includesOnlyTransitions(lanes) {
|
2029 | return (lanes & TransitionLanes) === lanes;
|
2030 | }
|
2031 | function includesBlockingLane(root, lanes) {
|
2032 |
|
2033 | var SyncDefaultLanes = InputContinuousHydrationLane | InputContinuousLane | DefaultHydrationLane | DefaultLane;
|
2034 | return (lanes & SyncDefaultLanes) !== NoLanes;
|
2035 | }
|
2036 | function includesExpiredLane(root, lanes) {
|
2037 |
|
2038 |
|
2039 | return (lanes & root.expiredLanes) !== NoLanes;
|
2040 | }
|
2041 | function isTransitionLane(lane) {
|
2042 | return (lane & TransitionLanes) !== 0;
|
2043 | }
|
2044 | function claimNextTransitionLane() {
|
2045 |
|
2046 |
|
2047 |
|
2048 | var lane = nextTransitionLane;
|
2049 | nextTransitionLane <<= 1;
|
2050 |
|
2051 | if ((nextTransitionLane & TransitionLanes) === 0) {
|
2052 | nextTransitionLane = TransitionLane1;
|
2053 | }
|
2054 |
|
2055 | return lane;
|
2056 | }
|
2057 | function claimNextRetryLane() {
|
2058 | var lane = nextRetryLane;
|
2059 | nextRetryLane <<= 1;
|
2060 |
|
2061 | if ((nextRetryLane & RetryLanes) === 0) {
|
2062 | nextRetryLane = RetryLane1;
|
2063 | }
|
2064 |
|
2065 | return lane;
|
2066 | }
|
2067 | function getHighestPriorityLane(lanes) {
|
2068 | return lanes & -lanes;
|
2069 | }
|
2070 | function pickArbitraryLane(lanes) {
|
2071 |
|
2072 |
|
2073 |
|
2074 |
|
2075 | return getHighestPriorityLane(lanes);
|
2076 | }
|
2077 |
|
2078 | function pickArbitraryLaneIndex(lanes) {
|
2079 | return 31 - clz32(lanes);
|
2080 | }
|
2081 |
|
2082 | function laneToIndex(lane) {
|
2083 | return pickArbitraryLaneIndex(lane);
|
2084 | }
|
2085 |
|
2086 | function includesSomeLane(a, b) {
|
2087 | return (a & b) !== NoLanes;
|
2088 | }
|
2089 | function isSubsetOfLanes(set, subset) {
|
2090 | return (set & subset) === subset;
|
2091 | }
|
2092 | function mergeLanes(a, b) {
|
2093 | return a | b;
|
2094 | }
|
2095 | function removeLanes(set, subset) {
|
2096 | return set & ~subset;
|
2097 | }
|
2098 | function intersectLanes(a, b) {
|
2099 | return a & b;
|
2100 | }
|
2101 |
|
2102 |
|
2103 | function laneToLanes(lane) {
|
2104 | return lane;
|
2105 | }
|
2106 | function createLaneMap(initial) {
|
2107 |
|
2108 |
|
2109 | var laneMap = [];
|
2110 |
|
2111 | for (var i = 0; i < TotalLanes; i++) {
|
2112 | laneMap.push(initial);
|
2113 | }
|
2114 |
|
2115 | return laneMap;
|
2116 | }
|
2117 | function markRootUpdated(root, updateLane, eventTime) {
|
2118 | root.pendingLanes |= updateLane;
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 | if (updateLane !== IdleLane) {
|
2132 | root.suspendedLanes = NoLanes;
|
2133 | root.pingedLanes = NoLanes;
|
2134 | }
|
2135 |
|
2136 | var eventTimes = root.eventTimes;
|
2137 | var index = laneToIndex(updateLane);
|
2138 |
|
2139 |
|
2140 | eventTimes[index] = eventTime;
|
2141 | }
|
2142 | function markRootSuspended(root, suspendedLanes) {
|
2143 | root.suspendedLanes |= suspendedLanes;
|
2144 | root.pingedLanes &= ~suspendedLanes;
|
2145 |
|
2146 | var expirationTimes = root.expirationTimes;
|
2147 | var lanes = suspendedLanes;
|
2148 |
|
2149 | while (lanes > 0) {
|
2150 | var index = pickArbitraryLaneIndex(lanes);
|
2151 | var lane = 1 << index;
|
2152 | expirationTimes[index] = NoTimestamp;
|
2153 | lanes &= ~lane;
|
2154 | }
|
2155 | }
|
2156 | function markRootPinged(root, pingedLanes, eventTime) {
|
2157 | root.pingedLanes |= root.suspendedLanes & pingedLanes;
|
2158 | }
|
2159 | function markRootFinished(root, remainingLanes) {
|
2160 | var noLongerPendingLanes = root.pendingLanes & ~remainingLanes;
|
2161 | root.pendingLanes = remainingLanes;
|
2162 |
|
2163 | root.suspendedLanes = 0;
|
2164 | root.pingedLanes = 0;
|
2165 | root.expiredLanes &= remainingLanes;
|
2166 | root.mutableReadLanes &= remainingLanes;
|
2167 | root.entangledLanes &= remainingLanes;
|
2168 | var entanglements = root.entanglements;
|
2169 | var eventTimes = root.eventTimes;
|
2170 | var expirationTimes = root.expirationTimes;
|
2171 |
|
2172 | var lanes = noLongerPendingLanes;
|
2173 |
|
2174 | while (lanes > 0) {
|
2175 | var index = pickArbitraryLaneIndex(lanes);
|
2176 | var lane = 1 << index;
|
2177 | entanglements[index] = NoLanes;
|
2178 | eventTimes[index] = NoTimestamp;
|
2179 | expirationTimes[index] = NoTimestamp;
|
2180 | lanes &= ~lane;
|
2181 | }
|
2182 | }
|
2183 | function markRootEntangled(root, entangledLanes) {
|
2184 |
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 |
|
2195 | var rootEntangledLanes = root.entangledLanes |= entangledLanes;
|
2196 | var entanglements = root.entanglements;
|
2197 | var lanes = rootEntangledLanes;
|
2198 |
|
2199 | while (lanes) {
|
2200 | var index = pickArbitraryLaneIndex(lanes);
|
2201 | var lane = 1 << index;
|
2202 |
|
2203 | if (
|
2204 | lane & entangledLanes |
|
2205 | entanglements[index] & entangledLanes) {
|
2206 | entanglements[index] |= entangledLanes;
|
2207 | }
|
2208 |
|
2209 | lanes &= ~lane;
|
2210 | }
|
2211 | }
|
2212 | function getBumpedLaneForHydration(root, renderLanes) {
|
2213 | var renderLane = getHighestPriorityLane(renderLanes);
|
2214 | var lane;
|
2215 |
|
2216 | switch (renderLane) {
|
2217 | case InputContinuousLane:
|
2218 | lane = InputContinuousHydrationLane;
|
2219 | break;
|
2220 |
|
2221 | case DefaultLane:
|
2222 | lane = DefaultHydrationLane;
|
2223 | break;
|
2224 |
|
2225 | case TransitionLane1:
|
2226 | case TransitionLane2:
|
2227 | case TransitionLane3:
|
2228 | case TransitionLane4:
|
2229 | case TransitionLane5:
|
2230 | case TransitionLane6:
|
2231 | case TransitionLane7:
|
2232 | case TransitionLane8:
|
2233 | case TransitionLane9:
|
2234 | case TransitionLane10:
|
2235 | case TransitionLane11:
|
2236 | case TransitionLane12:
|
2237 | case TransitionLane13:
|
2238 | case TransitionLane14:
|
2239 | case TransitionLane15:
|
2240 | case TransitionLane16:
|
2241 | case RetryLane1:
|
2242 | case RetryLane2:
|
2243 | case RetryLane3:
|
2244 | case RetryLane4:
|
2245 | case RetryLane5:
|
2246 | lane = TransitionHydrationLane;
|
2247 | break;
|
2248 |
|
2249 | case IdleLane:
|
2250 | lane = IdleHydrationLane;
|
2251 | break;
|
2252 |
|
2253 | default:
|
2254 |
|
2255 |
|
2256 | lane = NoLane;
|
2257 | break;
|
2258 | }
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 | if ((lane & (root.suspendedLanes | renderLanes)) !== NoLane) {
|
2264 |
|
2265 | return NoLane;
|
2266 | }
|
2267 |
|
2268 | return lane;
|
2269 | }
|
2270 | function addFiberToLanesMap(root, fiber, lanes) {
|
2271 |
|
2272 | if (!isDevToolsPresent) {
|
2273 | return;
|
2274 | }
|
2275 |
|
2276 | var pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
|
2277 |
|
2278 | while (lanes > 0) {
|
2279 | var index = laneToIndex(lanes);
|
2280 | var lane = 1 << index;
|
2281 | var updaters = pendingUpdatersLaneMap[index];
|
2282 | updaters.add(fiber);
|
2283 | lanes &= ~lane;
|
2284 | }
|
2285 | }
|
2286 | function movePendingFibersToMemoized(root, lanes) {
|
2287 |
|
2288 | if (!isDevToolsPresent) {
|
2289 | return;
|
2290 | }
|
2291 |
|
2292 | var pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
|
2293 | var memoizedUpdaters = root.memoizedUpdaters;
|
2294 |
|
2295 | while (lanes > 0) {
|
2296 | var index = laneToIndex(lanes);
|
2297 | var lane = 1 << index;
|
2298 | var updaters = pendingUpdatersLaneMap[index];
|
2299 |
|
2300 | if (updaters.size > 0) {
|
2301 | updaters.forEach(function (fiber) {
|
2302 | var alternate = fiber.alternate;
|
2303 |
|
2304 | if (alternate === null || !memoizedUpdaters.has(alternate)) {
|
2305 | memoizedUpdaters.add(fiber);
|
2306 | }
|
2307 | });
|
2308 | updaters.clear();
|
2309 | }
|
2310 |
|
2311 | lanes &= ~lane;
|
2312 | }
|
2313 | }
|
2314 |
|
2315 | var DiscreteEventPriority = SyncLane;
|
2316 | var ContinuousEventPriority = InputContinuousLane;
|
2317 | var DefaultEventPriority = DefaultLane;
|
2318 | var IdleEventPriority = IdleLane;
|
2319 | var currentUpdatePriority = NoLane;
|
2320 | function getCurrentUpdatePriority() {
|
2321 | return currentUpdatePriority;
|
2322 | }
|
2323 | function setCurrentUpdatePriority(newPriority) {
|
2324 | currentUpdatePriority = newPriority;
|
2325 | }
|
2326 | function higherEventPriority(a, b) {
|
2327 | return a !== 0 && a < b ? a : b;
|
2328 | }
|
2329 | function lowerEventPriority(a, b) {
|
2330 | return a === 0 || a > b ? a : b;
|
2331 | }
|
2332 | function isHigherEventPriority(a, b) {
|
2333 | return a !== 0 && a < b;
|
2334 | }
|
2335 | function lanesToEventPriority(lanes) {
|
2336 | var lane = getHighestPriorityLane(lanes);
|
2337 |
|
2338 | if (!isHigherEventPriority(DiscreteEventPriority, lane)) {
|
2339 | return DiscreteEventPriority;
|
2340 | }
|
2341 |
|
2342 | if (!isHigherEventPriority(ContinuousEventPriority, lane)) {
|
2343 | return ContinuousEventPriority;
|
2344 | }
|
2345 |
|
2346 | if (includesNonIdleWork(lane)) {
|
2347 | return DefaultEventPriority;
|
2348 | }
|
2349 |
|
2350 | return IdleEventPriority;
|
2351 | }
|
2352 |
|
2353 |
|
2354 |
|
2355 | function shim() {
|
2356 | throw new Error('The current renderer does not support hydration. ' + 'This error is likely caused by a bug in React. ' + 'Please file an issue.');
|
2357 | }
|
2358 | var isSuspenseInstancePending = shim;
|
2359 | var isSuspenseInstanceFallback = shim;
|
2360 | var registerSuspenseInstanceRetry = shim;
|
2361 | var hydrateTextInstance = shim;
|
2362 | var clearSuspenseBoundary = shim;
|
2363 | var clearSuspenseBoundaryFromContainer = shim;
|
2364 | var errorHydratingContainer = shim;
|
2365 |
|
2366 | var pooledTransform = new transform();
|
2367 | var NO_CONTEXT = {};
|
2368 | var UPDATE_SIGNAL = {};
|
2369 |
|
2370 | {
|
2371 | Object.freeze(NO_CONTEXT);
|
2372 | Object.freeze(UPDATE_SIGNAL);
|
2373 | }
|
2374 |
|
2375 |
|
2376 |
|
2377 | function addEventListeners(instance, type, listener) {
|
2378 |
|
2379 |
|
2380 | if (!instance._listeners) {
|
2381 | instance._listeners = {};
|
2382 | instance._subscriptions = {};
|
2383 | }
|
2384 |
|
2385 | instance._listeners[type] = listener;
|
2386 |
|
2387 | if (listener) {
|
2388 | if (!instance._subscriptions[type]) {
|
2389 | instance._subscriptions[type] = instance.subscribe(type, createEventHandler(instance), instance);
|
2390 | }
|
2391 | } else {
|
2392 | if (instance._subscriptions[type]) {
|
2393 | instance._subscriptions[type]();
|
2394 |
|
2395 | delete instance._subscriptions[type];
|
2396 | }
|
2397 | }
|
2398 | }
|
2399 |
|
2400 | function createEventHandler(instance) {
|
2401 | return function handleEvent(event) {
|
2402 | var listener = instance._listeners[event.type];
|
2403 |
|
2404 | if (!listener) ; else if (typeof listener === 'function') {
|
2405 | listener.call(instance, event);
|
2406 | } else if (listener.handleEvent) {
|
2407 | listener.handleEvent(event);
|
2408 | }
|
2409 | };
|
2410 | }
|
2411 |
|
2412 | function destroyEventListeners(instance) {
|
2413 | if (instance._subscriptions) {
|
2414 | for (var type in instance._subscriptions) {
|
2415 | instance._subscriptions[type]();
|
2416 | }
|
2417 | }
|
2418 |
|
2419 | instance._subscriptions = null;
|
2420 | instance._listeners = null;
|
2421 | }
|
2422 |
|
2423 | function getScaleX(props) {
|
2424 | if (props.scaleX != null) {
|
2425 | return props.scaleX;
|
2426 | } else if (props.scale != null) {
|
2427 | return props.scale;
|
2428 | } else {
|
2429 | return 1;
|
2430 | }
|
2431 | }
|
2432 |
|
2433 | function getScaleY(props) {
|
2434 | if (props.scaleY != null) {
|
2435 | return props.scaleY;
|
2436 | } else if (props.scale != null) {
|
2437 | return props.scale;
|
2438 | } else {
|
2439 | return 1;
|
2440 | }
|
2441 | }
|
2442 |
|
2443 | function isSameFont(oldFont, newFont) {
|
2444 | if (oldFont === newFont) {
|
2445 | return true;
|
2446 | } else if (typeof newFont === 'string' || typeof oldFont === 'string') {
|
2447 | return false;
|
2448 | } else {
|
2449 | return newFont.fontSize === oldFont.fontSize && newFont.fontStyle === oldFont.fontStyle && newFont.fontVariant === oldFont.fontVariant && newFont.fontWeight === oldFont.fontWeight && newFont.fontFamily === oldFont.fontFamily;
|
2450 | }
|
2451 | }
|
2452 |
|
2453 |
|
2454 |
|
2455 | function applyClippingRectangleProps(instance, props) {
|
2456 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2457 | applyNodeProps(instance, props, prevProps);
|
2458 | instance.width = props.width;
|
2459 | instance.height = props.height;
|
2460 | }
|
2461 |
|
2462 | function applyGroupProps(instance, props) {
|
2463 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2464 | applyNodeProps(instance, props, prevProps);
|
2465 | instance.width = props.width;
|
2466 | instance.height = props.height;
|
2467 | }
|
2468 |
|
2469 | function applyNodeProps(instance, props) {
|
2470 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2471 | var scaleX = getScaleX(props);
|
2472 | var scaleY = getScaleY(props);
|
2473 | 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);
|
2474 |
|
2475 | if (props.transform != null) {
|
2476 | pooledTransform.transform(props.transform);
|
2477 | }
|
2478 |
|
2479 | 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) {
|
2480 | instance.transformTo(pooledTransform);
|
2481 | }
|
2482 |
|
2483 | if (props.cursor !== prevProps.cursor || props.title !== prevProps.title) {
|
2484 | instance.indicate(props.cursor, props.title);
|
2485 | }
|
2486 |
|
2487 | if (instance.blend && props.opacity !== prevProps.opacity) {
|
2488 | instance.blend(props.opacity == null ? 1 : props.opacity);
|
2489 | }
|
2490 |
|
2491 | if (props.visible !== prevProps.visible) {
|
2492 | if (props.visible == null || props.visible) {
|
2493 | instance.show();
|
2494 | } else {
|
2495 | instance.hide();
|
2496 | }
|
2497 | }
|
2498 |
|
2499 | for (var type in EVENT_TYPES) {
|
2500 | addEventListeners(instance, EVENT_TYPES[type], props[type]);
|
2501 | }
|
2502 | }
|
2503 |
|
2504 | function applyRenderableNodeProps(instance, props) {
|
2505 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2506 | applyNodeProps(instance, props, prevProps);
|
2507 |
|
2508 | if (prevProps.fill !== props.fill) {
|
2509 | if (props.fill && props.fill.applyFill) {
|
2510 | props.fill.applyFill(instance);
|
2511 | } else {
|
2512 | instance.fill(props.fill);
|
2513 | }
|
2514 | }
|
2515 |
|
2516 | if (prevProps.stroke !== props.stroke || prevProps.strokeWidth !== props.strokeWidth || prevProps.strokeCap !== props.strokeCap || prevProps.strokeJoin !== props.strokeJoin ||
|
2517 | prevProps.strokeDash !== props.strokeDash) {
|
2518 | instance.stroke(props.stroke, props.strokeWidth, props.strokeCap, props.strokeJoin, props.strokeDash);
|
2519 | }
|
2520 | }
|
2521 |
|
2522 | function applyShapeProps(instance, props) {
|
2523 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2524 | applyRenderableNodeProps(instance, props, prevProps);
|
2525 | var path = props.d || childrenAsString(props.children);
|
2526 | var prevDelta = instance._prevDelta;
|
2527 | var prevPath = instance._prevPath;
|
2528 |
|
2529 | if (path !== prevPath || path.delta !== prevDelta || prevProps.height !== props.height || prevProps.width !== props.width) {
|
2530 | instance.draw(path, props.width, props.height);
|
2531 | instance._prevDelta = path.delta;
|
2532 | instance._prevPath = path;
|
2533 | }
|
2534 | }
|
2535 |
|
2536 | function applyTextProps(instance, props) {
|
2537 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2538 | applyRenderableNodeProps(instance, props, prevProps);
|
2539 | var string = props.children;
|
2540 |
|
2541 | if (instance._currentString !== string || !isSameFont(props.font, prevProps.font) || props.alignment !== prevProps.alignment || props.path !== prevProps.path) {
|
2542 | instance.draw(string, props.font, props.alignment, props.path);
|
2543 | instance._currentString = string;
|
2544 | }
|
2545 | }
|
2546 | function appendInitialChild(parentInstance, child) {
|
2547 | if (typeof child === 'string') {
|
2548 |
|
2549 | throw new Error('Text children should already be flattened.');
|
2550 | }
|
2551 |
|
2552 | child.inject(parentInstance);
|
2553 | }
|
2554 | function createInstance(type, props, internalInstanceHandle) {
|
2555 | var instance;
|
2556 |
|
2557 | switch (type) {
|
2558 | case TYPES.CLIPPING_RECTANGLE:
|
2559 | instance = current.ClippingRectangle();
|
2560 | instance._applyProps = applyClippingRectangleProps;
|
2561 | break;
|
2562 |
|
2563 | case TYPES.GROUP:
|
2564 | instance = current.Group();
|
2565 | instance._applyProps = applyGroupProps;
|
2566 | break;
|
2567 |
|
2568 | case TYPES.SHAPE:
|
2569 | instance = current.Shape();
|
2570 | instance._applyProps = applyShapeProps;
|
2571 | break;
|
2572 |
|
2573 | case TYPES.TEXT:
|
2574 | instance = current.Text(props.children, props.font, props.alignment, props.path);
|
2575 | instance._applyProps = applyTextProps;
|
2576 | break;
|
2577 | }
|
2578 |
|
2579 | if (!instance) {
|
2580 | throw new Error("ReactART does not support the type \"" + type + "\"");
|
2581 | }
|
2582 |
|
2583 | instance._applyProps(instance, props);
|
2584 |
|
2585 | return instance;
|
2586 | }
|
2587 | function createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
|
2588 | return text;
|
2589 | }
|
2590 | function getPublicInstance(instance) {
|
2591 | return instance;
|
2592 | }
|
2593 | function prepareForCommit() {
|
2594 |
|
2595 | return null;
|
2596 | }
|
2597 | function prepareUpdate(domElement, type, oldProps, newProps) {
|
2598 | return UPDATE_SIGNAL;
|
2599 | }
|
2600 | function resetAfterCommit() {
|
2601 | }
|
2602 | function resetTextContent(domElement) {
|
2603 | }
|
2604 | function getRootHostContext() {
|
2605 | return NO_CONTEXT;
|
2606 | }
|
2607 | function getChildHostContext() {
|
2608 | return NO_CONTEXT;
|
2609 | }
|
2610 | var scheduleTimeout = setTimeout;
|
2611 | var cancelTimeout = clearTimeout;
|
2612 | var noTimeout = -1;
|
2613 | function shouldSetTextContent(type, props) {
|
2614 | return typeof props.children === 'string' || typeof props.children === 'number';
|
2615 | }
|
2616 | function getCurrentEventPriority() {
|
2617 | return DefaultEventPriority;
|
2618 | }
|
2619 |
|
2620 | var warnsIfNotActing = false;
|
2621 | function appendChild(parentInstance, child) {
|
2622 | if (child.parentNode === parentInstance) {
|
2623 | child.eject();
|
2624 | }
|
2625 |
|
2626 | child.inject(parentInstance);
|
2627 | }
|
2628 | function appendChildToContainer(parentInstance, child) {
|
2629 | if (child.parentNode === parentInstance) {
|
2630 | child.eject();
|
2631 | }
|
2632 |
|
2633 | child.inject(parentInstance);
|
2634 | }
|
2635 | function insertBefore(parentInstance, child, beforeChild) {
|
2636 | if (child === beforeChild) {
|
2637 | throw new Error('ReactART: Can not insert node before itself');
|
2638 | }
|
2639 |
|
2640 | child.injectBefore(beforeChild);
|
2641 | }
|
2642 | function insertInContainerBefore(parentInstance, child, beforeChild) {
|
2643 | if (child === beforeChild) {
|
2644 | throw new Error('ReactART: Can not insert node before itself');
|
2645 | }
|
2646 |
|
2647 | child.injectBefore(beforeChild);
|
2648 | }
|
2649 | function removeChild(parentInstance, child) {
|
2650 | destroyEventListeners(child);
|
2651 | child.eject();
|
2652 | }
|
2653 | function removeChildFromContainer(parentInstance, child) {
|
2654 | destroyEventListeners(child);
|
2655 | child.eject();
|
2656 | }
|
2657 | function commitUpdate(instance, updatePayload, type, oldProps, newProps) {
|
2658 | instance._applyProps(instance, newProps, oldProps);
|
2659 | }
|
2660 | function hideInstance(instance) {
|
2661 | instance.hide();
|
2662 | }
|
2663 | function unhideInstance(instance, props) {
|
2664 | if (props.visible == null || props.visible) {
|
2665 | instance.show();
|
2666 | }
|
2667 | }
|
2668 | function unhideTextInstance(textInstance, text) {
|
2669 | }
|
2670 | function clearContainer(container) {
|
2671 | }
|
2672 | function preparePortalMount(portalInstance) {
|
2673 | }
|
2674 |
|
2675 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
2676 | var prefix;
|
2677 | function describeBuiltInComponentFrame(name, source, ownerFn) {
|
2678 | {
|
2679 | if (prefix === undefined) {
|
2680 |
|
2681 | try {
|
2682 | throw Error();
|
2683 | } catch (x) {
|
2684 | var match = x.stack.trim().match(/\n( *(at )?)/);
|
2685 | prefix = match && match[1] || '';
|
2686 | }
|
2687 | }
|
2688 |
|
2689 |
|
2690 | return '\n' + prefix + name;
|
2691 | }
|
2692 | }
|
2693 | var reentry = false;
|
2694 | var componentFrameCache;
|
2695 |
|
2696 | {
|
2697 | var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
2698 | componentFrameCache = new PossiblyWeakMap();
|
2699 | }
|
2700 |
|
2701 | function describeNativeComponentFrame(fn, construct) {
|
2702 |
|
2703 | if ( !fn || reentry) {
|
2704 | return '';
|
2705 | }
|
2706 |
|
2707 | {
|
2708 | var frame = componentFrameCache.get(fn);
|
2709 |
|
2710 | if (frame !== undefined) {
|
2711 | return frame;
|
2712 | }
|
2713 | }
|
2714 |
|
2715 | var control;
|
2716 | reentry = true;
|
2717 | var previousPrepareStackTrace = Error.prepareStackTrace;
|
2718 |
|
2719 | Error.prepareStackTrace = undefined;
|
2720 | var previousDispatcher;
|
2721 |
|
2722 | {
|
2723 | previousDispatcher = ReactCurrentDispatcher.current;
|
2724 |
|
2725 |
|
2726 | ReactCurrentDispatcher.current = null;
|
2727 | disableLogs();
|
2728 | }
|
2729 |
|
2730 | try {
|
2731 |
|
2732 | if (construct) {
|
2733 |
|
2734 | var Fake = function () {
|
2735 | throw Error();
|
2736 | };
|
2737 |
|
2738 |
|
2739 | Object.defineProperty(Fake.prototype, 'props', {
|
2740 | set: function () {
|
2741 |
|
2742 |
|
2743 | throw Error();
|
2744 | }
|
2745 | });
|
2746 |
|
2747 | if (typeof Reflect === 'object' && Reflect.construct) {
|
2748 |
|
2749 |
|
2750 | try {
|
2751 | Reflect.construct(Fake, []);
|
2752 | } catch (x) {
|
2753 | control = x;
|
2754 | }
|
2755 |
|
2756 | Reflect.construct(fn, [], Fake);
|
2757 | } else {
|
2758 | try {
|
2759 | Fake.call();
|
2760 | } catch (x) {
|
2761 | control = x;
|
2762 | }
|
2763 |
|
2764 | fn.call(Fake.prototype);
|
2765 | }
|
2766 | } else {
|
2767 | try {
|
2768 | throw Error();
|
2769 | } catch (x) {
|
2770 | control = x;
|
2771 | }
|
2772 |
|
2773 | fn();
|
2774 | }
|
2775 | } catch (sample) {
|
2776 |
|
2777 | if (sample && control && typeof sample.stack === 'string') {
|
2778 |
|
2779 |
|
2780 | var sampleLines = sample.stack.split('\n');
|
2781 | var controlLines = control.stack.split('\n');
|
2782 | var s = sampleLines.length - 1;
|
2783 | var c = controlLines.length - 1;
|
2784 |
|
2785 | while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 |
|
2791 |
|
2792 | c--;
|
2793 | }
|
2794 |
|
2795 | for (; s >= 1 && c >= 0; s--, c--) {
|
2796 |
|
2797 |
|
2798 | if (sampleLines[s] !== controlLines[c]) {
|
2799 |
|
2800 |
|
2801 |
|
2802 |
|
2803 |
|
2804 | if (s !== 1 || c !== 1) {
|
2805 | do {
|
2806 | s--;
|
2807 | c--;
|
2808 |
|
2809 |
|
2810 | if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
2811 |
|
2812 | var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
|
2813 |
|
2814 |
|
2815 |
|
2816 |
|
2817 | if (fn.displayName && _frame.includes('<anonymous>')) {
|
2818 | _frame = _frame.replace('<anonymous>', fn.displayName);
|
2819 | }
|
2820 |
|
2821 | {
|
2822 | if (typeof fn === 'function') {
|
2823 | componentFrameCache.set(fn, _frame);
|
2824 | }
|
2825 | }
|
2826 |
|
2827 |
|
2828 | return _frame;
|
2829 | }
|
2830 | } while (s >= 1 && c >= 0);
|
2831 | }
|
2832 |
|
2833 | break;
|
2834 | }
|
2835 | }
|
2836 | }
|
2837 | } finally {
|
2838 | reentry = false;
|
2839 |
|
2840 | {
|
2841 | ReactCurrentDispatcher.current = previousDispatcher;
|
2842 | reenableLogs();
|
2843 | }
|
2844 |
|
2845 | Error.prepareStackTrace = previousPrepareStackTrace;
|
2846 | }
|
2847 |
|
2848 |
|
2849 | var name = fn ? fn.displayName || fn.name : '';
|
2850 | var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
|
2851 |
|
2852 | {
|
2853 | if (typeof fn === 'function') {
|
2854 | componentFrameCache.set(fn, syntheticFrame);
|
2855 | }
|
2856 | }
|
2857 |
|
2858 | return syntheticFrame;
|
2859 | }
|
2860 |
|
2861 | function describeClassComponentFrame(ctor, source, ownerFn) {
|
2862 | {
|
2863 | return describeNativeComponentFrame(ctor, true);
|
2864 | }
|
2865 | }
|
2866 | function describeFunctionComponentFrame(fn, source, ownerFn) {
|
2867 | {
|
2868 | return describeNativeComponentFrame(fn, false);
|
2869 | }
|
2870 | }
|
2871 |
|
2872 | function shouldConstruct(Component) {
|
2873 | var prototype = Component.prototype;
|
2874 | return !!(prototype && prototype.isReactComponent);
|
2875 | }
|
2876 |
|
2877 | function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
2878 |
|
2879 | if (type == null) {
|
2880 | return '';
|
2881 | }
|
2882 |
|
2883 | if (typeof type === 'function') {
|
2884 | {
|
2885 | return describeNativeComponentFrame(type, shouldConstruct(type));
|
2886 | }
|
2887 | }
|
2888 |
|
2889 | if (typeof type === 'string') {
|
2890 | return describeBuiltInComponentFrame(type);
|
2891 | }
|
2892 |
|
2893 | switch (type) {
|
2894 | case REACT_SUSPENSE_TYPE:
|
2895 | return describeBuiltInComponentFrame('Suspense');
|
2896 |
|
2897 | case REACT_SUSPENSE_LIST_TYPE:
|
2898 | return describeBuiltInComponentFrame('SuspenseList');
|
2899 | }
|
2900 |
|
2901 | if (typeof type === 'object') {
|
2902 | switch (type.$$typeof) {
|
2903 | case REACT_FORWARD_REF_TYPE:
|
2904 | return describeFunctionComponentFrame(type.render);
|
2905 |
|
2906 | case REACT_MEMO_TYPE:
|
2907 |
|
2908 | return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
2909 |
|
2910 | case REACT_LAZY_TYPE:
|
2911 | {
|
2912 | var lazyComponent = type;
|
2913 | var payload = lazyComponent._payload;
|
2914 | var init = lazyComponent._init;
|
2915 |
|
2916 | try {
|
2917 |
|
2918 | return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
2919 | } catch (x) {}
|
2920 | }
|
2921 | }
|
2922 | }
|
2923 |
|
2924 | return '';
|
2925 | }
|
2926 |
|
2927 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
2928 |
|
2929 | var loggedTypeFailures = {};
|
2930 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
2931 |
|
2932 | function setCurrentlyValidatingElement(element) {
|
2933 | {
|
2934 | if (element) {
|
2935 | var owner = element._owner;
|
2936 | var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
2937 | ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
2938 | } else {
|
2939 | ReactDebugCurrentFrame.setExtraStackFrame(null);
|
2940 | }
|
2941 | }
|
2942 | }
|
2943 |
|
2944 | function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
2945 | {
|
2946 |
|
2947 | var has = Function.call.bind(hasOwnProperty);
|
2948 |
|
2949 | for (var typeSpecName in typeSpecs) {
|
2950 | if (has(typeSpecs, typeSpecName)) {
|
2951 | var error$1 = void 0;
|
2952 |
|
2953 |
|
2954 |
|
2955 | try {
|
2956 |
|
2957 |
|
2958 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
2959 |
|
2960 | var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
2961 | err.name = 'Invariant Violation';
|
2962 | throw err;
|
2963 | }
|
2964 |
|
2965 | error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
2966 | } catch (ex) {
|
2967 | error$1 = ex;
|
2968 | }
|
2969 |
|
2970 | if (error$1 && !(error$1 instanceof Error)) {
|
2971 | setCurrentlyValidatingElement(element);
|
2972 |
|
2973 | error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
2974 |
|
2975 | setCurrentlyValidatingElement(null);
|
2976 | }
|
2977 |
|
2978 | if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
2979 |
|
2980 |
|
2981 | loggedTypeFailures[error$1.message] = true;
|
2982 | setCurrentlyValidatingElement(element);
|
2983 |
|
2984 | error('Failed %s type: %s', location, error$1.message);
|
2985 |
|
2986 | setCurrentlyValidatingElement(null);
|
2987 | }
|
2988 | }
|
2989 | }
|
2990 | }
|
2991 | }
|
2992 |
|
2993 | var valueStack = [];
|
2994 | var fiberStack;
|
2995 |
|
2996 | {
|
2997 | fiberStack = [];
|
2998 | }
|
2999 |
|
3000 | var index = -1;
|
3001 |
|
3002 | function createCursor(defaultValue) {
|
3003 | return {
|
3004 | current: defaultValue
|
3005 | };
|
3006 | }
|
3007 |
|
3008 | function pop(cursor, fiber) {
|
3009 | if (index < 0) {
|
3010 | {
|
3011 | error('Unexpected pop.');
|
3012 | }
|
3013 |
|
3014 | return;
|
3015 | }
|
3016 |
|
3017 | {
|
3018 | if (fiber !== fiberStack[index]) {
|
3019 | error('Unexpected Fiber popped.');
|
3020 | }
|
3021 | }
|
3022 |
|
3023 | cursor.current = valueStack[index];
|
3024 | valueStack[index] = null;
|
3025 |
|
3026 | {
|
3027 | fiberStack[index] = null;
|
3028 | }
|
3029 |
|
3030 | index--;
|
3031 | }
|
3032 |
|
3033 | function push(cursor, value, fiber) {
|
3034 | index++;
|
3035 | valueStack[index] = cursor.current;
|
3036 |
|
3037 | {
|
3038 | fiberStack[index] = fiber;
|
3039 | }
|
3040 |
|
3041 | cursor.current = value;
|
3042 | }
|
3043 |
|
3044 | var warnedAboutMissingGetChildContext;
|
3045 |
|
3046 | {
|
3047 | warnedAboutMissingGetChildContext = {};
|
3048 | }
|
3049 |
|
3050 | var emptyContextObject = {};
|
3051 |
|
3052 | {
|
3053 | Object.freeze(emptyContextObject);
|
3054 | }
|
3055 |
|
3056 |
|
3057 | var contextStackCursor = createCursor(emptyContextObject);
|
3058 |
|
3059 | var didPerformWorkStackCursor = createCursor(false);
|
3060 |
|
3061 |
|
3062 |
|
3063 | var previousContext = emptyContextObject;
|
3064 |
|
3065 | function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
|
3066 | {
|
3067 | if (didPushOwnContextIfProvider && isContextProvider(Component)) {
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 | return previousContext;
|
3073 | }
|
3074 |
|
3075 | return contextStackCursor.current;
|
3076 | }
|
3077 | }
|
3078 |
|
3079 | function cacheContext(workInProgress, unmaskedContext, maskedContext) {
|
3080 | {
|
3081 | var instance = workInProgress.stateNode;
|
3082 | instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
3083 | instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
3084 | }
|
3085 | }
|
3086 |
|
3087 | function getMaskedContext(workInProgress, unmaskedContext) {
|
3088 | {
|
3089 | var type = workInProgress.type;
|
3090 | var contextTypes = type.contextTypes;
|
3091 |
|
3092 | if (!contextTypes) {
|
3093 | return emptyContextObject;
|
3094 | }
|
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 | var instance = workInProgress.stateNode;
|
3100 |
|
3101 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
|
3102 | return instance.__reactInternalMemoizedMaskedChildContext;
|
3103 | }
|
3104 |
|
3105 | var context = {};
|
3106 |
|
3107 | for (var key in contextTypes) {
|
3108 | context[key] = unmaskedContext[key];
|
3109 | }
|
3110 |
|
3111 | {
|
3112 | var name = getComponentNameFromFiber(workInProgress) || 'Unknown';
|
3113 | checkPropTypes(contextTypes, context, 'context', name);
|
3114 | }
|
3115 |
|
3116 |
|
3117 |
|
3118 | if (instance) {
|
3119 | cacheContext(workInProgress, unmaskedContext, context);
|
3120 | }
|
3121 |
|
3122 | return context;
|
3123 | }
|
3124 | }
|
3125 |
|
3126 | function hasContextChanged() {
|
3127 | {
|
3128 | return didPerformWorkStackCursor.current;
|
3129 | }
|
3130 | }
|
3131 |
|
3132 | function isContextProvider(type) {
|
3133 | {
|
3134 | var childContextTypes = type.childContextTypes;
|
3135 | return childContextTypes !== null && childContextTypes !== undefined;
|
3136 | }
|
3137 | }
|
3138 |
|
3139 | function popContext(fiber) {
|
3140 | {
|
3141 | pop(didPerformWorkStackCursor, fiber);
|
3142 | pop(contextStackCursor, fiber);
|
3143 | }
|
3144 | }
|
3145 |
|
3146 | function popTopLevelContextObject(fiber) {
|
3147 | {
|
3148 | pop(didPerformWorkStackCursor, fiber);
|
3149 | pop(contextStackCursor, fiber);
|
3150 | }
|
3151 | }
|
3152 |
|
3153 | function pushTopLevelContextObject(fiber, context, didChange) {
|
3154 | {
|
3155 | if (contextStackCursor.current !== emptyContextObject) {
|
3156 | throw new Error('Unexpected context found on stack. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3157 | }
|
3158 |
|
3159 | push(contextStackCursor, context, fiber);
|
3160 | push(didPerformWorkStackCursor, didChange, fiber);
|
3161 | }
|
3162 | }
|
3163 |
|
3164 | function processChildContext(fiber, type, parentContext) {
|
3165 | {
|
3166 | var instance = fiber.stateNode;
|
3167 | var childContextTypes = type.childContextTypes;
|
3168 |
|
3169 |
|
3170 | if (typeof instance.getChildContext !== 'function') {
|
3171 | {
|
3172 | var componentName = getComponentNameFromFiber(fiber) || 'Unknown';
|
3173 |
|
3174 | if (!warnedAboutMissingGetChildContext[componentName]) {
|
3175 | warnedAboutMissingGetChildContext[componentName] = true;
|
3176 |
|
3177 | error('%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);
|
3178 | }
|
3179 | }
|
3180 |
|
3181 | return parentContext;
|
3182 | }
|
3183 |
|
3184 | var childContext = instance.getChildContext();
|
3185 |
|
3186 | for (var contextKey in childContext) {
|
3187 | if (!(contextKey in childContextTypes)) {
|
3188 | throw new Error((getComponentNameFromFiber(fiber) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes.");
|
3189 | }
|
3190 | }
|
3191 |
|
3192 | {
|
3193 | var name = getComponentNameFromFiber(fiber) || 'Unknown';
|
3194 | checkPropTypes(childContextTypes, childContext, 'child context', name);
|
3195 | }
|
3196 |
|
3197 | return assign({}, parentContext, childContext);
|
3198 | }
|
3199 | }
|
3200 |
|
3201 | function pushContextProvider(workInProgress) {
|
3202 | {
|
3203 | var instance = workInProgress.stateNode;
|
3204 |
|
3205 |
|
3206 |
|
3207 | var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
|
3208 |
|
3209 |
|
3210 | previousContext = contextStackCursor.current;
|
3211 | push(contextStackCursor, memoizedMergedChildContext, workInProgress);
|
3212 | push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
|
3213 | return true;
|
3214 | }
|
3215 | }
|
3216 |
|
3217 | function invalidateContextProvider(workInProgress, type, didChange) {
|
3218 | {
|
3219 | var instance = workInProgress.stateNode;
|
3220 |
|
3221 | if (!instance) {
|
3222 | throw new Error('Expected to have an instance by this point. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3223 | }
|
3224 |
|
3225 | if (didChange) {
|
3226 |
|
3227 |
|
3228 |
|
3229 | var mergedContext = processChildContext(workInProgress, type, previousContext);
|
3230 | instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
3231 |
|
3232 |
|
3233 | pop(didPerformWorkStackCursor, workInProgress);
|
3234 | pop(contextStackCursor, workInProgress);
|
3235 |
|
3236 | push(contextStackCursor, mergedContext, workInProgress);
|
3237 | push(didPerformWorkStackCursor, didChange, workInProgress);
|
3238 | } else {
|
3239 | pop(didPerformWorkStackCursor, workInProgress);
|
3240 | push(didPerformWorkStackCursor, didChange, workInProgress);
|
3241 | }
|
3242 | }
|
3243 | }
|
3244 |
|
3245 | function findCurrentUnmaskedContext(fiber) {
|
3246 | {
|
3247 |
|
3248 |
|
3249 | if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) {
|
3250 | throw new Error('Expected subtree parent to be a mounted class component. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3251 | }
|
3252 |
|
3253 | var node = fiber;
|
3254 |
|
3255 | do {
|
3256 | switch (node.tag) {
|
3257 | case HostRoot:
|
3258 | return node.stateNode.context;
|
3259 |
|
3260 | case ClassComponent:
|
3261 | {
|
3262 | var Component = node.type;
|
3263 |
|
3264 | if (isContextProvider(Component)) {
|
3265 | return node.stateNode.__reactInternalMemoizedMergedChildContext;
|
3266 | }
|
3267 |
|
3268 | break;
|
3269 | }
|
3270 | }
|
3271 |
|
3272 | node = node.return;
|
3273 | } while (node !== null);
|
3274 |
|
3275 | throw new Error('Found unexpected detached subtree parent. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3276 | }
|
3277 | }
|
3278 |
|
3279 | |
3280 |
|
3281 |
|
3282 |
|
3283 | function is(x, y) {
|
3284 | return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y
|
3285 | ;
|
3286 | }
|
3287 |
|
3288 | var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
3289 |
|
3290 | var syncQueue = null;
|
3291 | var includesLegacySyncCallbacks = false;
|
3292 | var isFlushingSyncQueue = false;
|
3293 | function scheduleSyncCallback(callback) {
|
3294 |
|
3295 |
|
3296 | if (syncQueue === null) {
|
3297 | syncQueue = [callback];
|
3298 | } else {
|
3299 |
|
3300 |
|
3301 | syncQueue.push(callback);
|
3302 | }
|
3303 | }
|
3304 | function scheduleLegacySyncCallback(callback) {
|
3305 | includesLegacySyncCallbacks = true;
|
3306 | scheduleSyncCallback(callback);
|
3307 | }
|
3308 | function flushSyncCallbacksOnlyInLegacyMode() {
|
3309 |
|
3310 |
|
3311 |
|
3312 |
|
3313 |
|
3314 | if (includesLegacySyncCallbacks) {
|
3315 | flushSyncCallbacks();
|
3316 | }
|
3317 | }
|
3318 | function flushSyncCallbacks() {
|
3319 | if (!isFlushingSyncQueue && syncQueue !== null) {
|
3320 |
|
3321 | isFlushingSyncQueue = true;
|
3322 | var i = 0;
|
3323 | var previousUpdatePriority = getCurrentUpdatePriority();
|
3324 |
|
3325 | try {
|
3326 | var isSync = true;
|
3327 | var queue = syncQueue;
|
3328 |
|
3329 |
|
3330 | setCurrentUpdatePriority(DiscreteEventPriority);
|
3331 |
|
3332 | for (; i < queue.length; i++) {
|
3333 | var callback = queue[i];
|
3334 |
|
3335 | do {
|
3336 | callback = callback(isSync);
|
3337 | } while (callback !== null);
|
3338 | }
|
3339 |
|
3340 | syncQueue = null;
|
3341 | includesLegacySyncCallbacks = false;
|
3342 | } catch (error) {
|
3343 |
|
3344 | if (syncQueue !== null) {
|
3345 | syncQueue = syncQueue.slice(i + 1);
|
3346 | }
|
3347 |
|
3348 |
|
3349 | scheduleCallback(ImmediatePriority, flushSyncCallbacks);
|
3350 | throw error;
|
3351 | } finally {
|
3352 | setCurrentUpdatePriority(previousUpdatePriority);
|
3353 | isFlushingSyncQueue = false;
|
3354 | }
|
3355 | }
|
3356 |
|
3357 | return null;
|
3358 | }
|
3359 |
|
3360 |
|
3361 |
|
3362 |
|
3363 | function isRootDehydrated(root) {
|
3364 | var currentState = root.current.memoizedState;
|
3365 | return currentState.isDehydrated;
|
3366 | }
|
3367 |
|
3368 | var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
|
3369 | var NoTransition = null;
|
3370 | function requestCurrentTransition() {
|
3371 | return ReactCurrentBatchConfig.transition;
|
3372 | }
|
3373 |
|
3374 | |
3375 |
|
3376 |
|
3377 |
|
3378 |
|
3379 |
|
3380 | function shallowEqual(objA, objB) {
|
3381 | if (objectIs(objA, objB)) {
|
3382 | return true;
|
3383 | }
|
3384 |
|
3385 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
3386 | return false;
|
3387 | }
|
3388 |
|
3389 | var keysA = Object.keys(objA);
|
3390 | var keysB = Object.keys(objB);
|
3391 |
|
3392 | if (keysA.length !== keysB.length) {
|
3393 | return false;
|
3394 | }
|
3395 |
|
3396 |
|
3397 | for (var i = 0; i < keysA.length; i++) {
|
3398 | var currentKey = keysA[i];
|
3399 |
|
3400 | if (!hasOwnProperty.call(objB, currentKey) || !objectIs(objA[currentKey], objB[currentKey])) {
|
3401 | return false;
|
3402 | }
|
3403 | }
|
3404 |
|
3405 | return true;
|
3406 | }
|
3407 |
|
3408 | function describeFiber(fiber) {
|
3409 | var owner = fiber._debugOwner ? fiber._debugOwner.type : null ;
|
3410 | var source = fiber._debugSource ;
|
3411 |
|
3412 | switch (fiber.tag) {
|
3413 | case HostComponent:
|
3414 | return describeBuiltInComponentFrame(fiber.type);
|
3415 |
|
3416 | case LazyComponent:
|
3417 | return describeBuiltInComponentFrame('Lazy');
|
3418 |
|
3419 | case SuspenseComponent:
|
3420 | return describeBuiltInComponentFrame('Suspense');
|
3421 |
|
3422 | case SuspenseListComponent:
|
3423 | return describeBuiltInComponentFrame('SuspenseList');
|
3424 |
|
3425 | case FunctionComponent:
|
3426 | case IndeterminateComponent:
|
3427 | case SimpleMemoComponent:
|
3428 | return describeFunctionComponentFrame(fiber.type);
|
3429 |
|
3430 | case ForwardRef:
|
3431 | return describeFunctionComponentFrame(fiber.type.render);
|
3432 |
|
3433 | case ClassComponent:
|
3434 | return describeClassComponentFrame(fiber.type);
|
3435 |
|
3436 | default:
|
3437 | return '';
|
3438 | }
|
3439 | }
|
3440 |
|
3441 | function getStackByFiberInDevAndProd(workInProgress) {
|
3442 | try {
|
3443 | var info = '';
|
3444 | var node = workInProgress;
|
3445 |
|
3446 | do {
|
3447 | info += describeFiber(node);
|
3448 | node = node.return;
|
3449 | } while (node);
|
3450 |
|
3451 | return info;
|
3452 | } catch (x) {
|
3453 | return '\nError generating stack: ' + x.message + '\n' + x.stack;
|
3454 | }
|
3455 | }
|
3456 |
|
3457 | var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
3458 | var current$1 = null;
|
3459 | var isRendering = false;
|
3460 | function getCurrentFiberOwnerNameInDevOrNull() {
|
3461 | {
|
3462 | if (current$1 === null) {
|
3463 | return null;
|
3464 | }
|
3465 |
|
3466 | var owner = current$1._debugOwner;
|
3467 |
|
3468 | if (owner !== null && typeof owner !== 'undefined') {
|
3469 | return getComponentNameFromFiber(owner);
|
3470 | }
|
3471 | }
|
3472 |
|
3473 | return null;
|
3474 | }
|
3475 |
|
3476 | function getCurrentFiberStackInDev() {
|
3477 | {
|
3478 | if (current$1 === null) {
|
3479 | return '';
|
3480 | }
|
3481 |
|
3482 |
|
3483 |
|
3484 | return getStackByFiberInDevAndProd(current$1);
|
3485 | }
|
3486 | }
|
3487 |
|
3488 | function resetCurrentFiber() {
|
3489 | {
|
3490 | ReactDebugCurrentFrame$1.getCurrentStack = null;
|
3491 | current$1 = null;
|
3492 | isRendering = false;
|
3493 | }
|
3494 | }
|
3495 | function setCurrentFiber(fiber) {
|
3496 | {
|
3497 | ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev;
|
3498 | current$1 = fiber;
|
3499 | isRendering = false;
|
3500 | }
|
3501 | }
|
3502 | function setIsRendering(rendering) {
|
3503 | {
|
3504 | isRendering = rendering;
|
3505 | }
|
3506 | }
|
3507 |
|
3508 | var ReactStrictModeWarnings = {
|
3509 | recordUnsafeLifecycleWarnings: function (fiber, instance) {},
|
3510 | flushPendingUnsafeLifecycleWarnings: function () {},
|
3511 | recordLegacyContextWarning: function (fiber, instance) {},
|
3512 | flushLegacyContextWarning: function () {},
|
3513 | discardPendingWarnings: function () {}
|
3514 | };
|
3515 |
|
3516 | {
|
3517 | var findStrictRoot = function (fiber) {
|
3518 | var maybeStrictRoot = null;
|
3519 | var node = fiber;
|
3520 |
|
3521 | while (node !== null) {
|
3522 | if (node.mode & StrictLegacyMode) {
|
3523 | maybeStrictRoot = node;
|
3524 | }
|
3525 |
|
3526 | node = node.return;
|
3527 | }
|
3528 |
|
3529 | return maybeStrictRoot;
|
3530 | };
|
3531 |
|
3532 | var setToSortedString = function (set) {
|
3533 | var array = [];
|
3534 | set.forEach(function (value) {
|
3535 | array.push(value);
|
3536 | });
|
3537 | return array.sort().join(', ');
|
3538 | };
|
3539 |
|
3540 | var pendingComponentWillMountWarnings = [];
|
3541 | var pendingUNSAFE_ComponentWillMountWarnings = [];
|
3542 | var pendingComponentWillReceivePropsWarnings = [];
|
3543 | var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
3544 | var pendingComponentWillUpdateWarnings = [];
|
3545 | var pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
3546 |
|
3547 | var didWarnAboutUnsafeLifecycles = new Set();
|
3548 |
|
3549 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
|
3550 |
|
3551 | if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
|
3552 | return;
|
3553 | }
|
3554 |
|
3555 | if (typeof instance.componentWillMount === 'function' &&
|
3556 | instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
3557 | pendingComponentWillMountWarnings.push(fiber);
|
3558 | }
|
3559 |
|
3560 | if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillMount === 'function') {
|
3561 | pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
|
3562 | }
|
3563 |
|
3564 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
3565 | pendingComponentWillReceivePropsWarnings.push(fiber);
|
3566 | }
|
3567 |
|
3568 | if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
3569 | pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
|
3570 | }
|
3571 |
|
3572 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
3573 | pendingComponentWillUpdateWarnings.push(fiber);
|
3574 | }
|
3575 |
|
3576 | if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
3577 | pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
|
3578 | }
|
3579 | };
|
3580 |
|
3581 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
|
3582 |
|
3583 | var componentWillMountUniqueNames = new Set();
|
3584 |
|
3585 | if (pendingComponentWillMountWarnings.length > 0) {
|
3586 | pendingComponentWillMountWarnings.forEach(function (fiber) {
|
3587 | componentWillMountUniqueNames.add(getComponentNameFromFiber(fiber) || 'Component');
|
3588 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
3589 | });
|
3590 | pendingComponentWillMountWarnings = [];
|
3591 | }
|
3592 |
|
3593 | var UNSAFE_componentWillMountUniqueNames = new Set();
|
3594 |
|
3595 | if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
|
3596 | pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
|
3597 | UNSAFE_componentWillMountUniqueNames.add(getComponentNameFromFiber(fiber) || 'Component');
|
3598 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
3599 | });
|
3600 | pendingUNSAFE_ComponentWillMountWarnings = [];
|
3601 | }
|
3602 |
|
3603 | var componentWillReceivePropsUniqueNames = new Set();
|
3604 |
|
3605 | if (pendingComponentWillReceivePropsWarnings.length > 0) {
|
3606 | pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
|
3607 | componentWillReceivePropsUniqueNames.add(getComponentNameFromFiber(fiber) || 'Component');
|
3608 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
3609 | });
|
3610 | pendingComponentWillReceivePropsWarnings = [];
|
3611 | }
|
3612 |
|
3613 | var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
|
3614 |
|
3615 | if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
|
3616 | pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
|
3617 | UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentNameFromFiber(fiber) || 'Component');
|
3618 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
3619 | });
|
3620 | pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
3621 | }
|
3622 |
|
3623 | var componentWillUpdateUniqueNames = new Set();
|
3624 |
|
3625 | if (pendingComponentWillUpdateWarnings.length > 0) {
|
3626 | pendingComponentWillUpdateWarnings.forEach(function (fiber) {
|
3627 | componentWillUpdateUniqueNames.add(getComponentNameFromFiber(fiber) || 'Component');
|
3628 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
3629 | });
|
3630 | pendingComponentWillUpdateWarnings = [];
|
3631 | }
|
3632 |
|
3633 | var UNSAFE_componentWillUpdateUniqueNames = new Set();
|
3634 |
|
3635 | if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
|
3636 | pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
|
3637 | UNSAFE_componentWillUpdateUniqueNames.add(getComponentNameFromFiber(fiber) || 'Component');
|
3638 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
3639 | });
|
3640 | pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
3641 | }
|
3642 |
|
3643 |
|
3644 |
|
3645 | if (UNSAFE_componentWillMountUniqueNames.size > 0) {
|
3646 | var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
|
3647 |
|
3648 | error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://reactjs.org/link/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);
|
3649 | }
|
3650 |
|
3651 | if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
|
3652 | var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
|
3653 |
|
3654 | error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/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://reactjs.org/link/derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
|
3655 | }
|
3656 |
|
3657 | if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
|
3658 | var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
|
3659 |
|
3660 | error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
|
3661 | }
|
3662 |
|
3663 | if (componentWillMountUniqueNames.size > 0) {
|
3664 | var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
|
3665 |
|
3666 | warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/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 18.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);
|
3667 | }
|
3668 |
|
3669 | if (componentWillReceivePropsUniqueNames.size > 0) {
|
3670 | var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
|
3671 |
|
3672 | warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/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://reactjs.org/link/derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 18.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);
|
3673 | }
|
3674 |
|
3675 | if (componentWillUpdateUniqueNames.size > 0) {
|
3676 | var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
|
3677 |
|
3678 | warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/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 18.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);
|
3679 | }
|
3680 | };
|
3681 |
|
3682 | var pendingLegacyContextWarning = new Map();
|
3683 |
|
3684 | var didWarnAboutLegacyContext = new Set();
|
3685 |
|
3686 | ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
|
3687 | var strictRoot = findStrictRoot(fiber);
|
3688 |
|
3689 | if (strictRoot === null) {
|
3690 | error('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.');
|
3691 |
|
3692 | return;
|
3693 | }
|
3694 |
|
3695 |
|
3696 | if (didWarnAboutLegacyContext.has(fiber.type)) {
|
3697 | return;
|
3698 | }
|
3699 |
|
3700 | var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
|
3701 |
|
3702 | if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
|
3703 | if (warningsForRoot === undefined) {
|
3704 | warningsForRoot = [];
|
3705 | pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
|
3706 | }
|
3707 |
|
3708 | warningsForRoot.push(fiber);
|
3709 | }
|
3710 | };
|
3711 |
|
3712 | ReactStrictModeWarnings.flushLegacyContextWarning = function () {
|
3713 | pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
|
3714 | if (fiberArray.length === 0) {
|
3715 | return;
|
3716 | }
|
3717 |
|
3718 | var firstFiber = fiberArray[0];
|
3719 | var uniqueNames = new Set();
|
3720 | fiberArray.forEach(function (fiber) {
|
3721 | uniqueNames.add(getComponentNameFromFiber(fiber) || 'Component');
|
3722 | didWarnAboutLegacyContext.add(fiber.type);
|
3723 | });
|
3724 | var sortedNames = setToSortedString(uniqueNames);
|
3725 |
|
3726 | try {
|
3727 | setCurrentFiber(firstFiber);
|
3728 |
|
3729 | error('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://reactjs.org/link/legacy-context', sortedNames);
|
3730 | } finally {
|
3731 | resetCurrentFiber();
|
3732 | }
|
3733 | });
|
3734 | };
|
3735 |
|
3736 | ReactStrictModeWarnings.discardPendingWarnings = function () {
|
3737 | pendingComponentWillMountWarnings = [];
|
3738 | pendingUNSAFE_ComponentWillMountWarnings = [];
|
3739 | pendingComponentWillReceivePropsWarnings = [];
|
3740 | pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
3741 | pendingComponentWillUpdateWarnings = [];
|
3742 | pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
3743 | pendingLegacyContextWarning = new Map();
|
3744 | };
|
3745 | }
|
3746 |
|
3747 | |
3748 |
|
3749 |
|
3750 |
|
3751 |
|
3752 |
|
3753 |
|
3754 |
|
3755 |
|
3756 |
|
3757 | function typeName(value) {
|
3758 | {
|
3759 |
|
3760 | var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
|
3761 | var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
|
3762 | return type;
|
3763 | }
|
3764 | }
|
3765 |
|
3766 |
|
3767 | function willCoercionThrow(value) {
|
3768 | {
|
3769 | try {
|
3770 | testStringCoercion(value);
|
3771 | return false;
|
3772 | } catch (e) {
|
3773 | return true;
|
3774 | }
|
3775 | }
|
3776 | }
|
3777 |
|
3778 | function testStringCoercion(value) {
|
3779 |
|
3780 |
|
3781 |
|
3782 |
|
3783 |
|
3784 |
|
3785 |
|
3786 |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 |
|
3792 |
|
3793 |
|
3794 |
|
3795 |
|
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 |
|
3801 |
|
3802 | return '' + value;
|
3803 | }
|
3804 | function checkPropStringCoercion(value, propName) {
|
3805 | {
|
3806 | if (willCoercionThrow(value)) {
|
3807 | error('The provided `%s` prop is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', propName, typeName(value));
|
3808 |
|
3809 | return testStringCoercion(value);
|
3810 | }
|
3811 | }
|
3812 | }
|
3813 |
|
3814 | function resolveDefaultProps(Component, baseProps) {
|
3815 | if (Component && Component.defaultProps) {
|
3816 |
|
3817 | var props = assign({}, baseProps);
|
3818 | var defaultProps = Component.defaultProps;
|
3819 |
|
3820 | for (var propName in defaultProps) {
|
3821 | if (props[propName] === undefined) {
|
3822 | props[propName] = defaultProps[propName];
|
3823 | }
|
3824 | }
|
3825 |
|
3826 | return props;
|
3827 | }
|
3828 |
|
3829 | return baseProps;
|
3830 | }
|
3831 |
|
3832 | var valueCursor = createCursor(null);
|
3833 | var rendererSigil;
|
3834 |
|
3835 | {
|
3836 |
|
3837 | rendererSigil = {};
|
3838 | }
|
3839 |
|
3840 | var currentlyRenderingFiber = null;
|
3841 | var lastContextDependency = null;
|
3842 | var lastFullyObservedContext = null;
|
3843 | var isDisallowedContextReadInDEV = false;
|
3844 | function resetContextDependencies() {
|
3845 |
|
3846 |
|
3847 | currentlyRenderingFiber = null;
|
3848 | lastContextDependency = null;
|
3849 | lastFullyObservedContext = null;
|
3850 |
|
3851 | {
|
3852 | isDisallowedContextReadInDEV = false;
|
3853 | }
|
3854 | }
|
3855 | function enterDisallowedContextReadInDEV() {
|
3856 | {
|
3857 | isDisallowedContextReadInDEV = true;
|
3858 | }
|
3859 | }
|
3860 | function exitDisallowedContextReadInDEV() {
|
3861 | {
|
3862 | isDisallowedContextReadInDEV = false;
|
3863 | }
|
3864 | }
|
3865 | function pushProvider(providerFiber, context, nextValue) {
|
3866 | {
|
3867 | push(valueCursor, context._currentValue2, providerFiber);
|
3868 | context._currentValue2 = nextValue;
|
3869 |
|
3870 | {
|
3871 | if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) {
|
3872 | error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
|
3873 | }
|
3874 |
|
3875 | context._currentRenderer2 = rendererSigil;
|
3876 | }
|
3877 | }
|
3878 | }
|
3879 | function popProvider(context, providerFiber) {
|
3880 | var currentValue = valueCursor.current;
|
3881 | pop(valueCursor, providerFiber);
|
3882 |
|
3883 | {
|
3884 | {
|
3885 | context._currentValue2 = currentValue;
|
3886 | }
|
3887 | }
|
3888 | }
|
3889 | function scheduleContextWorkOnParentPath(parent, renderLanes, propagationRoot) {
|
3890 |
|
3891 | var node = parent;
|
3892 |
|
3893 | while (node !== null) {
|
3894 | var alternate = node.alternate;
|
3895 |
|
3896 | if (!isSubsetOfLanes(node.childLanes, renderLanes)) {
|
3897 | node.childLanes = mergeLanes(node.childLanes, renderLanes);
|
3898 |
|
3899 | if (alternate !== null) {
|
3900 | alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
|
3901 | }
|
3902 | } else if (alternate !== null && !isSubsetOfLanes(alternate.childLanes, renderLanes)) {
|
3903 | alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
|
3904 | }
|
3905 |
|
3906 | if (node === propagationRoot) {
|
3907 | break;
|
3908 | }
|
3909 |
|
3910 | node = node.return;
|
3911 | }
|
3912 |
|
3913 | {
|
3914 | if (node !== propagationRoot) {
|
3915 | error('Expected to find the propagation root when scheduling context work. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3916 | }
|
3917 | }
|
3918 | }
|
3919 | function propagateContextChange(workInProgress, context, renderLanes) {
|
3920 | {
|
3921 | propagateContextChange_eager(workInProgress, context, renderLanes);
|
3922 | }
|
3923 | }
|
3924 |
|
3925 | function propagateContextChange_eager(workInProgress, context, renderLanes) {
|
3926 |
|
3927 | var fiber = workInProgress.child;
|
3928 |
|
3929 | if (fiber !== null) {
|
3930 |
|
3931 | fiber.return = workInProgress;
|
3932 | }
|
3933 |
|
3934 | while (fiber !== null) {
|
3935 | var nextFiber = void 0;
|
3936 |
|
3937 | var list = fiber.dependencies;
|
3938 |
|
3939 | if (list !== null) {
|
3940 | nextFiber = fiber.child;
|
3941 | var dependency = list.firstContext;
|
3942 |
|
3943 | while (dependency !== null) {
|
3944 |
|
3945 | if (dependency.context === context) {
|
3946 |
|
3947 | if (fiber.tag === ClassComponent) {
|
3948 |
|
3949 | var lane = pickArbitraryLane(renderLanes);
|
3950 | var update = createUpdate(NoTimestamp, lane);
|
3951 | update.tag = ForceUpdate;
|
3952 |
|
3953 |
|
3954 |
|
3955 |
|
3956 |
|
3957 | var updateQueue = fiber.updateQueue;
|
3958 |
|
3959 | if (updateQueue === null) ; else {
|
3960 | var sharedQueue = updateQueue.shared;
|
3961 | var pending = sharedQueue.pending;
|
3962 |
|
3963 | if (pending === null) {
|
3964 |
|
3965 | update.next = update;
|
3966 | } else {
|
3967 | update.next = pending.next;
|
3968 | pending.next = update;
|
3969 | }
|
3970 |
|
3971 | sharedQueue.pending = update;
|
3972 | }
|
3973 | }
|
3974 |
|
3975 | fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
|
3976 | var alternate = fiber.alternate;
|
3977 |
|
3978 | if (alternate !== null) {
|
3979 | alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
|
3980 | }
|
3981 |
|
3982 | scheduleContextWorkOnParentPath(fiber.return, renderLanes, workInProgress);
|
3983 |
|
3984 | list.lanes = mergeLanes(list.lanes, renderLanes);
|
3985 |
|
3986 |
|
3987 | break;
|
3988 | }
|
3989 |
|
3990 | dependency = dependency.next;
|
3991 | }
|
3992 | } else if (fiber.tag === ContextProvider) {
|
3993 |
|
3994 | nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
|
3995 | } else if ( fiber.tag === DehydratedFragment) {
|
3996 |
|
3997 |
|
3998 |
|
3999 | var parentSuspense = fiber.return;
|
4000 |
|
4001 | if (parentSuspense === null) {
|
4002 | throw new Error('We just came from a parent so we must have had a parent. This is a bug in React.');
|
4003 | }
|
4004 |
|
4005 | parentSuspense.lanes = mergeLanes(parentSuspense.lanes, renderLanes);
|
4006 | var _alternate = parentSuspense.alternate;
|
4007 |
|
4008 | if (_alternate !== null) {
|
4009 | _alternate.lanes = mergeLanes(_alternate.lanes, renderLanes);
|
4010 | }
|
4011 |
|
4012 |
|
4013 |
|
4014 |
|
4015 |
|
4016 | scheduleContextWorkOnParentPath(parentSuspense, renderLanes, workInProgress);
|
4017 | nextFiber = fiber.sibling;
|
4018 | } else {
|
4019 |
|
4020 | nextFiber = fiber.child;
|
4021 | }
|
4022 |
|
4023 | if (nextFiber !== null) {
|
4024 |
|
4025 | nextFiber.return = fiber;
|
4026 | } else {
|
4027 |
|
4028 | nextFiber = fiber;
|
4029 |
|
4030 | while (nextFiber !== null) {
|
4031 | if (nextFiber === workInProgress) {
|
4032 |
|
4033 | nextFiber = null;
|
4034 | break;
|
4035 | }
|
4036 |
|
4037 | var sibling = nextFiber.sibling;
|
4038 |
|
4039 | if (sibling !== null) {
|
4040 |
|
4041 | sibling.return = nextFiber.return;
|
4042 | nextFiber = sibling;
|
4043 | break;
|
4044 | }
|
4045 |
|
4046 |
|
4047 | nextFiber = nextFiber.return;
|
4048 | }
|
4049 | }
|
4050 |
|
4051 | fiber = nextFiber;
|
4052 | }
|
4053 | }
|
4054 | function prepareToReadContext(workInProgress, renderLanes) {
|
4055 | currentlyRenderingFiber = workInProgress;
|
4056 | lastContextDependency = null;
|
4057 | lastFullyObservedContext = null;
|
4058 | var dependencies = workInProgress.dependencies;
|
4059 |
|
4060 | if (dependencies !== null) {
|
4061 | {
|
4062 | var firstContext = dependencies.firstContext;
|
4063 |
|
4064 | if (firstContext !== null) {
|
4065 | if (includesSomeLane(dependencies.lanes, renderLanes)) {
|
4066 |
|
4067 | markWorkInProgressReceivedUpdate();
|
4068 | }
|
4069 |
|
4070 |
|
4071 | dependencies.firstContext = null;
|
4072 | }
|
4073 | }
|
4074 | }
|
4075 | }
|
4076 | function readContext(context) {
|
4077 | {
|
4078 |
|
4079 |
|
4080 | if (isDisallowedContextReadInDEV) {
|
4081 | 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().');
|
4082 | }
|
4083 | }
|
4084 |
|
4085 | var value = context._currentValue2;
|
4086 |
|
4087 | if (lastFullyObservedContext === context) ; else {
|
4088 | var contextItem = {
|
4089 | context: context,
|
4090 | memoizedValue: value,
|
4091 | next: null
|
4092 | };
|
4093 |
|
4094 | if (lastContextDependency === null) {
|
4095 | if (currentlyRenderingFiber === null) {
|
4096 | throw new 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().');
|
4097 | }
|
4098 |
|
4099 |
|
4100 | lastContextDependency = contextItem;
|
4101 | currentlyRenderingFiber.dependencies = {
|
4102 | lanes: NoLanes,
|
4103 | firstContext: contextItem
|
4104 | };
|
4105 | } else {
|
4106 |
|
4107 | lastContextDependency = lastContextDependency.next = contextItem;
|
4108 | }
|
4109 | }
|
4110 |
|
4111 | return value;
|
4112 | }
|
4113 |
|
4114 |
|
4115 |
|
4116 |
|
4117 |
|
4118 | var interleavedQueues = null;
|
4119 | function pushInterleavedQueue(queue) {
|
4120 | if (interleavedQueues === null) {
|
4121 | interleavedQueues = [queue];
|
4122 | } else {
|
4123 | interleavedQueues.push(queue);
|
4124 | }
|
4125 | }
|
4126 | function enqueueInterleavedUpdates() {
|
4127 |
|
4128 |
|
4129 |
|
4130 |
|
4131 |
|
4132 | if (interleavedQueues !== null) {
|
4133 | for (var i = 0; i < interleavedQueues.length; i++) {
|
4134 | var queue = interleavedQueues[i];
|
4135 | var lastInterleavedUpdate = queue.interleaved;
|
4136 |
|
4137 | if (lastInterleavedUpdate !== null) {
|
4138 | queue.interleaved = null;
|
4139 | var firstInterleavedUpdate = lastInterleavedUpdate.next;
|
4140 | var lastPendingUpdate = queue.pending;
|
4141 |
|
4142 | if (lastPendingUpdate !== null) {
|
4143 | var firstPendingUpdate = lastPendingUpdate.next;
|
4144 | lastPendingUpdate.next = firstInterleavedUpdate;
|
4145 | lastInterleavedUpdate.next = firstPendingUpdate;
|
4146 | }
|
4147 |
|
4148 | queue.pending = lastInterleavedUpdate;
|
4149 | }
|
4150 | }
|
4151 |
|
4152 | interleavedQueues = null;
|
4153 | }
|
4154 | }
|
4155 |
|
4156 | var UpdateState = 0;
|
4157 | var ReplaceState = 1;
|
4158 | var ForceUpdate = 2;
|
4159 | var CaptureUpdate = 3;
|
4160 |
|
4161 |
|
4162 |
|
4163 | var hasForceUpdate = false;
|
4164 | var didWarnUpdateInsideUpdate;
|
4165 | var currentlyProcessingQueue;
|
4166 |
|
4167 | {
|
4168 | didWarnUpdateInsideUpdate = false;
|
4169 | currentlyProcessingQueue = null;
|
4170 | }
|
4171 |
|
4172 | function initializeUpdateQueue(fiber) {
|
4173 | var queue = {
|
4174 | baseState: fiber.memoizedState,
|
4175 | firstBaseUpdate: null,
|
4176 | lastBaseUpdate: null,
|
4177 | shared: {
|
4178 | pending: null,
|
4179 | interleaved: null,
|
4180 | lanes: NoLanes
|
4181 | },
|
4182 | effects: null
|
4183 | };
|
4184 | fiber.updateQueue = queue;
|
4185 | }
|
4186 | function cloneUpdateQueue(current, workInProgress) {
|
4187 |
|
4188 | var queue = workInProgress.updateQueue;
|
4189 | var currentQueue = current.updateQueue;
|
4190 |
|
4191 | if (queue === currentQueue) {
|
4192 | var clone = {
|
4193 | baseState: currentQueue.baseState,
|
4194 | firstBaseUpdate: currentQueue.firstBaseUpdate,
|
4195 | lastBaseUpdate: currentQueue.lastBaseUpdate,
|
4196 | shared: currentQueue.shared,
|
4197 | effects: currentQueue.effects
|
4198 | };
|
4199 | workInProgress.updateQueue = clone;
|
4200 | }
|
4201 | }
|
4202 | function createUpdate(eventTime, lane) {
|
4203 | var update = {
|
4204 | eventTime: eventTime,
|
4205 | lane: lane,
|
4206 | tag: UpdateState,
|
4207 | payload: null,
|
4208 | callback: null,
|
4209 | next: null
|
4210 | };
|
4211 | return update;
|
4212 | }
|
4213 | function enqueueUpdate(fiber, update, lane) {
|
4214 | var updateQueue = fiber.updateQueue;
|
4215 |
|
4216 | if (updateQueue === null) {
|
4217 |
|
4218 | return;
|
4219 | }
|
4220 |
|
4221 | var sharedQueue = updateQueue.shared;
|
4222 |
|
4223 | if (isInterleavedUpdate(fiber)) {
|
4224 | var interleaved = sharedQueue.interleaved;
|
4225 |
|
4226 | if (interleaved === null) {
|
4227 |
|
4228 | update.next = update;
|
4229 |
|
4230 |
|
4231 | pushInterleavedQueue(sharedQueue);
|
4232 | } else {
|
4233 | update.next = interleaved.next;
|
4234 | interleaved.next = update;
|
4235 | }
|
4236 |
|
4237 | sharedQueue.interleaved = update;
|
4238 | } else {
|
4239 | var pending = sharedQueue.pending;
|
4240 |
|
4241 | if (pending === null) {
|
4242 |
|
4243 | update.next = update;
|
4244 | } else {
|
4245 | update.next = pending.next;
|
4246 | pending.next = update;
|
4247 | }
|
4248 |
|
4249 | sharedQueue.pending = update;
|
4250 | }
|
4251 |
|
4252 | {
|
4253 | if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) {
|
4254 | error('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.');
|
4255 |
|
4256 | didWarnUpdateInsideUpdate = true;
|
4257 | }
|
4258 | }
|
4259 | }
|
4260 | function entangleTransitions(root, fiber, lane) {
|
4261 | var updateQueue = fiber.updateQueue;
|
4262 |
|
4263 | if (updateQueue === null) {
|
4264 |
|
4265 | return;
|
4266 | }
|
4267 |
|
4268 | var sharedQueue = updateQueue.shared;
|
4269 |
|
4270 | if (isTransitionLane(lane)) {
|
4271 | var queueLanes = sharedQueue.lanes;
|
4272 |
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 | queueLanes = intersectLanes(queueLanes, root.pendingLanes);
|
4278 |
|
4279 | var newQueueLanes = mergeLanes(queueLanes, lane);
|
4280 | sharedQueue.lanes = newQueueLanes;
|
4281 |
|
4282 |
|
4283 |
|
4284 | markRootEntangled(root, newQueueLanes);
|
4285 | }
|
4286 | }
|
4287 | function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
|
4288 |
|
4289 |
|
4290 |
|
4291 | var queue = workInProgress.updateQueue;
|
4292 |
|
4293 | var current = workInProgress.alternate;
|
4294 |
|
4295 | if (current !== null) {
|
4296 | var currentQueue = current.updateQueue;
|
4297 |
|
4298 | if (queue === currentQueue) {
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 |
|
4305 | var newFirst = null;
|
4306 | var newLast = null;
|
4307 | var firstBaseUpdate = queue.firstBaseUpdate;
|
4308 |
|
4309 | if (firstBaseUpdate !== null) {
|
4310 |
|
4311 | var update = firstBaseUpdate;
|
4312 |
|
4313 | do {
|
4314 | var clone = {
|
4315 | eventTime: update.eventTime,
|
4316 | lane: update.lane,
|
4317 | tag: update.tag,
|
4318 | payload: update.payload,
|
4319 | callback: update.callback,
|
4320 | next: null
|
4321 | };
|
4322 |
|
4323 | if (newLast === null) {
|
4324 | newFirst = newLast = clone;
|
4325 | } else {
|
4326 | newLast.next = clone;
|
4327 | newLast = clone;
|
4328 | }
|
4329 |
|
4330 | update = update.next;
|
4331 | } while (update !== null);
|
4332 |
|
4333 |
|
4334 | if (newLast === null) {
|
4335 | newFirst = newLast = capturedUpdate;
|
4336 | } else {
|
4337 | newLast.next = capturedUpdate;
|
4338 | newLast = capturedUpdate;
|
4339 | }
|
4340 | } else {
|
4341 |
|
4342 | newFirst = newLast = capturedUpdate;
|
4343 | }
|
4344 |
|
4345 | queue = {
|
4346 | baseState: currentQueue.baseState,
|
4347 | firstBaseUpdate: newFirst,
|
4348 | lastBaseUpdate: newLast,
|
4349 | shared: currentQueue.shared,
|
4350 | effects: currentQueue.effects
|
4351 | };
|
4352 | workInProgress.updateQueue = queue;
|
4353 | return;
|
4354 | }
|
4355 | }
|
4356 |
|
4357 |
|
4358 | var lastBaseUpdate = queue.lastBaseUpdate;
|
4359 |
|
4360 | if (lastBaseUpdate === null) {
|
4361 | queue.firstBaseUpdate = capturedUpdate;
|
4362 | } else {
|
4363 | lastBaseUpdate.next = capturedUpdate;
|
4364 | }
|
4365 |
|
4366 | queue.lastBaseUpdate = capturedUpdate;
|
4367 | }
|
4368 |
|
4369 | function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
|
4370 | switch (update.tag) {
|
4371 | case ReplaceState:
|
4372 | {
|
4373 | var payload = update.payload;
|
4374 |
|
4375 | if (typeof payload === 'function') {
|
4376 |
|
4377 | {
|
4378 | enterDisallowedContextReadInDEV();
|
4379 | }
|
4380 |
|
4381 | var nextState = payload.call(instance, prevState, nextProps);
|
4382 |
|
4383 | {
|
4384 | if ( workInProgress.mode & StrictLegacyMode) {
|
4385 | setIsStrictModeForDevtools(true);
|
4386 |
|
4387 | try {
|
4388 | payload.call(instance, prevState, nextProps);
|
4389 | } finally {
|
4390 | setIsStrictModeForDevtools(false);
|
4391 | }
|
4392 | }
|
4393 |
|
4394 | exitDisallowedContextReadInDEV();
|
4395 | }
|
4396 |
|
4397 | return nextState;
|
4398 | }
|
4399 |
|
4400 |
|
4401 | return payload;
|
4402 | }
|
4403 |
|
4404 | case CaptureUpdate:
|
4405 | {
|
4406 | workInProgress.flags = workInProgress.flags & ~ShouldCapture | DidCapture;
|
4407 | }
|
4408 |
|
4409 |
|
4410 | case UpdateState:
|
4411 | {
|
4412 | var _payload = update.payload;
|
4413 | var partialState;
|
4414 |
|
4415 | if (typeof _payload === 'function') {
|
4416 |
|
4417 | {
|
4418 | enterDisallowedContextReadInDEV();
|
4419 | }
|
4420 |
|
4421 | partialState = _payload.call(instance, prevState, nextProps);
|
4422 |
|
4423 | {
|
4424 | if ( workInProgress.mode & StrictLegacyMode) {
|
4425 | setIsStrictModeForDevtools(true);
|
4426 |
|
4427 | try {
|
4428 | _payload.call(instance, prevState, nextProps);
|
4429 | } finally {
|
4430 | setIsStrictModeForDevtools(false);
|
4431 | }
|
4432 | }
|
4433 |
|
4434 | exitDisallowedContextReadInDEV();
|
4435 | }
|
4436 | } else {
|
4437 |
|
4438 | partialState = _payload;
|
4439 | }
|
4440 |
|
4441 | if (partialState === null || partialState === undefined) {
|
4442 |
|
4443 | return prevState;
|
4444 | }
|
4445 |
|
4446 |
|
4447 | return assign({}, prevState, partialState);
|
4448 | }
|
4449 |
|
4450 | case ForceUpdate:
|
4451 | {
|
4452 | hasForceUpdate = true;
|
4453 | return prevState;
|
4454 | }
|
4455 | }
|
4456 |
|
4457 | return prevState;
|
4458 | }
|
4459 |
|
4460 | function processUpdateQueue(workInProgress, props, instance, renderLanes) {
|
4461 |
|
4462 | var queue = workInProgress.updateQueue;
|
4463 | hasForceUpdate = false;
|
4464 |
|
4465 | {
|
4466 | currentlyProcessingQueue = queue.shared;
|
4467 | }
|
4468 |
|
4469 | var firstBaseUpdate = queue.firstBaseUpdate;
|
4470 | var lastBaseUpdate = queue.lastBaseUpdate;
|
4471 |
|
4472 | var pendingQueue = queue.shared.pending;
|
4473 |
|
4474 | if (pendingQueue !== null) {
|
4475 | queue.shared.pending = null;
|
4476 |
|
4477 |
|
4478 | var lastPendingUpdate = pendingQueue;
|
4479 | var firstPendingUpdate = lastPendingUpdate.next;
|
4480 | lastPendingUpdate.next = null;
|
4481 |
|
4482 | if (lastBaseUpdate === null) {
|
4483 | firstBaseUpdate = firstPendingUpdate;
|
4484 | } else {
|
4485 | lastBaseUpdate.next = firstPendingUpdate;
|
4486 | }
|
4487 |
|
4488 | lastBaseUpdate = lastPendingUpdate;
|
4489 |
|
4490 |
|
4491 |
|
4492 |
|
4493 |
|
4494 | var current = workInProgress.alternate;
|
4495 |
|
4496 | if (current !== null) {
|
4497 |
|
4498 | var currentQueue = current.updateQueue;
|
4499 | var currentLastBaseUpdate = currentQueue.lastBaseUpdate;
|
4500 |
|
4501 | if (currentLastBaseUpdate !== lastBaseUpdate) {
|
4502 | if (currentLastBaseUpdate === null) {
|
4503 | currentQueue.firstBaseUpdate = firstPendingUpdate;
|
4504 | } else {
|
4505 | currentLastBaseUpdate.next = firstPendingUpdate;
|
4506 | }
|
4507 |
|
4508 | currentQueue.lastBaseUpdate = lastPendingUpdate;
|
4509 | }
|
4510 | }
|
4511 | }
|
4512 |
|
4513 |
|
4514 | if (firstBaseUpdate !== null) {
|
4515 |
|
4516 | var newState = queue.baseState;
|
4517 |
|
4518 |
|
4519 | var newLanes = NoLanes;
|
4520 | var newBaseState = null;
|
4521 | var newFirstBaseUpdate = null;
|
4522 | var newLastBaseUpdate = null;
|
4523 | var update = firstBaseUpdate;
|
4524 |
|
4525 | do {
|
4526 | var updateLane = update.lane;
|
4527 | var updateEventTime = update.eventTime;
|
4528 |
|
4529 | if (!isSubsetOfLanes(renderLanes, updateLane)) {
|
4530 |
|
4531 |
|
4532 |
|
4533 | var clone = {
|
4534 | eventTime: updateEventTime,
|
4535 | lane: updateLane,
|
4536 | tag: update.tag,
|
4537 | payload: update.payload,
|
4538 | callback: update.callback,
|
4539 | next: null
|
4540 | };
|
4541 |
|
4542 | if (newLastBaseUpdate === null) {
|
4543 | newFirstBaseUpdate = newLastBaseUpdate = clone;
|
4544 | newBaseState = newState;
|
4545 | } else {
|
4546 | newLastBaseUpdate = newLastBaseUpdate.next = clone;
|
4547 | }
|
4548 |
|
4549 |
|
4550 | newLanes = mergeLanes(newLanes, updateLane);
|
4551 | } else {
|
4552 |
|
4553 | if (newLastBaseUpdate !== null) {
|
4554 | var _clone = {
|
4555 | eventTime: updateEventTime,
|
4556 |
|
4557 |
|
4558 |
|
4559 | lane: NoLane,
|
4560 | tag: update.tag,
|
4561 | payload: update.payload,
|
4562 | callback: update.callback,
|
4563 | next: null
|
4564 | };
|
4565 | newLastBaseUpdate = newLastBaseUpdate.next = _clone;
|
4566 | }
|
4567 |
|
4568 |
|
4569 | newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance);
|
4570 | var callback = update.callback;
|
4571 |
|
4572 | if (callback !== null &&
|
4573 |
|
4574 | update.lane !== NoLane) {
|
4575 | workInProgress.flags |= Callback;
|
4576 | var effects = queue.effects;
|
4577 |
|
4578 | if (effects === null) {
|
4579 | queue.effects = [update];
|
4580 | } else {
|
4581 | effects.push(update);
|
4582 | }
|
4583 | }
|
4584 | }
|
4585 |
|
4586 | update = update.next;
|
4587 |
|
4588 | if (update === null) {
|
4589 | pendingQueue = queue.shared.pending;
|
4590 |
|
4591 | if (pendingQueue === null) {
|
4592 | break;
|
4593 | } else {
|
4594 |
|
4595 |
|
4596 | var _lastPendingUpdate = pendingQueue;
|
4597 |
|
4598 |
|
4599 | var _firstPendingUpdate = _lastPendingUpdate.next;
|
4600 | _lastPendingUpdate.next = null;
|
4601 | update = _firstPendingUpdate;
|
4602 | queue.lastBaseUpdate = _lastPendingUpdate;
|
4603 | queue.shared.pending = null;
|
4604 | }
|
4605 | }
|
4606 | } while (true);
|
4607 |
|
4608 | if (newLastBaseUpdate === null) {
|
4609 | newBaseState = newState;
|
4610 | }
|
4611 |
|
4612 | queue.baseState = newBaseState;
|
4613 | queue.firstBaseUpdate = newFirstBaseUpdate;
|
4614 | queue.lastBaseUpdate = newLastBaseUpdate;
|
4615 |
|
4616 |
|
4617 |
|
4618 | var lastInterleaved = queue.shared.interleaved;
|
4619 |
|
4620 | if (lastInterleaved !== null) {
|
4621 | var interleaved = lastInterleaved;
|
4622 |
|
4623 | do {
|
4624 | newLanes = mergeLanes(newLanes, interleaved.lane);
|
4625 | interleaved = interleaved.next;
|
4626 | } while (interleaved !== lastInterleaved);
|
4627 | } else if (firstBaseUpdate === null) {
|
4628 |
|
4629 |
|
4630 | queue.shared.lanes = NoLanes;
|
4631 | }
|
4632 |
|
4633 |
|
4634 |
|
4635 |
|
4636 |
|
4637 |
|
4638 |
|
4639 |
|
4640 | markSkippedUpdateLanes(newLanes);
|
4641 | workInProgress.lanes = newLanes;
|
4642 | workInProgress.memoizedState = newState;
|
4643 | }
|
4644 |
|
4645 | {
|
4646 | currentlyProcessingQueue = null;
|
4647 | }
|
4648 | }
|
4649 |
|
4650 | function callCallback(callback, context) {
|
4651 | if (typeof callback !== 'function') {
|
4652 | throw new Error('Invalid argument passed as callback. Expected a function. Instead ' + ("received: " + callback));
|
4653 | }
|
4654 |
|
4655 | callback.call(context);
|
4656 | }
|
4657 |
|
4658 | function resetHasForceUpdateBeforeProcessing() {
|
4659 | hasForceUpdate = false;
|
4660 | }
|
4661 | function checkHasForceUpdateAfterProcessing() {
|
4662 | return hasForceUpdate;
|
4663 | }
|
4664 | function commitUpdateQueue(finishedWork, finishedQueue, instance) {
|
4665 |
|
4666 | var effects = finishedQueue.effects;
|
4667 | finishedQueue.effects = null;
|
4668 |
|
4669 | if (effects !== null) {
|
4670 | for (var i = 0; i < effects.length; i++) {
|
4671 | var effect = effects[i];
|
4672 | var callback = effect.callback;
|
4673 |
|
4674 | if (callback !== null) {
|
4675 | effect.callback = null;
|
4676 | callCallback(callback, instance);
|
4677 | }
|
4678 | }
|
4679 | }
|
4680 | }
|
4681 |
|
4682 | var fakeInternalInstance = {};
|
4683 |
|
4684 |
|
4685 | var emptyRefsObject = new React.Component().refs;
|
4686 | var didWarnAboutStateAssignmentForComponent;
|
4687 | var didWarnAboutUninitializedState;
|
4688 | var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
|
4689 | var didWarnAboutLegacyLifecyclesAndDerivedState;
|
4690 | var didWarnAboutUndefinedDerivedState;
|
4691 | var warnOnUndefinedDerivedState;
|
4692 | var warnOnInvalidCallback;
|
4693 | var didWarnAboutDirectlyAssigningPropsToState;
|
4694 | var didWarnAboutContextTypeAndContextTypes;
|
4695 | var didWarnAboutInvalidateContextType;
|
4696 |
|
4697 | {
|
4698 | didWarnAboutStateAssignmentForComponent = new Set();
|
4699 | didWarnAboutUninitializedState = new Set();
|
4700 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
|
4701 | didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
|
4702 | didWarnAboutDirectlyAssigningPropsToState = new Set();
|
4703 | didWarnAboutUndefinedDerivedState = new Set();
|
4704 | didWarnAboutContextTypeAndContextTypes = new Set();
|
4705 | didWarnAboutInvalidateContextType = new Set();
|
4706 | var didWarnOnInvalidCallback = new Set();
|
4707 |
|
4708 | warnOnInvalidCallback = function (callback, callerName) {
|
4709 | if (callback === null || typeof callback === 'function') {
|
4710 | return;
|
4711 | }
|
4712 |
|
4713 | var key = callerName + '_' + callback;
|
4714 |
|
4715 | if (!didWarnOnInvalidCallback.has(key)) {
|
4716 | didWarnOnInvalidCallback.add(key);
|
4717 |
|
4718 | error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
|
4719 | }
|
4720 | };
|
4721 |
|
4722 | warnOnUndefinedDerivedState = function (type, partialState) {
|
4723 | if (partialState === undefined) {
|
4724 | var componentName = getComponentNameFromType(type) || 'Component';
|
4725 |
|
4726 | if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
|
4727 | didWarnAboutUndefinedDerivedState.add(componentName);
|
4728 |
|
4729 | error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
|
4730 | }
|
4731 | }
|
4732 | };
|
4733 |
|
4734 |
|
4735 |
|
4736 |
|
4737 |
|
4738 |
|
4739 | Object.defineProperty(fakeInternalInstance, '_processChildContext', {
|
4740 | enumerable: false,
|
4741 | value: function () {
|
4742 | throw new 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).');
|
4743 | }
|
4744 | });
|
4745 | Object.freeze(fakeInternalInstance);
|
4746 | }
|
4747 |
|
4748 | function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
|
4749 | var prevState = workInProgress.memoizedState;
|
4750 | var partialState = getDerivedStateFromProps(nextProps, prevState);
|
4751 |
|
4752 | {
|
4753 | if ( workInProgress.mode & StrictLegacyMode) {
|
4754 | setIsStrictModeForDevtools(true);
|
4755 |
|
4756 | try {
|
4757 |
|
4758 | partialState = getDerivedStateFromProps(nextProps, prevState);
|
4759 | } finally {
|
4760 | setIsStrictModeForDevtools(false);
|
4761 | }
|
4762 | }
|
4763 |
|
4764 | warnOnUndefinedDerivedState(ctor, partialState);
|
4765 | }
|
4766 |
|
4767 |
|
4768 | var memoizedState = partialState === null || partialState === undefined ? prevState : assign({}, prevState, partialState);
|
4769 | workInProgress.memoizedState = memoizedState;
|
4770 |
|
4771 |
|
4772 | if (workInProgress.lanes === NoLanes) {
|
4773 |
|
4774 | var updateQueue = workInProgress.updateQueue;
|
4775 | updateQueue.baseState = memoizedState;
|
4776 | }
|
4777 | }
|
4778 |
|
4779 | var classComponentUpdater = {
|
4780 | isMounted: isMounted,
|
4781 | enqueueSetState: function (inst, payload, callback) {
|
4782 | var fiber = get(inst);
|
4783 | var eventTime = requestEventTime();
|
4784 | var lane = requestUpdateLane(fiber);
|
4785 | var update = createUpdate(eventTime, lane);
|
4786 | update.payload = payload;
|
4787 |
|
4788 | if (callback !== undefined && callback !== null) {
|
4789 | {
|
4790 | warnOnInvalidCallback(callback, 'setState');
|
4791 | }
|
4792 |
|
4793 | update.callback = callback;
|
4794 | }
|
4795 |
|
4796 | enqueueUpdate(fiber, update);
|
4797 | var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
|
4798 |
|
4799 | if (root !== null) {
|
4800 | entangleTransitions(root, fiber, lane);
|
4801 | }
|
4802 |
|
4803 | {
|
4804 | markStateUpdateScheduled(fiber, lane);
|
4805 | }
|
4806 | },
|
4807 | enqueueReplaceState: function (inst, payload, callback) {
|
4808 | var fiber = get(inst);
|
4809 | var eventTime = requestEventTime();
|
4810 | var lane = requestUpdateLane(fiber);
|
4811 | var update = createUpdate(eventTime, lane);
|
4812 | update.tag = ReplaceState;
|
4813 | update.payload = payload;
|
4814 |
|
4815 | if (callback !== undefined && callback !== null) {
|
4816 | {
|
4817 | warnOnInvalidCallback(callback, 'replaceState');
|
4818 | }
|
4819 |
|
4820 | update.callback = callback;
|
4821 | }
|
4822 |
|
4823 | enqueueUpdate(fiber, update);
|
4824 | var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
|
4825 |
|
4826 | if (root !== null) {
|
4827 | entangleTransitions(root, fiber, lane);
|
4828 | }
|
4829 |
|
4830 | {
|
4831 | markStateUpdateScheduled(fiber, lane);
|
4832 | }
|
4833 | },
|
4834 | enqueueForceUpdate: function (inst, callback) {
|
4835 | var fiber = get(inst);
|
4836 | var eventTime = requestEventTime();
|
4837 | var lane = requestUpdateLane(fiber);
|
4838 | var update = createUpdate(eventTime, lane);
|
4839 | update.tag = ForceUpdate;
|
4840 |
|
4841 | if (callback !== undefined && callback !== null) {
|
4842 | {
|
4843 | warnOnInvalidCallback(callback, 'forceUpdate');
|
4844 | }
|
4845 |
|
4846 | update.callback = callback;
|
4847 | }
|
4848 |
|
4849 | enqueueUpdate(fiber, update);
|
4850 | var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
|
4851 |
|
4852 | if (root !== null) {
|
4853 | entangleTransitions(root, fiber, lane);
|
4854 | }
|
4855 |
|
4856 | {
|
4857 | markForceUpdateScheduled(fiber, lane);
|
4858 | }
|
4859 | }
|
4860 | };
|
4861 |
|
4862 | function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
|
4863 | var instance = workInProgress.stateNode;
|
4864 |
|
4865 | if (typeof instance.shouldComponentUpdate === 'function') {
|
4866 | var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
4867 |
|
4868 | {
|
4869 | if ( workInProgress.mode & StrictLegacyMode) {
|
4870 | setIsStrictModeForDevtools(true);
|
4871 |
|
4872 | try {
|
4873 |
|
4874 | shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
4875 | } finally {
|
4876 | setIsStrictModeForDevtools(false);
|
4877 | }
|
4878 | }
|
4879 |
|
4880 | if (shouldUpdate === undefined) {
|
4881 | error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentNameFromType(ctor) || 'Component');
|
4882 | }
|
4883 | }
|
4884 |
|
4885 | return shouldUpdate;
|
4886 | }
|
4887 |
|
4888 | if (ctor.prototype && ctor.prototype.isPureReactComponent) {
|
4889 | return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
|
4890 | }
|
4891 |
|
4892 | return true;
|
4893 | }
|
4894 |
|
4895 | function checkClassInstance(workInProgress, ctor, newProps) {
|
4896 | var instance = workInProgress.stateNode;
|
4897 |
|
4898 | {
|
4899 | var name = getComponentNameFromType(ctor) || 'Component';
|
4900 | var renderPresent = instance.render;
|
4901 |
|
4902 | if (!renderPresent) {
|
4903 | if (ctor.prototype && typeof ctor.prototype.render === 'function') {
|
4904 | error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
|
4905 | } else {
|
4906 | error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
|
4907 | }
|
4908 | }
|
4909 |
|
4910 | if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
|
4911 | error('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);
|
4912 | }
|
4913 |
|
4914 | if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
|
4915 | error('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);
|
4916 | }
|
4917 |
|
4918 | if (instance.propTypes) {
|
4919 | error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
|
4920 | }
|
4921 |
|
4922 | if (instance.contextType) {
|
4923 | error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
|
4924 | }
|
4925 |
|
4926 | {
|
4927 | if (instance.contextTypes) {
|
4928 | error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
|
4929 | }
|
4930 |
|
4931 | if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
|
4932 | didWarnAboutContextTypeAndContextTypes.add(ctor);
|
4933 |
|
4934 | error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
|
4935 | }
|
4936 | }
|
4937 |
|
4938 | if (typeof instance.componentShouldUpdate === 'function') {
|
4939 | error('%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);
|
4940 | }
|
4941 |
|
4942 | if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
|
4943 | error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentNameFromType(ctor) || 'A pure component');
|
4944 | }
|
4945 |
|
4946 | if (typeof instance.componentDidUnmount === 'function') {
|
4947 | error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
|
4948 | }
|
4949 |
|
4950 | if (typeof instance.componentDidReceiveProps === 'function') {
|
4951 | error('%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);
|
4952 | }
|
4953 |
|
4954 | if (typeof instance.componentWillRecieveProps === 'function') {
|
4955 | error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
|
4956 | }
|
4957 |
|
4958 | if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') {
|
4959 | error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
|
4960 | }
|
4961 |
|
4962 | var hasMutatedProps = instance.props !== newProps;
|
4963 |
|
4964 | if (instance.props !== undefined && hasMutatedProps) {
|
4965 | error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
|
4966 | }
|
4967 |
|
4968 | if (instance.defaultProps) {
|
4969 | error('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);
|
4970 | }
|
4971 |
|
4972 | if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
|
4973 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
|
4974 |
|
4975 | error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentNameFromType(ctor));
|
4976 | }
|
4977 |
|
4978 | if (typeof instance.getDerivedStateFromProps === 'function') {
|
4979 | error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
|
4980 | }
|
4981 |
|
4982 | if (typeof instance.getDerivedStateFromError === 'function') {
|
4983 | error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
|
4984 | }
|
4985 |
|
4986 | if (typeof ctor.getSnapshotBeforeUpdate === 'function') {
|
4987 | error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name);
|
4988 | }
|
4989 |
|
4990 | var _state = instance.state;
|
4991 |
|
4992 | if (_state && (typeof _state !== 'object' || isArray(_state))) {
|
4993 | error('%s.state: must be set to an object or null', name);
|
4994 | }
|
4995 |
|
4996 | if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') {
|
4997 | error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
|
4998 | }
|
4999 | }
|
5000 | }
|
5001 |
|
5002 | function adoptClassInstance(workInProgress, instance) {
|
5003 | instance.updater = classComponentUpdater;
|
5004 | workInProgress.stateNode = instance;
|
5005 |
|
5006 | set(instance, workInProgress);
|
5007 |
|
5008 | {
|
5009 | instance._reactInternalInstance = fakeInternalInstance;
|
5010 | }
|
5011 | }
|
5012 |
|
5013 | function constructClassInstance(workInProgress, ctor, props) {
|
5014 | var isLegacyContextConsumer = false;
|
5015 | var unmaskedContext = emptyContextObject;
|
5016 | var context = emptyContextObject;
|
5017 | var contextType = ctor.contextType;
|
5018 |
|
5019 | {
|
5020 | if ('contextType' in ctor) {
|
5021 | var isValid =
|
5022 | contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined;
|
5023 |
|
5024 | if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
|
5025 | didWarnAboutInvalidateContextType.add(ctor);
|
5026 | var addendum = '';
|
5027 |
|
5028 | if (contextType === undefined) {
|
5029 | 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.';
|
5030 | } else if (typeof contextType !== 'object') {
|
5031 | addendum = ' However, it is set to a ' + typeof contextType + '.';
|
5032 | } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
|
5033 | addendum = ' Did you accidentally pass the Context.Provider instead?';
|
5034 | } else if (contextType._context !== undefined) {
|
5035 |
|
5036 | addendum = ' Did you accidentally pass the Context.Consumer instead?';
|
5037 | } else {
|
5038 | addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
|
5039 | }
|
5040 |
|
5041 | error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentNameFromType(ctor) || 'Component', addendum);
|
5042 | }
|
5043 | }
|
5044 | }
|
5045 |
|
5046 | if (typeof contextType === 'object' && contextType !== null) {
|
5047 | context = readContext(contextType);
|
5048 | } else {
|
5049 | unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
5050 | var contextTypes = ctor.contextTypes;
|
5051 | isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
|
5052 | context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
|
5053 | }
|
5054 |
|
5055 | var instance = new ctor(props, context);
|
5056 |
|
5057 | {
|
5058 | if ( workInProgress.mode & StrictLegacyMode) {
|
5059 | setIsStrictModeForDevtools(true);
|
5060 |
|
5061 | try {
|
5062 | instance = new ctor(props, context);
|
5063 | } finally {
|
5064 | setIsStrictModeForDevtools(false);
|
5065 | }
|
5066 | }
|
5067 | }
|
5068 |
|
5069 | var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
|
5070 | adoptClassInstance(workInProgress, instance);
|
5071 |
|
5072 | {
|
5073 | if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
|
5074 | var componentName = getComponentNameFromType(ctor) || 'Component';
|
5075 |
|
5076 | if (!didWarnAboutUninitializedState.has(componentName)) {
|
5077 | didWarnAboutUninitializedState.add(componentName);
|
5078 |
|
5079 | error('`%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);
|
5080 | }
|
5081 | }
|
5082 |
|
5083 |
|
5084 |
|
5085 |
|
5086 | if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
|
5087 | var foundWillMountName = null;
|
5088 | var foundWillReceivePropsName = null;
|
5089 | var foundWillUpdateName = null;
|
5090 |
|
5091 | if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
5092 | foundWillMountName = 'componentWillMount';
|
5093 | } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
5094 | foundWillMountName = 'UNSAFE_componentWillMount';
|
5095 | }
|
5096 |
|
5097 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
5098 | foundWillReceivePropsName = 'componentWillReceiveProps';
|
5099 | } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
5100 | foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
|
5101 | }
|
5102 |
|
5103 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
5104 | foundWillUpdateName = 'componentWillUpdate';
|
5105 | } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
5106 | foundWillUpdateName = 'UNSAFE_componentWillUpdate';
|
5107 | }
|
5108 |
|
5109 | if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
|
5110 | var _componentName = getComponentNameFromType(ctor) || 'Component';
|
5111 |
|
5112 | var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
|
5113 |
|
5114 | if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
|
5115 | didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
|
5116 |
|
5117 | error('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://reactjs.org/link/unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
|
5118 | }
|
5119 | }
|
5120 | }
|
5121 | }
|
5122 |
|
5123 |
|
5124 |
|
5125 | if (isLegacyContextConsumer) {
|
5126 | cacheContext(workInProgress, unmaskedContext, context);
|
5127 | }
|
5128 |
|
5129 | return instance;
|
5130 | }
|
5131 |
|
5132 | function callComponentWillMount(workInProgress, instance) {
|
5133 | var oldState = instance.state;
|
5134 |
|
5135 | if (typeof instance.componentWillMount === 'function') {
|
5136 | instance.componentWillMount();
|
5137 | }
|
5138 |
|
5139 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
5140 | instance.UNSAFE_componentWillMount();
|
5141 | }
|
5142 |
|
5143 | if (oldState !== instance.state) {
|
5144 | {
|
5145 | error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentNameFromFiber(workInProgress) || 'Component');
|
5146 | }
|
5147 |
|
5148 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
5149 | }
|
5150 | }
|
5151 |
|
5152 | function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
|
5153 | var oldState = instance.state;
|
5154 |
|
5155 | if (typeof instance.componentWillReceiveProps === 'function') {
|
5156 | instance.componentWillReceiveProps(newProps, nextContext);
|
5157 | }
|
5158 |
|
5159 | if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
5160 | instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
|
5161 | }
|
5162 |
|
5163 | if (instance.state !== oldState) {
|
5164 | {
|
5165 | var componentName = getComponentNameFromFiber(workInProgress) || 'Component';
|
5166 |
|
5167 | if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
|
5168 | didWarnAboutStateAssignmentForComponent.add(componentName);
|
5169 |
|
5170 | error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
|
5171 | }
|
5172 | }
|
5173 |
|
5174 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
5175 | }
|
5176 | }
|
5177 |
|
5178 |
|
5179 | function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
|
5180 | {
|
5181 | checkClassInstance(workInProgress, ctor, newProps);
|
5182 | }
|
5183 |
|
5184 | var instance = workInProgress.stateNode;
|
5185 | instance.props = newProps;
|
5186 | instance.state = workInProgress.memoizedState;
|
5187 | instance.refs = emptyRefsObject;
|
5188 | initializeUpdateQueue(workInProgress);
|
5189 | var contextType = ctor.contextType;
|
5190 |
|
5191 | if (typeof contextType === 'object' && contextType !== null) {
|
5192 | instance.context = readContext(contextType);
|
5193 | } else {
|
5194 | var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
5195 | instance.context = getMaskedContext(workInProgress, unmaskedContext);
|
5196 | }
|
5197 |
|
5198 | {
|
5199 | if (instance.state === newProps) {
|
5200 | var componentName = getComponentNameFromType(ctor) || 'Component';
|
5201 |
|
5202 | if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
|
5203 | didWarnAboutDirectlyAssigningPropsToState.add(componentName);
|
5204 |
|
5205 | error('%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);
|
5206 | }
|
5207 | }
|
5208 |
|
5209 | if (workInProgress.mode & StrictLegacyMode) {
|
5210 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
|
5211 | }
|
5212 |
|
5213 | {
|
5214 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
|
5215 | }
|
5216 | }
|
5217 |
|
5218 | instance.state = workInProgress.memoizedState;
|
5219 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
5220 |
|
5221 | if (typeof getDerivedStateFromProps === 'function') {
|
5222 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
5223 | instance.state = workInProgress.memoizedState;
|
5224 | }
|
5225 |
|
5226 |
|
5227 |
|
5228 | if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
5229 | callComponentWillMount(workInProgress, instance);
|
5230 |
|
5231 |
|
5232 | processUpdateQueue(workInProgress, newProps, instance, renderLanes);
|
5233 | instance.state = workInProgress.memoizedState;
|
5234 | }
|
5235 |
|
5236 | if (typeof instance.componentDidMount === 'function') {
|
5237 | var fiberFlags = Update;
|
5238 |
|
5239 | {
|
5240 | fiberFlags |= LayoutStatic;
|
5241 | }
|
5242 |
|
5243 | if ( (workInProgress.mode & StrictEffectsMode) !== NoMode) {
|
5244 | fiberFlags |= MountLayoutDev;
|
5245 | }
|
5246 |
|
5247 | workInProgress.flags |= fiberFlags;
|
5248 | }
|
5249 | }
|
5250 |
|
5251 | function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) {
|
5252 | var instance = workInProgress.stateNode;
|
5253 | var oldProps = workInProgress.memoizedProps;
|
5254 | instance.props = oldProps;
|
5255 | var oldContext = instance.context;
|
5256 | var contextType = ctor.contextType;
|
5257 | var nextContext = emptyContextObject;
|
5258 |
|
5259 | if (typeof contextType === 'object' && contextType !== null) {
|
5260 | nextContext = readContext(contextType);
|
5261 | } else {
|
5262 | var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
5263 | nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
|
5264 | }
|
5265 |
|
5266 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
5267 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
5268 |
|
5269 |
|
5270 |
|
5271 |
|
5272 |
|
5273 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
5274 | if (oldProps !== newProps || oldContext !== nextContext) {
|
5275 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
5276 | }
|
5277 | }
|
5278 |
|
5279 | resetHasForceUpdateBeforeProcessing();
|
5280 | var oldState = workInProgress.memoizedState;
|
5281 | var newState = instance.state = oldState;
|
5282 | processUpdateQueue(workInProgress, newProps, instance, renderLanes);
|
5283 | newState = workInProgress.memoizedState;
|
5284 |
|
5285 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
5286 |
|
5287 |
|
5288 | if (typeof instance.componentDidMount === 'function') {
|
5289 | var fiberFlags = Update;
|
5290 |
|
5291 | {
|
5292 | fiberFlags |= LayoutStatic;
|
5293 | }
|
5294 |
|
5295 | if ( (workInProgress.mode & StrictEffectsMode) !== NoMode) {
|
5296 | fiberFlags |= MountLayoutDev;
|
5297 | }
|
5298 |
|
5299 | workInProgress.flags |= fiberFlags;
|
5300 | }
|
5301 |
|
5302 | return false;
|
5303 | }
|
5304 |
|
5305 | if (typeof getDerivedStateFromProps === 'function') {
|
5306 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
5307 | newState = workInProgress.memoizedState;
|
5308 | }
|
5309 |
|
5310 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
|
5311 |
|
5312 | if (shouldUpdate) {
|
5313 |
|
5314 |
|
5315 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
5316 | if (typeof instance.componentWillMount === 'function') {
|
5317 | instance.componentWillMount();
|
5318 | }
|
5319 |
|
5320 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
5321 | instance.UNSAFE_componentWillMount();
|
5322 | }
|
5323 | }
|
5324 |
|
5325 | if (typeof instance.componentDidMount === 'function') {
|
5326 | var _fiberFlags = Update;
|
5327 |
|
5328 | {
|
5329 | _fiberFlags |= LayoutStatic;
|
5330 | }
|
5331 |
|
5332 | if ( (workInProgress.mode & StrictEffectsMode) !== NoMode) {
|
5333 | _fiberFlags |= MountLayoutDev;
|
5334 | }
|
5335 |
|
5336 | workInProgress.flags |= _fiberFlags;
|
5337 | }
|
5338 | } else {
|
5339 |
|
5340 |
|
5341 | if (typeof instance.componentDidMount === 'function') {
|
5342 | var _fiberFlags2 = Update;
|
5343 |
|
5344 | {
|
5345 | _fiberFlags2 |= LayoutStatic;
|
5346 | }
|
5347 |
|
5348 | if ( (workInProgress.mode & StrictEffectsMode) !== NoMode) {
|
5349 | _fiberFlags2 |= MountLayoutDev;
|
5350 | }
|
5351 |
|
5352 | workInProgress.flags |= _fiberFlags2;
|
5353 | }
|
5354 |
|
5355 |
|
5356 |
|
5357 | workInProgress.memoizedProps = newProps;
|
5358 | workInProgress.memoizedState = newState;
|
5359 | }
|
5360 |
|
5361 |
|
5362 |
|
5363 | instance.props = newProps;
|
5364 | instance.state = newState;
|
5365 | instance.context = nextContext;
|
5366 | return shouldUpdate;
|
5367 | }
|
5368 |
|
5369 |
|
5370 | function updateClassInstance(current, workInProgress, ctor, newProps, renderLanes) {
|
5371 | var instance = workInProgress.stateNode;
|
5372 | cloneUpdateQueue(current, workInProgress);
|
5373 | var unresolvedOldProps = workInProgress.memoizedProps;
|
5374 | var oldProps = workInProgress.type === workInProgress.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress.type, unresolvedOldProps);
|
5375 | instance.props = oldProps;
|
5376 | var unresolvedNewProps = workInProgress.pendingProps;
|
5377 | var oldContext = instance.context;
|
5378 | var contextType = ctor.contextType;
|
5379 | var nextContext = emptyContextObject;
|
5380 |
|
5381 | if (typeof contextType === 'object' && contextType !== null) {
|
5382 | nextContext = readContext(contextType);
|
5383 | } else {
|
5384 | var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
5385 | nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
|
5386 | }
|
5387 |
|
5388 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
5389 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
5390 |
|
5391 |
|
5392 |
|
5393 |
|
5394 |
|
5395 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
5396 | if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) {
|
5397 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
5398 | }
|
5399 | }
|
5400 |
|
5401 | resetHasForceUpdateBeforeProcessing();
|
5402 | var oldState = workInProgress.memoizedState;
|
5403 | var newState = instance.state = oldState;
|
5404 | processUpdateQueue(workInProgress, newProps, instance, renderLanes);
|
5405 | newState = workInProgress.memoizedState;
|
5406 |
|
5407 | if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() && !(enableLazyContextPropagation )) {
|
5408 |
|
5409 |
|
5410 | if (typeof instance.componentDidUpdate === 'function') {
|
5411 | if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
5412 | workInProgress.flags |= Update;
|
5413 | }
|
5414 | }
|
5415 |
|
5416 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
5417 | if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
5418 | workInProgress.flags |= Snapshot;
|
5419 | }
|
5420 | }
|
5421 |
|
5422 | return false;
|
5423 | }
|
5424 |
|
5425 | if (typeof getDerivedStateFromProps === 'function') {
|
5426 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
5427 | newState = workInProgress.memoizedState;
|
5428 | }
|
5429 |
|
5430 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) ||
|
5431 |
|
5432 |
|
5433 |
|
5434 | enableLazyContextPropagation ;
|
5435 |
|
5436 | if (shouldUpdate) {
|
5437 |
|
5438 |
|
5439 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
|
5440 | if (typeof instance.componentWillUpdate === 'function') {
|
5441 | instance.componentWillUpdate(newProps, newState, nextContext);
|
5442 | }
|
5443 |
|
5444 | if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
5445 | instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
|
5446 | }
|
5447 | }
|
5448 |
|
5449 | if (typeof instance.componentDidUpdate === 'function') {
|
5450 | workInProgress.flags |= Update;
|
5451 | }
|
5452 |
|
5453 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
5454 | workInProgress.flags |= Snapshot;
|
5455 | }
|
5456 | } else {
|
5457 |
|
5458 |
|
5459 | if (typeof instance.componentDidUpdate === 'function') {
|
5460 | if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
5461 | workInProgress.flags |= Update;
|
5462 | }
|
5463 | }
|
5464 |
|
5465 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
5466 | if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
5467 | workInProgress.flags |= Snapshot;
|
5468 | }
|
5469 | }
|
5470 |
|
5471 |
|
5472 |
|
5473 | workInProgress.memoizedProps = newProps;
|
5474 | workInProgress.memoizedState = newState;
|
5475 | }
|
5476 |
|
5477 |
|
5478 |
|
5479 | instance.props = newProps;
|
5480 | instance.state = newState;
|
5481 | instance.context = nextContext;
|
5482 | return shouldUpdate;
|
5483 | }
|
5484 |
|
5485 |
|
5486 |
|
5487 |
|
5488 |
|
5489 | var forkStack = [];
|
5490 | var forkStackIndex = 0;
|
5491 | var treeForkProvider = null;
|
5492 | var treeForkCount = 0;
|
5493 | var idStack = [];
|
5494 | var idStackIndex = 0;
|
5495 | var treeContextProvider = null;
|
5496 | var treeContextId = 1;
|
5497 | var treeContextOverflow = '';
|
5498 |
|
5499 | function popTreeContext(workInProgress) {
|
5500 |
|
5501 |
|
5502 |
|
5503 |
|
5504 |
|
5505 | while (workInProgress === treeForkProvider) {
|
5506 | treeForkProvider = forkStack[--forkStackIndex];
|
5507 | forkStack[forkStackIndex] = null;
|
5508 | treeForkCount = forkStack[--forkStackIndex];
|
5509 | forkStack[forkStackIndex] = null;
|
5510 | }
|
5511 |
|
5512 | while (workInProgress === treeContextProvider) {
|
5513 | treeContextProvider = idStack[--idStackIndex];
|
5514 | idStack[idStackIndex] = null;
|
5515 | treeContextOverflow = idStack[--idStackIndex];
|
5516 | idStack[idStackIndex] = null;
|
5517 | treeContextId = idStack[--idStackIndex];
|
5518 | idStack[idStackIndex] = null;
|
5519 | }
|
5520 | }
|
5521 |
|
5522 | var isHydrating = false;
|
5523 |
|
5524 | var hydrationErrors = null;
|
5525 |
|
5526 | function reenterHydrationStateFromDehydratedSuspenseInstance(fiber, suspenseInstance, treeContext) {
|
5527 | {
|
5528 | return false;
|
5529 | }
|
5530 | }
|
5531 |
|
5532 | function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
|
5533 | {
|
5534 | throw new Error('Expected prepareToHydrateHostInstance() to never be called. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
5535 | }
|
5536 | }
|
5537 |
|
5538 | function prepareToHydrateHostTextInstance(fiber) {
|
5539 | {
|
5540 | throw new Error('Expected prepareToHydrateHostTextInstance() to never be called. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
5541 | }
|
5542 | var shouldUpdate = hydrateTextInstance();
|
5543 | }
|
5544 |
|
5545 | function prepareToHydrateHostSuspenseInstance(fiber) {
|
5546 | {
|
5547 | throw new Error('Expected prepareToHydrateHostSuspenseInstance() to never be called. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
5548 | }
|
5549 | }
|
5550 |
|
5551 | function popHydrationState(fiber) {
|
5552 | {
|
5553 | return false;
|
5554 | }
|
5555 | }
|
5556 |
|
5557 | function upgradeHydrationErrorsToRecoverable() {
|
5558 | if (hydrationErrors !== null) {
|
5559 |
|
5560 |
|
5561 |
|
5562 | queueRecoverableErrors(hydrationErrors);
|
5563 | hydrationErrors = null;
|
5564 | }
|
5565 | }
|
5566 |
|
5567 | function getIsHydrating() {
|
5568 | return isHydrating;
|
5569 | }
|
5570 |
|
5571 | function queueHydrationError(error) {
|
5572 | if (hydrationErrors === null) {
|
5573 | hydrationErrors = [error];
|
5574 | } else {
|
5575 | hydrationErrors.push(error);
|
5576 | }
|
5577 | }
|
5578 |
|
5579 | var didWarnAboutMaps;
|
5580 | var didWarnAboutGenerators;
|
5581 | var didWarnAboutStringRefs;
|
5582 | var ownerHasKeyUseWarning;
|
5583 | var ownerHasFunctionTypeWarning;
|
5584 |
|
5585 | var warnForMissingKey = function (child, returnFiber) {};
|
5586 |
|
5587 | {
|
5588 | didWarnAboutMaps = false;
|
5589 | didWarnAboutGenerators = false;
|
5590 | didWarnAboutStringRefs = {};
|
5591 | |
5592 |
|
5593 |
|
5594 |
|
5595 |
|
5596 |
|
5597 | ownerHasKeyUseWarning = {};
|
5598 | ownerHasFunctionTypeWarning = {};
|
5599 |
|
5600 | warnForMissingKey = function (child, returnFiber) {
|
5601 | if (child === null || typeof child !== 'object') {
|
5602 | return;
|
5603 | }
|
5604 |
|
5605 | if (!child._store || child._store.validated || child.key != null) {
|
5606 | return;
|
5607 | }
|
5608 |
|
5609 | if (typeof child._store !== 'object') {
|
5610 | throw new Error('React Component in warnForMissingKey should have a _store. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
5611 | }
|
5612 |
|
5613 | child._store.validated = true;
|
5614 | var componentName = getComponentNameFromFiber(returnFiber) || 'Component';
|
5615 |
|
5616 | if (ownerHasKeyUseWarning[componentName]) {
|
5617 | return;
|
5618 | }
|
5619 |
|
5620 | ownerHasKeyUseWarning[componentName] = true;
|
5621 |
|
5622 | error('Each child in a list should have a unique ' + '"key" prop. See https://reactjs.org/link/warning-keys for ' + 'more information.');
|
5623 | };
|
5624 | }
|
5625 |
|
5626 | function coerceRef(returnFiber, current, element) {
|
5627 | var mixedRef = element.ref;
|
5628 |
|
5629 | if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
|
5630 | {
|
5631 |
|
5632 |
|
5633 | if ((returnFiber.mode & StrictLegacyMode || warnAboutStringRefs) &&
|
5634 |
|
5635 |
|
5636 | !(element._owner && element._self && element._owner.stateNode !== element._self)) {
|
5637 | var componentName = getComponentNameFromFiber(returnFiber) || 'Component';
|
5638 |
|
5639 | if (!didWarnAboutStringRefs[componentName]) {
|
5640 | {
|
5641 | error('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://reactjs.org/link/strict-mode-string-ref', mixedRef);
|
5642 | }
|
5643 |
|
5644 | didWarnAboutStringRefs[componentName] = true;
|
5645 | }
|
5646 | }
|
5647 | }
|
5648 |
|
5649 | if (element._owner) {
|
5650 | var owner = element._owner;
|
5651 | var inst;
|
5652 |
|
5653 | if (owner) {
|
5654 | var ownerFiber = owner;
|
5655 |
|
5656 | if (ownerFiber.tag !== ClassComponent) {
|
5657 | throw new Error('Function components cannot have string refs. ' + 'We recommend using useRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref');
|
5658 | }
|
5659 |
|
5660 | inst = ownerFiber.stateNode;
|
5661 | }
|
5662 |
|
5663 | if (!inst) {
|
5664 | throw new Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a " + 'bug in React. Please file an issue.');
|
5665 | }
|
5666 |
|
5667 |
|
5668 | var resolvedInst = inst;
|
5669 |
|
5670 | {
|
5671 | checkPropStringCoercion(mixedRef, 'ref');
|
5672 | }
|
5673 |
|
5674 | var stringRef = '' + mixedRef;
|
5675 |
|
5676 | if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) {
|
5677 | return current.ref;
|
5678 | }
|
5679 |
|
5680 | var ref = function (value) {
|
5681 | var refs = resolvedInst.refs;
|
5682 |
|
5683 | if (refs === emptyRefsObject) {
|
5684 |
|
5685 | refs = resolvedInst.refs = {};
|
5686 | }
|
5687 |
|
5688 | if (value === null) {
|
5689 | delete refs[stringRef];
|
5690 | } else {
|
5691 | refs[stringRef] = value;
|
5692 | }
|
5693 | };
|
5694 |
|
5695 | ref._stringRef = stringRef;
|
5696 | return ref;
|
5697 | } else {
|
5698 | if (typeof mixedRef !== 'string') {
|
5699 | throw new Error('Expected ref to be a function, a string, an object returned by React.createRef(), or null.');
|
5700 | }
|
5701 |
|
5702 | if (!element._owner) {
|
5703 | throw new Error("Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of" + ' the following reasons:\n' + '1. You may be adding a ref to a function component\n' + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + '3. You have multiple copies of React loaded\n' + 'See https://reactjs.org/link/refs-must-have-owner for more information.');
|
5704 | }
|
5705 | }
|
5706 | }
|
5707 |
|
5708 | return mixedRef;
|
5709 | }
|
5710 |
|
5711 | function throwOnInvalidObjectType(returnFiber, newChild) {
|
5712 | var childString = Object.prototype.toString.call(newChild);
|
5713 | throw new Error("Objects are not valid as a React child (found: " + (childString === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : childString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');
|
5714 | }
|
5715 |
|
5716 | function warnOnFunctionType(returnFiber) {
|
5717 | {
|
5718 | var componentName = getComponentNameFromFiber(returnFiber) || 'Component';
|
5719 |
|
5720 | if (ownerHasFunctionTypeWarning[componentName]) {
|
5721 | return;
|
5722 | }
|
5723 |
|
5724 | ownerHasFunctionTypeWarning[componentName] = true;
|
5725 |
|
5726 | error('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.');
|
5727 | }
|
5728 | }
|
5729 |
|
5730 | function resolveLazy(lazyType) {
|
5731 | var payload = lazyType._payload;
|
5732 | var init = lazyType._init;
|
5733 | return init(payload);
|
5734 | }
|
5735 |
|
5736 |
|
5737 |
|
5738 |
|
5739 |
|
5740 | function ChildReconciler(shouldTrackSideEffects) {
|
5741 | function deleteChild(returnFiber, childToDelete) {
|
5742 | if (!shouldTrackSideEffects) {
|
5743 |
|
5744 | return;
|
5745 | }
|
5746 |
|
5747 | var deletions = returnFiber.deletions;
|
5748 |
|
5749 | if (deletions === null) {
|
5750 | returnFiber.deletions = [childToDelete];
|
5751 | returnFiber.flags |= ChildDeletion;
|
5752 | } else {
|
5753 | deletions.push(childToDelete);
|
5754 | }
|
5755 | }
|
5756 |
|
5757 | function deleteRemainingChildren(returnFiber, currentFirstChild) {
|
5758 | if (!shouldTrackSideEffects) {
|
5759 |
|
5760 | return null;
|
5761 | }
|
5762 |
|
5763 |
|
5764 |
|
5765 | var childToDelete = currentFirstChild;
|
5766 |
|
5767 | while (childToDelete !== null) {
|
5768 | deleteChild(returnFiber, childToDelete);
|
5769 | childToDelete = childToDelete.sibling;
|
5770 | }
|
5771 |
|
5772 | return null;
|
5773 | }
|
5774 |
|
5775 | function mapRemainingChildren(returnFiber, currentFirstChild) {
|
5776 |
|
5777 |
|
5778 |
|
5779 | var existingChildren = new Map();
|
5780 | var existingChild = currentFirstChild;
|
5781 |
|
5782 | while (existingChild !== null) {
|
5783 | if (existingChild.key !== null) {
|
5784 | existingChildren.set(existingChild.key, existingChild);
|
5785 | } else {
|
5786 | existingChildren.set(existingChild.index, existingChild);
|
5787 | }
|
5788 |
|
5789 | existingChild = existingChild.sibling;
|
5790 | }
|
5791 |
|
5792 | return existingChildren;
|
5793 | }
|
5794 |
|
5795 | function useFiber(fiber, pendingProps) {
|
5796 |
|
5797 |
|
5798 | var clone = createWorkInProgress(fiber, pendingProps);
|
5799 | clone.index = 0;
|
5800 | clone.sibling = null;
|
5801 | return clone;
|
5802 | }
|
5803 |
|
5804 | function placeChild(newFiber, lastPlacedIndex, newIndex) {
|
5805 | newFiber.index = newIndex;
|
5806 |
|
5807 | if (!shouldTrackSideEffects) {
|
5808 |
|
5809 |
|
5810 | newFiber.flags |= Forked;
|
5811 | return lastPlacedIndex;
|
5812 | }
|
5813 |
|
5814 | var current = newFiber.alternate;
|
5815 |
|
5816 | if (current !== null) {
|
5817 | var oldIndex = current.index;
|
5818 |
|
5819 | if (oldIndex < lastPlacedIndex) {
|
5820 |
|
5821 | newFiber.flags |= Placement;
|
5822 | return lastPlacedIndex;
|
5823 | } else {
|
5824 |
|
5825 | return oldIndex;
|
5826 | }
|
5827 | } else {
|
5828 |
|
5829 | newFiber.flags |= Placement;
|
5830 | return lastPlacedIndex;
|
5831 | }
|
5832 | }
|
5833 |
|
5834 | function placeSingleChild(newFiber) {
|
5835 |
|
5836 |
|
5837 | if (shouldTrackSideEffects && newFiber.alternate === null) {
|
5838 | newFiber.flags |= Placement;
|
5839 | }
|
5840 |
|
5841 | return newFiber;
|
5842 | }
|
5843 |
|
5844 | function updateTextNode(returnFiber, current, textContent, lanes) {
|
5845 | if (current === null || current.tag !== HostText) {
|
5846 |
|
5847 | var created = createFiberFromText(textContent, returnFiber.mode, lanes);
|
5848 | created.return = returnFiber;
|
5849 | return created;
|
5850 | } else {
|
5851 |
|
5852 | var existing = useFiber(current, textContent);
|
5853 | existing.return = returnFiber;
|
5854 | return existing;
|
5855 | }
|
5856 | }
|
5857 |
|
5858 | function updateElement(returnFiber, current, element, lanes) {
|
5859 | var elementType = element.type;
|
5860 |
|
5861 | if (elementType === REACT_FRAGMENT_TYPE) {
|
5862 | return updateFragment(returnFiber, current, element.props.children, lanes, element.key);
|
5863 | }
|
5864 |
|
5865 | if (current !== null) {
|
5866 | if (current.elementType === elementType || (
|
5867 | isCompatibleFamilyForHotReloading(current, element) ) ||
|
5868 |
|
5869 |
|
5870 |
|
5871 | typeof elementType === 'object' && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === current.type) {
|
5872 |
|
5873 | var existing = useFiber(current, element.props);
|
5874 | existing.ref = coerceRef(returnFiber, current, element);
|
5875 | existing.return = returnFiber;
|
5876 |
|
5877 | {
|
5878 | existing._debugSource = element._source;
|
5879 | existing._debugOwner = element._owner;
|
5880 | }
|
5881 |
|
5882 | return existing;
|
5883 | }
|
5884 | }
|
5885 |
|
5886 |
|
5887 | var created = createFiberFromElement(element, returnFiber.mode, lanes);
|
5888 | created.ref = coerceRef(returnFiber, current, element);
|
5889 | created.return = returnFiber;
|
5890 | return created;
|
5891 | }
|
5892 |
|
5893 | function updatePortal(returnFiber, current, portal, lanes) {
|
5894 | if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {
|
5895 |
|
5896 | var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
|
5897 | created.return = returnFiber;
|
5898 | return created;
|
5899 | } else {
|
5900 |
|
5901 | var existing = useFiber(current, portal.children || []);
|
5902 | existing.return = returnFiber;
|
5903 | return existing;
|
5904 | }
|
5905 | }
|
5906 |
|
5907 | function updateFragment(returnFiber, current, fragment, lanes, key) {
|
5908 | if (current === null || current.tag !== Fragment) {
|
5909 |
|
5910 | var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
5911 | created.return = returnFiber;
|
5912 | return created;
|
5913 | } else {
|
5914 |
|
5915 | var existing = useFiber(current, fragment);
|
5916 | existing.return = returnFiber;
|
5917 | return existing;
|
5918 | }
|
5919 | }
|
5920 |
|
5921 | function createChild(returnFiber, newChild, lanes) {
|
5922 | if (typeof newChild === 'string' && newChild !== '' || typeof newChild === 'number') {
|
5923 |
|
5924 |
|
5925 |
|
5926 | var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);
|
5927 | created.return = returnFiber;
|
5928 | return created;
|
5929 | }
|
5930 |
|
5931 | if (typeof newChild === 'object' && newChild !== null) {
|
5932 | switch (newChild.$$typeof) {
|
5933 | case REACT_ELEMENT_TYPE:
|
5934 | {
|
5935 | var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);
|
5936 |
|
5937 | _created.ref = coerceRef(returnFiber, null, newChild);
|
5938 | _created.return = returnFiber;
|
5939 | return _created;
|
5940 | }
|
5941 |
|
5942 | case REACT_PORTAL_TYPE:
|
5943 | {
|
5944 | var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);
|
5945 |
|
5946 | _created2.return = returnFiber;
|
5947 | return _created2;
|
5948 | }
|
5949 |
|
5950 | case REACT_LAZY_TYPE:
|
5951 | {
|
5952 | {
|
5953 | var payload = newChild._payload;
|
5954 | var init = newChild._init;
|
5955 | return createChild(returnFiber, init(payload), lanes);
|
5956 | }
|
5957 | }
|
5958 | }
|
5959 |
|
5960 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
5961 | var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);
|
5962 |
|
5963 | _created3.return = returnFiber;
|
5964 | return _created3;
|
5965 | }
|
5966 |
|
5967 | throwOnInvalidObjectType(returnFiber, newChild);
|
5968 | }
|
5969 |
|
5970 | {
|
5971 | if (typeof newChild === 'function') {
|
5972 | warnOnFunctionType(returnFiber);
|
5973 | }
|
5974 | }
|
5975 |
|
5976 | return null;
|
5977 | }
|
5978 |
|
5979 | function updateSlot(returnFiber, oldFiber, newChild, lanes) {
|
5980 |
|
5981 | var key = oldFiber !== null ? oldFiber.key : null;
|
5982 |
|
5983 | if (typeof newChild === 'string' && newChild !== '' || typeof newChild === 'number') {
|
5984 |
|
5985 |
|
5986 |
|
5987 | if (key !== null) {
|
5988 | return null;
|
5989 | }
|
5990 |
|
5991 | return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);
|
5992 | }
|
5993 |
|
5994 | if (typeof newChild === 'object' && newChild !== null) {
|
5995 | switch (newChild.$$typeof) {
|
5996 | case REACT_ELEMENT_TYPE:
|
5997 | {
|
5998 | if (newChild.key === key) {
|
5999 | return updateElement(returnFiber, oldFiber, newChild, lanes);
|
6000 | } else {
|
6001 | return null;
|
6002 | }
|
6003 | }
|
6004 |
|
6005 | case REACT_PORTAL_TYPE:
|
6006 | {
|
6007 | if (newChild.key === key) {
|
6008 | return updatePortal(returnFiber, oldFiber, newChild, lanes);
|
6009 | } else {
|
6010 | return null;
|
6011 | }
|
6012 | }
|
6013 |
|
6014 | case REACT_LAZY_TYPE:
|
6015 | {
|
6016 | {
|
6017 | var payload = newChild._payload;
|
6018 | var init = newChild._init;
|
6019 | return updateSlot(returnFiber, oldFiber, init(payload), lanes);
|
6020 | }
|
6021 | }
|
6022 | }
|
6023 |
|
6024 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
6025 | if (key !== null) {
|
6026 | return null;
|
6027 | }
|
6028 |
|
6029 | return updateFragment(returnFiber, oldFiber, newChild, lanes, null);
|
6030 | }
|
6031 |
|
6032 | throwOnInvalidObjectType(returnFiber, newChild);
|
6033 | }
|
6034 |
|
6035 | {
|
6036 | if (typeof newChild === 'function') {
|
6037 | warnOnFunctionType(returnFiber);
|
6038 | }
|
6039 | }
|
6040 |
|
6041 | return null;
|
6042 | }
|
6043 |
|
6044 | function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {
|
6045 | if (typeof newChild === 'string' && newChild !== '' || typeof newChild === 'number') {
|
6046 |
|
6047 |
|
6048 | var matchedFiber = existingChildren.get(newIdx) || null;
|
6049 | return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);
|
6050 | }
|
6051 |
|
6052 | if (typeof newChild === 'object' && newChild !== null) {
|
6053 | switch (newChild.$$typeof) {
|
6054 | case REACT_ELEMENT_TYPE:
|
6055 | {
|
6056 | var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
6057 |
|
6058 | return updateElement(returnFiber, _matchedFiber, newChild, lanes);
|
6059 | }
|
6060 |
|
6061 | case REACT_PORTAL_TYPE:
|
6062 | {
|
6063 | var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
6064 |
|
6065 | return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);
|
6066 | }
|
6067 |
|
6068 | case REACT_LAZY_TYPE:
|
6069 | {
|
6070 | var payload = newChild._payload;
|
6071 | var init = newChild._init;
|
6072 | return updateFromMap(existingChildren, returnFiber, newIdx, init(payload), lanes);
|
6073 | }
|
6074 |
|
6075 | }
|
6076 |
|
6077 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
6078 | var _matchedFiber3 = existingChildren.get(newIdx) || null;
|
6079 |
|
6080 | return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);
|
6081 | }
|
6082 |
|
6083 | throwOnInvalidObjectType(returnFiber, newChild);
|
6084 | }
|
6085 |
|
6086 | {
|
6087 | if (typeof newChild === 'function') {
|
6088 | warnOnFunctionType(returnFiber);
|
6089 | }
|
6090 | }
|
6091 |
|
6092 | return null;
|
6093 | }
|
6094 | |
6095 |
|
6096 |
|
6097 |
|
6098 |
|
6099 | function warnOnInvalidKey(child, knownKeys, returnFiber) {
|
6100 | {
|
6101 | if (typeof child !== 'object' || child === null) {
|
6102 | return knownKeys;
|
6103 | }
|
6104 |
|
6105 | switch (child.$$typeof) {
|
6106 | case REACT_ELEMENT_TYPE:
|
6107 | case REACT_PORTAL_TYPE:
|
6108 | warnForMissingKey(child, returnFiber);
|
6109 | var key = child.key;
|
6110 |
|
6111 | if (typeof key !== 'string') {
|
6112 | break;
|
6113 | }
|
6114 |
|
6115 | if (knownKeys === null) {
|
6116 | knownKeys = new Set();
|
6117 | knownKeys.add(key);
|
6118 | break;
|
6119 | }
|
6120 |
|
6121 | if (!knownKeys.has(key)) {
|
6122 | knownKeys.add(key);
|
6123 | break;
|
6124 | }
|
6125 |
|
6126 | error('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);
|
6127 |
|
6128 | break;
|
6129 |
|
6130 | case REACT_LAZY_TYPE:
|
6131 | {
|
6132 | var payload = child._payload;
|
6133 | var init = child._init;
|
6134 | warnOnInvalidKey(init(payload), knownKeys, returnFiber);
|
6135 | break;
|
6136 | }
|
6137 | }
|
6138 | }
|
6139 |
|
6140 | return knownKeys;
|
6141 | }
|
6142 |
|
6143 | function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {
|
6144 |
|
6145 |
|
6146 |
|
6147 |
|
6148 |
|
6149 |
|
6150 |
|
6151 |
|
6152 |
|
6153 |
|
6154 |
|
6155 |
|
6156 |
|
6157 |
|
6158 |
|
6159 | {
|
6160 |
|
6161 | var knownKeys = null;
|
6162 |
|
6163 | for (var i = 0; i < newChildren.length; i++) {
|
6164 | var child = newChildren[i];
|
6165 | knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
|
6166 | }
|
6167 | }
|
6168 |
|
6169 | var resultingFirstChild = null;
|
6170 | var previousNewFiber = null;
|
6171 | var oldFiber = currentFirstChild;
|
6172 | var lastPlacedIndex = 0;
|
6173 | var newIdx = 0;
|
6174 | var nextOldFiber = null;
|
6175 |
|
6176 | for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
|
6177 | if (oldFiber.index > newIdx) {
|
6178 | nextOldFiber = oldFiber;
|
6179 | oldFiber = null;
|
6180 | } else {
|
6181 | nextOldFiber = oldFiber.sibling;
|
6182 | }
|
6183 |
|
6184 | var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);
|
6185 |
|
6186 | if (newFiber === null) {
|
6187 |
|
6188 |
|
6189 |
|
6190 |
|
6191 | if (oldFiber === null) {
|
6192 | oldFiber = nextOldFiber;
|
6193 | }
|
6194 |
|
6195 | break;
|
6196 | }
|
6197 |
|
6198 | if (shouldTrackSideEffects) {
|
6199 | if (oldFiber && newFiber.alternate === null) {
|
6200 |
|
6201 |
|
6202 | deleteChild(returnFiber, oldFiber);
|
6203 | }
|
6204 | }
|
6205 |
|
6206 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
6207 |
|
6208 | if (previousNewFiber === null) {
|
6209 |
|
6210 | resultingFirstChild = newFiber;
|
6211 | } else {
|
6212 |
|
6213 |
|
6214 |
|
6215 |
|
6216 | previousNewFiber.sibling = newFiber;
|
6217 | }
|
6218 |
|
6219 | previousNewFiber = newFiber;
|
6220 | oldFiber = nextOldFiber;
|
6221 | }
|
6222 |
|
6223 | if (newIdx === newChildren.length) {
|
6224 |
|
6225 | deleteRemainingChildren(returnFiber, oldFiber);
|
6226 |
|
6227 | return resultingFirstChild;
|
6228 | }
|
6229 |
|
6230 | if (oldFiber === null) {
|
6231 |
|
6232 |
|
6233 | for (; newIdx < newChildren.length; newIdx++) {
|
6234 | var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);
|
6235 |
|
6236 | if (_newFiber === null) {
|
6237 | continue;
|
6238 | }
|
6239 |
|
6240 | lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
|
6241 |
|
6242 | if (previousNewFiber === null) {
|
6243 |
|
6244 | resultingFirstChild = _newFiber;
|
6245 | } else {
|
6246 | previousNewFiber.sibling = _newFiber;
|
6247 | }
|
6248 |
|
6249 | previousNewFiber = _newFiber;
|
6250 | }
|
6251 |
|
6252 | return resultingFirstChild;
|
6253 | }
|
6254 |
|
6255 |
|
6256 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
6257 |
|
6258 | for (; newIdx < newChildren.length; newIdx++) {
|
6259 | var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);
|
6260 |
|
6261 | if (_newFiber2 !== null) {
|
6262 | if (shouldTrackSideEffects) {
|
6263 | if (_newFiber2.alternate !== null) {
|
6264 |
|
6265 |
|
6266 |
|
6267 |
|
6268 | existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
|
6269 | }
|
6270 | }
|
6271 |
|
6272 | lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
|
6273 |
|
6274 | if (previousNewFiber === null) {
|
6275 | resultingFirstChild = _newFiber2;
|
6276 | } else {
|
6277 | previousNewFiber.sibling = _newFiber2;
|
6278 | }
|
6279 |
|
6280 | previousNewFiber = _newFiber2;
|
6281 | }
|
6282 | }
|
6283 |
|
6284 | if (shouldTrackSideEffects) {
|
6285 |
|
6286 |
|
6287 | existingChildren.forEach(function (child) {
|
6288 | return deleteChild(returnFiber, child);
|
6289 | });
|
6290 | }
|
6291 |
|
6292 | return resultingFirstChild;
|
6293 | }
|
6294 |
|
6295 | function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {
|
6296 |
|
6297 |
|
6298 | var iteratorFn = getIteratorFn(newChildrenIterable);
|
6299 |
|
6300 | if (typeof iteratorFn !== 'function') {
|
6301 | throw new Error('An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.');
|
6302 | }
|
6303 |
|
6304 | {
|
6305 |
|
6306 |
|
6307 | if (typeof Symbol === 'function' &&
|
6308 | newChildrenIterable[Symbol.toStringTag] === 'Generator') {
|
6309 | if (!didWarnAboutGenerators) {
|
6310 | error('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.');
|
6311 | }
|
6312 |
|
6313 | didWarnAboutGenerators = true;
|
6314 | }
|
6315 |
|
6316 |
|
6317 | if (newChildrenIterable.entries === iteratorFn) {
|
6318 | if (!didWarnAboutMaps) {
|
6319 | error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
|
6320 | }
|
6321 |
|
6322 | didWarnAboutMaps = true;
|
6323 | }
|
6324 |
|
6325 |
|
6326 |
|
6327 | var _newChildren = iteratorFn.call(newChildrenIterable);
|
6328 |
|
6329 | if (_newChildren) {
|
6330 | var knownKeys = null;
|
6331 |
|
6332 | var _step = _newChildren.next();
|
6333 |
|
6334 | for (; !_step.done; _step = _newChildren.next()) {
|
6335 | var child = _step.value;
|
6336 | knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
|
6337 | }
|
6338 | }
|
6339 | }
|
6340 |
|
6341 | var newChildren = iteratorFn.call(newChildrenIterable);
|
6342 |
|
6343 | if (newChildren == null) {
|
6344 | throw new Error('An iterable object provided no iterator.');
|
6345 | }
|
6346 |
|
6347 | var resultingFirstChild = null;
|
6348 | var previousNewFiber = null;
|
6349 | var oldFiber = currentFirstChild;
|
6350 | var lastPlacedIndex = 0;
|
6351 | var newIdx = 0;
|
6352 | var nextOldFiber = null;
|
6353 | var step = newChildren.next();
|
6354 |
|
6355 | for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
|
6356 | if (oldFiber.index > newIdx) {
|
6357 | nextOldFiber = oldFiber;
|
6358 | oldFiber = null;
|
6359 | } else {
|
6360 | nextOldFiber = oldFiber.sibling;
|
6361 | }
|
6362 |
|
6363 | var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
|
6364 |
|
6365 | if (newFiber === null) {
|
6366 |
|
6367 |
|
6368 |
|
6369 |
|
6370 | if (oldFiber === null) {
|
6371 | oldFiber = nextOldFiber;
|
6372 | }
|
6373 |
|
6374 | break;
|
6375 | }
|
6376 |
|
6377 | if (shouldTrackSideEffects) {
|
6378 | if (oldFiber && newFiber.alternate === null) {
|
6379 |
|
6380 |
|
6381 | deleteChild(returnFiber, oldFiber);
|
6382 | }
|
6383 | }
|
6384 |
|
6385 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
6386 |
|
6387 | if (previousNewFiber === null) {
|
6388 |
|
6389 | resultingFirstChild = newFiber;
|
6390 | } else {
|
6391 |
|
6392 |
|
6393 |
|
6394 |
|
6395 | previousNewFiber.sibling = newFiber;
|
6396 | }
|
6397 |
|
6398 | previousNewFiber = newFiber;
|
6399 | oldFiber = nextOldFiber;
|
6400 | }
|
6401 |
|
6402 | if (step.done) {
|
6403 |
|
6404 | deleteRemainingChildren(returnFiber, oldFiber);
|
6405 |
|
6406 | return resultingFirstChild;
|
6407 | }
|
6408 |
|
6409 | if (oldFiber === null) {
|
6410 |
|
6411 |
|
6412 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
6413 | var _newFiber3 = createChild(returnFiber, step.value, lanes);
|
6414 |
|
6415 | if (_newFiber3 === null) {
|
6416 | continue;
|
6417 | }
|
6418 |
|
6419 | lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
|
6420 |
|
6421 | if (previousNewFiber === null) {
|
6422 |
|
6423 | resultingFirstChild = _newFiber3;
|
6424 | } else {
|
6425 | previousNewFiber.sibling = _newFiber3;
|
6426 | }
|
6427 |
|
6428 | previousNewFiber = _newFiber3;
|
6429 | }
|
6430 |
|
6431 | return resultingFirstChild;
|
6432 | }
|
6433 |
|
6434 |
|
6435 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
6436 |
|
6437 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
6438 | var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);
|
6439 |
|
6440 | if (_newFiber4 !== null) {
|
6441 | if (shouldTrackSideEffects) {
|
6442 | if (_newFiber4.alternate !== null) {
|
6443 |
|
6444 |
|
6445 |
|
6446 |
|
6447 | existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
|
6448 | }
|
6449 | }
|
6450 |
|
6451 | lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
|
6452 |
|
6453 | if (previousNewFiber === null) {
|
6454 | resultingFirstChild = _newFiber4;
|
6455 | } else {
|
6456 | previousNewFiber.sibling = _newFiber4;
|
6457 | }
|
6458 |
|
6459 | previousNewFiber = _newFiber4;
|
6460 | }
|
6461 | }
|
6462 |
|
6463 | if (shouldTrackSideEffects) {
|
6464 |
|
6465 |
|
6466 | existingChildren.forEach(function (child) {
|
6467 | return deleteChild(returnFiber, child);
|
6468 | });
|
6469 | }
|
6470 |
|
6471 | return resultingFirstChild;
|
6472 | }
|
6473 |
|
6474 | function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {
|
6475 |
|
6476 |
|
6477 | if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
|
6478 |
|
6479 |
|
6480 | deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
|
6481 | var existing = useFiber(currentFirstChild, textContent);
|
6482 | existing.return = returnFiber;
|
6483 | return existing;
|
6484 | }
|
6485 |
|
6486 |
|
6487 |
|
6488 | deleteRemainingChildren(returnFiber, currentFirstChild);
|
6489 | var created = createFiberFromText(textContent, returnFiber.mode, lanes);
|
6490 | created.return = returnFiber;
|
6491 | return created;
|
6492 | }
|
6493 |
|
6494 | function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {
|
6495 | var key = element.key;
|
6496 | var child = currentFirstChild;
|
6497 |
|
6498 | while (child !== null) {
|
6499 |
|
6500 |
|
6501 | if (child.key === key) {
|
6502 | var elementType = element.type;
|
6503 |
|
6504 | if (elementType === REACT_FRAGMENT_TYPE) {
|
6505 | if (child.tag === Fragment) {
|
6506 | deleteRemainingChildren(returnFiber, child.sibling);
|
6507 | var existing = useFiber(child, element.props.children);
|
6508 | existing.return = returnFiber;
|
6509 |
|
6510 | {
|
6511 | existing._debugSource = element._source;
|
6512 | existing._debugOwner = element._owner;
|
6513 | }
|
6514 |
|
6515 | return existing;
|
6516 | }
|
6517 | } else {
|
6518 | if (child.elementType === elementType || (
|
6519 | isCompatibleFamilyForHotReloading(child, element) ) ||
|
6520 |
|
6521 |
|
6522 |
|
6523 | typeof elementType === 'object' && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === child.type) {
|
6524 | deleteRemainingChildren(returnFiber, child.sibling);
|
6525 |
|
6526 | var _existing = useFiber(child, element.props);
|
6527 |
|
6528 | _existing.ref = coerceRef(returnFiber, child, element);
|
6529 | _existing.return = returnFiber;
|
6530 |
|
6531 | {
|
6532 | _existing._debugSource = element._source;
|
6533 | _existing._debugOwner = element._owner;
|
6534 | }
|
6535 |
|
6536 | return _existing;
|
6537 | }
|
6538 | }
|
6539 |
|
6540 |
|
6541 | deleteRemainingChildren(returnFiber, child);
|
6542 | break;
|
6543 | } else {
|
6544 | deleteChild(returnFiber, child);
|
6545 | }
|
6546 |
|
6547 | child = child.sibling;
|
6548 | }
|
6549 |
|
6550 | if (element.type === REACT_FRAGMENT_TYPE) {
|
6551 | var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);
|
6552 | created.return = returnFiber;
|
6553 | return created;
|
6554 | } else {
|
6555 | var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);
|
6556 |
|
6557 | _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
|
6558 | _created4.return = returnFiber;
|
6559 | return _created4;
|
6560 | }
|
6561 | }
|
6562 |
|
6563 | function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {
|
6564 | var key = portal.key;
|
6565 | var child = currentFirstChild;
|
6566 |
|
6567 | while (child !== null) {
|
6568 |
|
6569 |
|
6570 | if (child.key === key) {
|
6571 | if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
|
6572 | deleteRemainingChildren(returnFiber, child.sibling);
|
6573 | var existing = useFiber(child, portal.children || []);
|
6574 | existing.return = returnFiber;
|
6575 | return existing;
|
6576 | } else {
|
6577 | deleteRemainingChildren(returnFiber, child);
|
6578 | break;
|
6579 | }
|
6580 | } else {
|
6581 | deleteChild(returnFiber, child);
|
6582 | }
|
6583 |
|
6584 | child = child.sibling;
|
6585 | }
|
6586 |
|
6587 | var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
|
6588 | created.return = returnFiber;
|
6589 | return created;
|
6590 | }
|
6591 |
|
6592 |
|
6593 |
|
6594 |
|
6595 | function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {
|
6596 |
|
6597 |
|
6598 |
|
6599 |
|
6600 |
|
6601 |
|
6602 |
|
6603 | var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
6604 |
|
6605 | if (isUnkeyedTopLevelFragment) {
|
6606 | newChild = newChild.props.children;
|
6607 | }
|
6608 |
|
6609 |
|
6610 | if (typeof newChild === 'object' && newChild !== null) {
|
6611 | switch (newChild.$$typeof) {
|
6612 | case REACT_ELEMENT_TYPE:
|
6613 | return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));
|
6614 |
|
6615 | case REACT_PORTAL_TYPE:
|
6616 | return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));
|
6617 |
|
6618 | case REACT_LAZY_TYPE:
|
6619 | {
|
6620 | var payload = newChild._payload;
|
6621 | var init = newChild._init;
|
6622 |
|
6623 | return reconcileChildFibers(returnFiber, currentFirstChild, init(payload), lanes);
|
6624 | }
|
6625 |
|
6626 | }
|
6627 |
|
6628 | if (isArray(newChild)) {
|
6629 | return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);
|
6630 | }
|
6631 |
|
6632 | if (getIteratorFn(newChild)) {
|
6633 | return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);
|
6634 | }
|
6635 |
|
6636 | throwOnInvalidObjectType(returnFiber, newChild);
|
6637 | }
|
6638 |
|
6639 | if (typeof newChild === 'string' && newChild !== '' || typeof newChild === 'number') {
|
6640 | return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));
|
6641 | }
|
6642 |
|
6643 | {
|
6644 | if (typeof newChild === 'function') {
|
6645 | warnOnFunctionType(returnFiber);
|
6646 | }
|
6647 | }
|
6648 |
|
6649 |
|
6650 | return deleteRemainingChildren(returnFiber, currentFirstChild);
|
6651 | }
|
6652 |
|
6653 | return reconcileChildFibers;
|
6654 | }
|
6655 |
|
6656 | var reconcileChildFibers = ChildReconciler(true);
|
6657 | var mountChildFibers = ChildReconciler(false);
|
6658 | function cloneChildFibers(current, workInProgress) {
|
6659 | if (current !== null && workInProgress.child !== current.child) {
|
6660 | throw new Error('Resuming work not yet implemented.');
|
6661 | }
|
6662 |
|
6663 | if (workInProgress.child === null) {
|
6664 | return;
|
6665 | }
|
6666 |
|
6667 | var currentChild = workInProgress.child;
|
6668 | var newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
|
6669 | workInProgress.child = newChild;
|
6670 | newChild.return = workInProgress;
|
6671 |
|
6672 | while (currentChild.sibling !== null) {
|
6673 | currentChild = currentChild.sibling;
|
6674 | newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps);
|
6675 | newChild.return = workInProgress;
|
6676 | }
|
6677 |
|
6678 | newChild.sibling = null;
|
6679 | }
|
6680 |
|
6681 | function resetChildFibers(workInProgress, lanes) {
|
6682 | var child = workInProgress.child;
|
6683 |
|
6684 | while (child !== null) {
|
6685 | resetWorkInProgress(child, lanes);
|
6686 | child = child.sibling;
|
6687 | }
|
6688 | }
|
6689 |
|
6690 | var NO_CONTEXT$1 = {};
|
6691 | var contextStackCursor$1 = createCursor(NO_CONTEXT$1);
|
6692 | var contextFiberStackCursor = createCursor(NO_CONTEXT$1);
|
6693 | var rootInstanceStackCursor = createCursor(NO_CONTEXT$1);
|
6694 |
|
6695 | function requiredContext(c) {
|
6696 | if (c === NO_CONTEXT$1) {
|
6697 | throw new Error('Expected host context to exist. This error is likely caused by a bug ' + 'in React. Please file an issue.');
|
6698 | }
|
6699 |
|
6700 | return c;
|
6701 | }
|
6702 |
|
6703 | function getRootHostContainer() {
|
6704 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
6705 | return rootInstance;
|
6706 | }
|
6707 |
|
6708 | function pushHostContainer(fiber, nextRootInstance) {
|
6709 |
|
6710 |
|
6711 | push(rootInstanceStackCursor, nextRootInstance, fiber);
|
6712 |
|
6713 |
|
6714 | push(contextFiberStackCursor, fiber, fiber);
|
6715 |
|
6716 |
|
6717 |
|
6718 |
|
6719 |
|
6720 | push(contextStackCursor$1, NO_CONTEXT$1, fiber);
|
6721 | var nextRootContext = getRootHostContext();
|
6722 |
|
6723 | pop(contextStackCursor$1, fiber);
|
6724 | push(contextStackCursor$1, nextRootContext, fiber);
|
6725 | }
|
6726 |
|
6727 | function popHostContainer(fiber) {
|
6728 | pop(contextStackCursor$1, fiber);
|
6729 | pop(contextFiberStackCursor, fiber);
|
6730 | pop(rootInstanceStackCursor, fiber);
|
6731 | }
|
6732 |
|
6733 | function getHostContext() {
|
6734 | var context = requiredContext(contextStackCursor$1.current);
|
6735 | return context;
|
6736 | }
|
6737 |
|
6738 | function pushHostContext(fiber) {
|
6739 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
6740 | var context = requiredContext(contextStackCursor$1.current);
|
6741 | var nextContext = getChildHostContext(context, fiber.type);
|
6742 |
|
6743 | if (context === nextContext) {
|
6744 | return;
|
6745 | }
|
6746 |
|
6747 |
|
6748 |
|
6749 | push(contextFiberStackCursor, fiber, fiber);
|
6750 | push(contextStackCursor$1, nextContext, fiber);
|
6751 | }
|
6752 |
|
6753 | function popHostContext(fiber) {
|
6754 |
|
6755 |
|
6756 | if (contextFiberStackCursor.current !== fiber) {
|
6757 | return;
|
6758 | }
|
6759 |
|
6760 | pop(contextStackCursor$1, fiber);
|
6761 | pop(contextFiberStackCursor, fiber);
|
6762 | }
|
6763 |
|
6764 | var DefaultSuspenseContext = 0;
|
6765 |
|
6766 |
|
6767 |
|
6768 |
|
6769 | var SubtreeSuspenseContextMask = 1;
|
6770 |
|
6771 |
|
6772 |
|
6773 |
|
6774 |
|
6775 |
|
6776 |
|
6777 | var InvisibleParentSuspenseContext = 1;
|
6778 |
|
6779 |
|
6780 |
|
6781 | var ForceSuspenseFallback = 2;
|
6782 | var suspenseStackCursor = createCursor(DefaultSuspenseContext);
|
6783 | function hasSuspenseContext(parentContext, flag) {
|
6784 | return (parentContext & flag) !== 0;
|
6785 | }
|
6786 | function setDefaultShallowSuspenseContext(parentContext) {
|
6787 | return parentContext & SubtreeSuspenseContextMask;
|
6788 | }
|
6789 | function setShallowSuspenseContext(parentContext, shallowContext) {
|
6790 | return parentContext & SubtreeSuspenseContextMask | shallowContext;
|
6791 | }
|
6792 | function addSubtreeSuspenseContext(parentContext, subtreeContext) {
|
6793 | return parentContext | subtreeContext;
|
6794 | }
|
6795 | function pushSuspenseContext(fiber, newContext) {
|
6796 | push(suspenseStackCursor, newContext, fiber);
|
6797 | }
|
6798 | function popSuspenseContext(fiber) {
|
6799 | pop(suspenseStackCursor, fiber);
|
6800 | }
|
6801 |
|
6802 | function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
|
6803 |
|
6804 |
|
6805 | var nextState = workInProgress.memoizedState;
|
6806 |
|
6807 | if (nextState !== null) {
|
6808 | if (nextState.dehydrated !== null) {
|
6809 |
|
6810 | return true;
|
6811 | }
|
6812 |
|
6813 | return false;
|
6814 | }
|
6815 |
|
6816 | var props = workInProgress.memoizedProps;
|
6817 |
|
6818 | {
|
6819 | return true;
|
6820 | }
|
6821 | }
|
6822 | function findFirstSuspended(row) {
|
6823 | var node = row;
|
6824 |
|
6825 | while (node !== null) {
|
6826 | if (node.tag === SuspenseComponent) {
|
6827 | var state = node.memoizedState;
|
6828 |
|
6829 | if (state !== null) {
|
6830 | var dehydrated = state.dehydrated;
|
6831 |
|
6832 | if (dehydrated === null || isSuspenseInstancePending() || isSuspenseInstanceFallback()) {
|
6833 | return node;
|
6834 | }
|
6835 | }
|
6836 | } else if (node.tag === SuspenseListComponent &&
|
6837 |
|
6838 | node.memoizedProps.revealOrder !== undefined) {
|
6839 | var didSuspend = (node.flags & DidCapture) !== NoFlags;
|
6840 |
|
6841 | if (didSuspend) {
|
6842 | return node;
|
6843 | }
|
6844 | } else if (node.child !== null) {
|
6845 | node.child.return = node;
|
6846 | node = node.child;
|
6847 | continue;
|
6848 | }
|
6849 |
|
6850 | if (node === row) {
|
6851 | return null;
|
6852 | }
|
6853 |
|
6854 | while (node.sibling === null) {
|
6855 | if (node.return === null || node.return === row) {
|
6856 | return null;
|
6857 | }
|
6858 |
|
6859 | node = node.return;
|
6860 | }
|
6861 |
|
6862 | node.sibling.return = node.return;
|
6863 | node = node.sibling;
|
6864 | }
|
6865 |
|
6866 | return null;
|
6867 | }
|
6868 |
|
6869 | var NoFlags$1 =
|
6870 |
|
6871 | 0;
|
6872 |
|
6873 | var HasEffect =
|
6874 |
|
6875 | 1;
|
6876 |
|
6877 | var Insertion =
|
6878 |
|
6879 | 2;
|
6880 | var Layout =
|
6881 |
|
6882 | 4;
|
6883 | var Passive$1 =
|
6884 |
|
6885 | 8;
|
6886 |
|
6887 |
|
6888 |
|
6889 |
|
6890 | var workInProgressSources = [];
|
6891 | function resetWorkInProgressVersions() {
|
6892 | for (var i = 0; i < workInProgressSources.length; i++) {
|
6893 | var mutableSource = workInProgressSources[i];
|
6894 |
|
6895 | {
|
6896 | mutableSource._workInProgressVersionSecondary = null;
|
6897 | }
|
6898 | }
|
6899 |
|
6900 | workInProgressSources.length = 0;
|
6901 | }
|
6902 |
|
6903 | var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
|
6904 | ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
|
6905 | var didWarnAboutMismatchedHooksForComponent;
|
6906 | var didWarnUncachedGetSnapshot;
|
6907 |
|
6908 | {
|
6909 | didWarnAboutMismatchedHooksForComponent = new Set();
|
6910 | }
|
6911 |
|
6912 |
|
6913 | var renderLanes = NoLanes;
|
6914 |
|
6915 |
|
6916 | var currentlyRenderingFiber$1 = null;
|
6917 |
|
6918 |
|
6919 |
|
6920 |
|
6921 | var currentHook = null;
|
6922 | var workInProgressHook = null;
|
6923 |
|
6924 |
|
6925 |
|
6926 |
|
6927 | var didScheduleRenderPhaseUpdate = false;
|
6928 |
|
6929 |
|
6930 |
|
6931 |
|
6932 | var didScheduleRenderPhaseUpdateDuringThisPass = false;
|
6933 |
|
6934 | var localIdCounter = 0;
|
6935 |
|
6936 |
|
6937 |
|
6938 | var globalClientIdCounter = 0;
|
6939 | var RE_RENDER_LIMIT = 25;
|
6940 |
|
6941 | var currentHookNameInDev = null;
|
6942 |
|
6943 |
|
6944 |
|
6945 | var hookTypesDev = null;
|
6946 | var hookTypesUpdateIndexDev = -1;
|
6947 |
|
6948 |
|
6949 |
|
6950 | var ignorePreviousDependencies = false;
|
6951 |
|
6952 | function mountHookTypesDev() {
|
6953 | {
|
6954 | var hookName = currentHookNameInDev;
|
6955 |
|
6956 | if (hookTypesDev === null) {
|
6957 | hookTypesDev = [hookName];
|
6958 | } else {
|
6959 | hookTypesDev.push(hookName);
|
6960 | }
|
6961 | }
|
6962 | }
|
6963 |
|
6964 | function updateHookTypesDev() {
|
6965 | {
|
6966 | var hookName = currentHookNameInDev;
|
6967 |
|
6968 | if (hookTypesDev !== null) {
|
6969 | hookTypesUpdateIndexDev++;
|
6970 |
|
6971 | if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
|
6972 | warnOnHookMismatchInDev(hookName);
|
6973 | }
|
6974 | }
|
6975 | }
|
6976 | }
|
6977 |
|
6978 | function checkDepsAreArrayDev(deps) {
|
6979 | {
|
6980 | if (deps !== undefined && deps !== null && !isArray(deps)) {
|
6981 |
|
6982 |
|
6983 | error('%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);
|
6984 | }
|
6985 | }
|
6986 | }
|
6987 |
|
6988 | function warnOnHookMismatchInDev(currentHookName) {
|
6989 | {
|
6990 | var componentName = getComponentNameFromFiber(currentlyRenderingFiber$1);
|
6991 |
|
6992 | if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
|
6993 | didWarnAboutMismatchedHooksForComponent.add(componentName);
|
6994 |
|
6995 | if (hookTypesDev !== null) {
|
6996 | var table = '';
|
6997 | var secondColumnStart = 30;
|
6998 |
|
6999 | for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
|
7000 | var oldHookName = hookTypesDev[i];
|
7001 | var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
|
7002 | var row = i + 1 + ". " + oldHookName;
|
7003 |
|
7004 |
|
7005 | while (row.length < secondColumnStart) {
|
7006 | row += ' ';
|
7007 | }
|
7008 |
|
7009 | row += newHookName + '\n';
|
7010 | table += row;
|
7011 | }
|
7012 |
|
7013 | error('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://reactjs.org/link/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
|
7014 | }
|
7015 | }
|
7016 | }
|
7017 | }
|
7018 |
|
7019 | function throwInvalidHookError() {
|
7020 | throw new 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:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');
|
7021 | }
|
7022 |
|
7023 | function areHookInputsEqual(nextDeps, prevDeps) {
|
7024 | {
|
7025 | if (ignorePreviousDependencies) {
|
7026 |
|
7027 | return false;
|
7028 | }
|
7029 | }
|
7030 |
|
7031 | if (prevDeps === null) {
|
7032 | {
|
7033 | error('%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);
|
7034 | }
|
7035 |
|
7036 | return false;
|
7037 | }
|
7038 |
|
7039 | {
|
7040 |
|
7041 |
|
7042 | if (nextDeps.length !== prevDeps.length) {
|
7043 | error('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(', ') + "]");
|
7044 | }
|
7045 | }
|
7046 |
|
7047 | for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
7048 | if (objectIs(nextDeps[i], prevDeps[i])) {
|
7049 | continue;
|
7050 | }
|
7051 |
|
7052 | return false;
|
7053 | }
|
7054 |
|
7055 | return true;
|
7056 | }
|
7057 |
|
7058 | function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderLanes) {
|
7059 | renderLanes = nextRenderLanes;
|
7060 | currentlyRenderingFiber$1 = workInProgress;
|
7061 |
|
7062 | {
|
7063 | hookTypesDev = current !== null ? current._debugHookTypes : null;
|
7064 | hookTypesUpdateIndexDev = -1;
|
7065 |
|
7066 | ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
|
7067 | }
|
7068 |
|
7069 | workInProgress.memoizedState = null;
|
7070 | workInProgress.updateQueue = null;
|
7071 | workInProgress.lanes = NoLanes;
|
7072 |
|
7073 |
|
7074 |
|
7075 |
|
7076 |
|
7077 |
|
7078 |
|
7079 |
|
7080 |
|
7081 |
|
7082 |
|
7083 | {
|
7084 | if (current !== null && current.memoizedState !== null) {
|
7085 | ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
7086 | } else if (hookTypesDev !== null) {
|
7087 |
|
7088 |
|
7089 |
|
7090 |
|
7091 |
|
7092 | ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
|
7093 | } else {
|
7094 | ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
|
7095 | }
|
7096 | }
|
7097 |
|
7098 | var children = Component(props, secondArg);
|
7099 |
|
7100 | if (didScheduleRenderPhaseUpdateDuringThisPass) {
|
7101 |
|
7102 |
|
7103 | var numberOfReRenders = 0;
|
7104 |
|
7105 | do {
|
7106 | didScheduleRenderPhaseUpdateDuringThisPass = false;
|
7107 | localIdCounter = 0;
|
7108 |
|
7109 | if (numberOfReRenders >= RE_RENDER_LIMIT) {
|
7110 | throw new Error('Too many re-renders. React limits the number of renders to prevent ' + 'an infinite loop.');
|
7111 | }
|
7112 |
|
7113 | numberOfReRenders += 1;
|
7114 |
|
7115 | {
|
7116 |
|
7117 |
|
7118 | ignorePreviousDependencies = false;
|
7119 | }
|
7120 |
|
7121 |
|
7122 | currentHook = null;
|
7123 | workInProgressHook = null;
|
7124 | workInProgress.updateQueue = null;
|
7125 |
|
7126 | {
|
7127 |
|
7128 | hookTypesUpdateIndexDev = -1;
|
7129 | }
|
7130 |
|
7131 | ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV ;
|
7132 | children = Component(props, secondArg);
|
7133 | } while (didScheduleRenderPhaseUpdateDuringThisPass);
|
7134 | }
|
7135 |
|
7136 |
|
7137 |
|
7138 | ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
7139 |
|
7140 | {
|
7141 | workInProgress._debugHookTypes = hookTypesDev;
|
7142 | }
|
7143 |
|
7144 |
|
7145 |
|
7146 | var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
|
7147 | renderLanes = NoLanes;
|
7148 | currentlyRenderingFiber$1 = null;
|
7149 | currentHook = null;
|
7150 | workInProgressHook = null;
|
7151 |
|
7152 | {
|
7153 | currentHookNameInDev = null;
|
7154 | hookTypesDev = null;
|
7155 | hookTypesUpdateIndexDev = -1;
|
7156 |
|
7157 |
|
7158 |
|
7159 |
|
7160 | if (current !== null && (current.flags & StaticMask) !== (workInProgress.flags & StaticMask) &&
|
7161 |
|
7162 |
|
7163 |
|
7164 |
|
7165 | (current.mode & ConcurrentMode) !== NoMode) {
|
7166 | error('Internal React error: Expected static flag was missing. Please ' + 'notify the React team.');
|
7167 | }
|
7168 | }
|
7169 |
|
7170 | didScheduleRenderPhaseUpdate = false;
|
7171 |
|
7172 |
|
7173 | if (didRenderTooFewHooks) {
|
7174 | throw new Error('Rendered fewer hooks than expected. This may be caused by an accidental ' + 'early return statement.');
|
7175 | }
|
7176 |
|
7177 | return children;
|
7178 | }
|
7179 | function checkDidRenderIdHook() {
|
7180 |
|
7181 |
|
7182 |
|
7183 | var didRenderIdHook = localIdCounter !== 0;
|
7184 | localIdCounter = 0;
|
7185 | return didRenderIdHook;
|
7186 | }
|
7187 | function bailoutHooks(current, workInProgress, lanes) {
|
7188 | workInProgress.updateQueue = current.updateQueue;
|
7189 |
|
7190 |
|
7191 | if ( (workInProgress.mode & StrictEffectsMode) !== NoMode) {
|
7192 | workInProgress.flags &= ~(MountPassiveDev | MountLayoutDev | Passive | Update);
|
7193 | } else {
|
7194 | workInProgress.flags &= ~(Passive | Update);
|
7195 | }
|
7196 |
|
7197 | current.lanes = removeLanes(current.lanes, lanes);
|
7198 | }
|
7199 | function resetHooksAfterThrow() {
|
7200 |
|
7201 |
|
7202 | ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
7203 |
|
7204 | if (didScheduleRenderPhaseUpdate) {
|
7205 |
|
7206 |
|
7207 |
|
7208 |
|
7209 |
|
7210 |
|
7211 |
|
7212 |
|
7213 | var hook = currentlyRenderingFiber$1.memoizedState;
|
7214 |
|
7215 | while (hook !== null) {
|
7216 | var queue = hook.queue;
|
7217 |
|
7218 | if (queue !== null) {
|
7219 | queue.pending = null;
|
7220 | }
|
7221 |
|
7222 | hook = hook.next;
|
7223 | }
|
7224 |
|
7225 | didScheduleRenderPhaseUpdate = false;
|
7226 | }
|
7227 |
|
7228 | renderLanes = NoLanes;
|
7229 | currentlyRenderingFiber$1 = null;
|
7230 | currentHook = null;
|
7231 | workInProgressHook = null;
|
7232 |
|
7233 | {
|
7234 | hookTypesDev = null;
|
7235 | hookTypesUpdateIndexDev = -1;
|
7236 | currentHookNameInDev = null;
|
7237 | isUpdatingOpaqueValueInRenderPhase = false;
|
7238 | }
|
7239 |
|
7240 | didScheduleRenderPhaseUpdateDuringThisPass = false;
|
7241 | localIdCounter = 0;
|
7242 | }
|
7243 |
|
7244 | function mountWorkInProgressHook() {
|
7245 | var hook = {
|
7246 | memoizedState: null,
|
7247 | baseState: null,
|
7248 | baseQueue: null,
|
7249 | queue: null,
|
7250 | next: null
|
7251 | };
|
7252 |
|
7253 | if (workInProgressHook === null) {
|
7254 |
|
7255 | currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook;
|
7256 | } else {
|
7257 |
|
7258 | workInProgressHook = workInProgressHook.next = hook;
|
7259 | }
|
7260 |
|
7261 | return workInProgressHook;
|
7262 | }
|
7263 |
|
7264 | function updateWorkInProgressHook() {
|
7265 |
|
7266 |
|
7267 |
|
7268 |
|
7269 |
|
7270 | var nextCurrentHook;
|
7271 |
|
7272 | if (currentHook === null) {
|
7273 | var current = currentlyRenderingFiber$1.alternate;
|
7274 |
|
7275 | if (current !== null) {
|
7276 | nextCurrentHook = current.memoizedState;
|
7277 | } else {
|
7278 | nextCurrentHook = null;
|
7279 | }
|
7280 | } else {
|
7281 | nextCurrentHook = currentHook.next;
|
7282 | }
|
7283 |
|
7284 | var nextWorkInProgressHook;
|
7285 |
|
7286 | if (workInProgressHook === null) {
|
7287 | nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState;
|
7288 | } else {
|
7289 | nextWorkInProgressHook = workInProgressHook.next;
|
7290 | }
|
7291 |
|
7292 | if (nextWorkInProgressHook !== null) {
|
7293 |
|
7294 | workInProgressHook = nextWorkInProgressHook;
|
7295 | nextWorkInProgressHook = workInProgressHook.next;
|
7296 | currentHook = nextCurrentHook;
|
7297 | } else {
|
7298 |
|
7299 | if (nextCurrentHook === null) {
|
7300 | throw new Error('Rendered more hooks than during the previous render.');
|
7301 | }
|
7302 |
|
7303 | currentHook = nextCurrentHook;
|
7304 | var newHook = {
|
7305 | memoizedState: currentHook.memoizedState,
|
7306 | baseState: currentHook.baseState,
|
7307 | baseQueue: currentHook.baseQueue,
|
7308 | queue: currentHook.queue,
|
7309 | next: null
|
7310 | };
|
7311 |
|
7312 | if (workInProgressHook === null) {
|
7313 |
|
7314 | currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook;
|
7315 | } else {
|
7316 |
|
7317 | workInProgressHook = workInProgressHook.next = newHook;
|
7318 | }
|
7319 | }
|
7320 |
|
7321 | return workInProgressHook;
|
7322 | }
|
7323 |
|
7324 | function createFunctionComponentUpdateQueue() {
|
7325 | return {
|
7326 | lastEffect: null,
|
7327 | stores: null
|
7328 | };
|
7329 | }
|
7330 |
|
7331 | function basicStateReducer(state, action) {
|
7332 |
|
7333 | return typeof action === 'function' ? action(state) : action;
|
7334 | }
|
7335 |
|
7336 | function mountReducer(reducer, initialArg, init) {
|
7337 | var hook = mountWorkInProgressHook();
|
7338 | var initialState;
|
7339 |
|
7340 | if (init !== undefined) {
|
7341 | initialState = init(initialArg);
|
7342 | } else {
|
7343 | initialState = initialArg;
|
7344 | }
|
7345 |
|
7346 | hook.memoizedState = hook.baseState = initialState;
|
7347 | var queue = {
|
7348 | pending: null,
|
7349 | interleaved: null,
|
7350 | lanes: NoLanes,
|
7351 | dispatch: null,
|
7352 | lastRenderedReducer: reducer,
|
7353 | lastRenderedState: initialState
|
7354 | };
|
7355 | hook.queue = queue;
|
7356 | var dispatch = queue.dispatch = dispatchReducerAction.bind(null, currentlyRenderingFiber$1, queue);
|
7357 | return [hook.memoizedState, dispatch];
|
7358 | }
|
7359 |
|
7360 | function updateReducer(reducer, initialArg, init) {
|
7361 | var hook = updateWorkInProgressHook();
|
7362 | var queue = hook.queue;
|
7363 |
|
7364 | if (queue === null) {
|
7365 | throw new Error('Should have a queue. This is likely a bug in React. Please file an issue.');
|
7366 | }
|
7367 |
|
7368 | queue.lastRenderedReducer = reducer;
|
7369 | var current = currentHook;
|
7370 |
|
7371 | var baseQueue = current.baseQueue;
|
7372 |
|
7373 | var pendingQueue = queue.pending;
|
7374 |
|
7375 | if (pendingQueue !== null) {
|
7376 |
|
7377 |
|
7378 | if (baseQueue !== null) {
|
7379 |
|
7380 | var baseFirst = baseQueue.next;
|
7381 | var pendingFirst = pendingQueue.next;
|
7382 | baseQueue.next = pendingFirst;
|
7383 | pendingQueue.next = baseFirst;
|
7384 | }
|
7385 |
|
7386 | {
|
7387 | if (current.baseQueue !== baseQueue) {
|
7388 |
|
7389 |
|
7390 | error('Internal error: Expected work-in-progress queue to be a clone. ' + 'This is a bug in React.');
|
7391 | }
|
7392 | }
|
7393 |
|
7394 | current.baseQueue = baseQueue = pendingQueue;
|
7395 | queue.pending = null;
|
7396 | }
|
7397 |
|
7398 | if (baseQueue !== null) {
|
7399 |
|
7400 | var first = baseQueue.next;
|
7401 | var newState = current.baseState;
|
7402 | var newBaseState = null;
|
7403 | var newBaseQueueFirst = null;
|
7404 | var newBaseQueueLast = null;
|
7405 | var update = first;
|
7406 |
|
7407 | do {
|
7408 | var updateLane = update.lane;
|
7409 |
|
7410 | if (!isSubsetOfLanes(renderLanes, updateLane)) {
|
7411 |
|
7412 |
|
7413 |
|
7414 | var clone = {
|
7415 | lane: updateLane,
|
7416 | action: update.action,
|
7417 | hasEagerState: update.hasEagerState,
|
7418 | eagerState: update.eagerState,
|
7419 | next: null
|
7420 | };
|
7421 |
|
7422 | if (newBaseQueueLast === null) {
|
7423 | newBaseQueueFirst = newBaseQueueLast = clone;
|
7424 | newBaseState = newState;
|
7425 | } else {
|
7426 | newBaseQueueLast = newBaseQueueLast.next = clone;
|
7427 | }
|
7428 |
|
7429 |
|
7430 |
|
7431 |
|
7432 | currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, updateLane);
|
7433 | markSkippedUpdateLanes(updateLane);
|
7434 | } else {
|
7435 |
|
7436 | if (newBaseQueueLast !== null) {
|
7437 | var _clone = {
|
7438 |
|
7439 |
|
7440 |
|
7441 | lane: NoLane,
|
7442 | action: update.action,
|
7443 | hasEagerState: update.hasEagerState,
|
7444 | eagerState: update.eagerState,
|
7445 | next: null
|
7446 | };
|
7447 | newBaseQueueLast = newBaseQueueLast.next = _clone;
|
7448 | }
|
7449 |
|
7450 |
|
7451 | if (update.hasEagerState) {
|
7452 |
|
7453 |
|
7454 | newState = update.eagerState;
|
7455 | } else {
|
7456 | var action = update.action;
|
7457 | newState = reducer(newState, action);
|
7458 | }
|
7459 | }
|
7460 |
|
7461 | update = update.next;
|
7462 | } while (update !== null && update !== first);
|
7463 |
|
7464 | if (newBaseQueueLast === null) {
|
7465 | newBaseState = newState;
|
7466 | } else {
|
7467 | newBaseQueueLast.next = newBaseQueueFirst;
|
7468 | }
|
7469 |
|
7470 |
|
7471 |
|
7472 | if (!objectIs(newState, hook.memoizedState)) {
|
7473 | markWorkInProgressReceivedUpdate();
|
7474 | }
|
7475 |
|
7476 | hook.memoizedState = newState;
|
7477 | hook.baseState = newBaseState;
|
7478 | hook.baseQueue = newBaseQueueLast;
|
7479 | queue.lastRenderedState = newState;
|
7480 | }
|
7481 |
|
7482 |
|
7483 |
|
7484 |
|
7485 | var lastInterleaved = queue.interleaved;
|
7486 |
|
7487 | if (lastInterleaved !== null) {
|
7488 | var interleaved = lastInterleaved;
|
7489 |
|
7490 | do {
|
7491 | var interleavedLane = interleaved.lane;
|
7492 | currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, interleavedLane);
|
7493 | markSkippedUpdateLanes(interleavedLane);
|
7494 | interleaved = interleaved.next;
|
7495 | } while (interleaved !== lastInterleaved);
|
7496 | } else if (baseQueue === null) {
|
7497 |
|
7498 |
|
7499 | queue.lanes = NoLanes;
|
7500 | }
|
7501 |
|
7502 | var dispatch = queue.dispatch;
|
7503 | return [hook.memoizedState, dispatch];
|
7504 | }
|
7505 |
|
7506 | function rerenderReducer(reducer, initialArg, init) {
|
7507 | var hook = updateWorkInProgressHook();
|
7508 | var queue = hook.queue;
|
7509 |
|
7510 | if (queue === null) {
|
7511 | throw new Error('Should have a queue. This is likely a bug in React. Please file an issue.');
|
7512 | }
|
7513 |
|
7514 | queue.lastRenderedReducer = reducer;
|
7515 |
|
7516 |
|
7517 | var dispatch = queue.dispatch;
|
7518 | var lastRenderPhaseUpdate = queue.pending;
|
7519 | var newState = hook.memoizedState;
|
7520 |
|
7521 | if (lastRenderPhaseUpdate !== null) {
|
7522 |
|
7523 | queue.pending = null;
|
7524 | var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
7525 | var update = firstRenderPhaseUpdate;
|
7526 |
|
7527 | do {
|
7528 |
|
7529 |
|
7530 |
|
7531 | var action = update.action;
|
7532 | newState = reducer(newState, action);
|
7533 | update = update.next;
|
7534 | } while (update !== firstRenderPhaseUpdate);
|
7535 |
|
7536 |
|
7537 |
|
7538 | if (!objectIs(newState, hook.memoizedState)) {
|
7539 | markWorkInProgressReceivedUpdate();
|
7540 | }
|
7541 |
|
7542 | hook.memoizedState = newState;
|
7543 |
|
7544 |
|
7545 |
|
7546 |
|
7547 | if (hook.baseQueue === null) {
|
7548 | hook.baseState = newState;
|
7549 | }
|
7550 |
|
7551 | queue.lastRenderedState = newState;
|
7552 | }
|
7553 |
|
7554 | return [newState, dispatch];
|
7555 | }
|
7556 |
|
7557 | function mountMutableSource(source, getSnapshot, subscribe) {
|
7558 | {
|
7559 | return undefined;
|
7560 | }
|
7561 | }
|
7562 |
|
7563 | function updateMutableSource(source, getSnapshot, subscribe) {
|
7564 | {
|
7565 | return undefined;
|
7566 | }
|
7567 | }
|
7568 |
|
7569 | function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
7570 | var fiber = currentlyRenderingFiber$1;
|
7571 | var hook = mountWorkInProgressHook();
|
7572 | var nextSnapshot;
|
7573 |
|
7574 | {
|
7575 | nextSnapshot = getSnapshot();
|
7576 |
|
7577 | {
|
7578 | if (!didWarnUncachedGetSnapshot) {
|
7579 | var cachedSnapshot = getSnapshot();
|
7580 |
|
7581 | if (!objectIs(nextSnapshot, cachedSnapshot)) {
|
7582 | error('The result of getSnapshot should be cached to avoid an infinite loop');
|
7583 |
|
7584 | didWarnUncachedGetSnapshot = true;
|
7585 | }
|
7586 | }
|
7587 | }
|
7588 |
|
7589 |
|
7590 |
|
7591 |
|
7592 |
|
7593 |
|
7594 |
|
7595 |
|
7596 | var root = getWorkInProgressRoot();
|
7597 |
|
7598 | if (root === null) {
|
7599 | throw new Error('Expected a work-in-progress root. This is a bug in React. Please file an issue.');
|
7600 | }
|
7601 |
|
7602 | if (!includesBlockingLane(root, renderLanes)) {
|
7603 | pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
|
7604 | }
|
7605 | }
|
7606 |
|
7607 |
|
7608 |
|
7609 |
|
7610 | hook.memoizedState = nextSnapshot;
|
7611 | var inst = {
|
7612 | value: nextSnapshot,
|
7613 | getSnapshot: getSnapshot
|
7614 | };
|
7615 | hook.queue = inst;
|
7616 |
|
7617 | mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]);
|
7618 |
|
7619 |
|
7620 |
|
7621 |
|
7622 |
|
7623 |
|
7624 |
|
7625 | fiber.flags |= Passive;
|
7626 | pushEffect(HasEffect | Passive$1, updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), undefined, null);
|
7627 | return nextSnapshot;
|
7628 | }
|
7629 |
|
7630 | function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
7631 | var fiber = currentlyRenderingFiber$1;
|
7632 | var hook = updateWorkInProgressHook();
|
7633 |
|
7634 |
|
7635 |
|
7636 | var nextSnapshot = getSnapshot();
|
7637 |
|
7638 | {
|
7639 | if (!didWarnUncachedGetSnapshot) {
|
7640 | var cachedSnapshot = getSnapshot();
|
7641 |
|
7642 | if (!objectIs(nextSnapshot, cachedSnapshot)) {
|
7643 | error('The result of getSnapshot should be cached to avoid an infinite loop');
|
7644 |
|
7645 | didWarnUncachedGetSnapshot = true;
|
7646 | }
|
7647 | }
|
7648 | }
|
7649 |
|
7650 | var prevSnapshot = hook.memoizedState;
|
7651 | var snapshotChanged = !objectIs(prevSnapshot, nextSnapshot);
|
7652 |
|
7653 | if (snapshotChanged) {
|
7654 | hook.memoizedState = nextSnapshot;
|
7655 | markWorkInProgressReceivedUpdate();
|
7656 | }
|
7657 |
|
7658 | var inst = hook.queue;
|
7659 | updateEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]);
|
7660 |
|
7661 |
|
7662 |
|
7663 |
|
7664 | if (inst.getSnapshot !== getSnapshot || snapshotChanged ||
|
7665 |
|
7666 | workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) {
|
7667 | fiber.flags |= Passive;
|
7668 | pushEffect(HasEffect | Passive$1, updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), undefined, null);
|
7669 |
|
7670 |
|
7671 |
|
7672 | var root = getWorkInProgressRoot();
|
7673 |
|
7674 | if (root === null) {
|
7675 | throw new Error('Expected a work-in-progress root. This is a bug in React. Please file an issue.');
|
7676 | }
|
7677 |
|
7678 | if (!includesBlockingLane(root, renderLanes)) {
|
7679 | pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
|
7680 | }
|
7681 | }
|
7682 |
|
7683 | return nextSnapshot;
|
7684 | }
|
7685 |
|
7686 | function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
|
7687 | fiber.flags |= StoreConsistency;
|
7688 | var check = {
|
7689 | getSnapshot: getSnapshot,
|
7690 | value: renderedSnapshot
|
7691 | };
|
7692 | var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
|
7693 |
|
7694 | if (componentUpdateQueue === null) {
|
7695 | componentUpdateQueue = createFunctionComponentUpdateQueue();
|
7696 | currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
|
7697 | componentUpdateQueue.stores = [check];
|
7698 | } else {
|
7699 | var stores = componentUpdateQueue.stores;
|
7700 |
|
7701 | if (stores === null) {
|
7702 | componentUpdateQueue.stores = [check];
|
7703 | } else {
|
7704 | stores.push(check);
|
7705 | }
|
7706 | }
|
7707 | }
|
7708 |
|
7709 | function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
|
7710 |
|
7711 | inst.value = nextSnapshot;
|
7712 | inst.getSnapshot = getSnapshot;
|
7713 |
|
7714 |
|
7715 |
|
7716 |
|
7717 | if (checkIfSnapshotChanged(inst)) {
|
7718 |
|
7719 | forceStoreRerender(fiber);
|
7720 | }
|
7721 | }
|
7722 |
|
7723 | function subscribeToStore(fiber, inst, subscribe) {
|
7724 | var handleStoreChange = function () {
|
7725 |
|
7726 |
|
7727 | if (checkIfSnapshotChanged(inst)) {
|
7728 |
|
7729 | forceStoreRerender(fiber);
|
7730 | }
|
7731 | };
|
7732 |
|
7733 |
|
7734 | return subscribe(handleStoreChange);
|
7735 | }
|
7736 |
|
7737 | function checkIfSnapshotChanged(inst) {
|
7738 | var latestGetSnapshot = inst.getSnapshot;
|
7739 | var prevValue = inst.value;
|
7740 |
|
7741 | try {
|
7742 | var nextValue = latestGetSnapshot();
|
7743 | return !objectIs(prevValue, nextValue);
|
7744 | } catch (error) {
|
7745 | return true;
|
7746 | }
|
7747 | }
|
7748 |
|
7749 | function forceStoreRerender(fiber) {
|
7750 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
7751 | }
|
7752 |
|
7753 | function mountState(initialState) {
|
7754 | var hook = mountWorkInProgressHook();
|
7755 |
|
7756 | if (typeof initialState === 'function') {
|
7757 |
|
7758 | initialState = initialState();
|
7759 | }
|
7760 |
|
7761 | hook.memoizedState = hook.baseState = initialState;
|
7762 | var queue = {
|
7763 | pending: null,
|
7764 | interleaved: null,
|
7765 | lanes: NoLanes,
|
7766 | dispatch: null,
|
7767 | lastRenderedReducer: basicStateReducer,
|
7768 | lastRenderedState: initialState
|
7769 | };
|
7770 | hook.queue = queue;
|
7771 | var dispatch = queue.dispatch = dispatchSetState.bind(null, currentlyRenderingFiber$1, queue);
|
7772 | return [hook.memoizedState, dispatch];
|
7773 | }
|
7774 |
|
7775 | function updateState(initialState) {
|
7776 | return updateReducer(basicStateReducer);
|
7777 | }
|
7778 |
|
7779 | function rerenderState(initialState) {
|
7780 | return rerenderReducer(basicStateReducer);
|
7781 | }
|
7782 |
|
7783 | function pushEffect(tag, create, destroy, deps) {
|
7784 | var effect = {
|
7785 | tag: tag,
|
7786 | create: create,
|
7787 | destroy: destroy,
|
7788 | deps: deps,
|
7789 |
|
7790 | next: null
|
7791 | };
|
7792 | var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
|
7793 |
|
7794 | if (componentUpdateQueue === null) {
|
7795 | componentUpdateQueue = createFunctionComponentUpdateQueue();
|
7796 | currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
|
7797 | componentUpdateQueue.lastEffect = effect.next = effect;
|
7798 | } else {
|
7799 | var lastEffect = componentUpdateQueue.lastEffect;
|
7800 |
|
7801 | if (lastEffect === null) {
|
7802 | componentUpdateQueue.lastEffect = effect.next = effect;
|
7803 | } else {
|
7804 | var firstEffect = lastEffect.next;
|
7805 | lastEffect.next = effect;
|
7806 | effect.next = firstEffect;
|
7807 | componentUpdateQueue.lastEffect = effect;
|
7808 | }
|
7809 | }
|
7810 |
|
7811 | return effect;
|
7812 | }
|
7813 |
|
7814 | function mountRef(initialValue) {
|
7815 | var hook = mountWorkInProgressHook();
|
7816 |
|
7817 | {
|
7818 | var _ref2 = {
|
7819 | current: initialValue
|
7820 | };
|
7821 | hook.memoizedState = _ref2;
|
7822 | return _ref2;
|
7823 | }
|
7824 | }
|
7825 |
|
7826 | function updateRef(initialValue) {
|
7827 | var hook = updateWorkInProgressHook();
|
7828 | return hook.memoizedState;
|
7829 | }
|
7830 |
|
7831 | function mountEffectImpl(fiberFlags, hookFlags, create, deps) {
|
7832 | var hook = mountWorkInProgressHook();
|
7833 | var nextDeps = deps === undefined ? null : deps;
|
7834 | currentlyRenderingFiber$1.flags |= fiberFlags;
|
7835 | hook.memoizedState = pushEffect(HasEffect | hookFlags, create, undefined, nextDeps);
|
7836 | }
|
7837 |
|
7838 | function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
|
7839 | var hook = updateWorkInProgressHook();
|
7840 | var nextDeps = deps === undefined ? null : deps;
|
7841 | var destroy = undefined;
|
7842 |
|
7843 | if (currentHook !== null) {
|
7844 | var prevEffect = currentHook.memoizedState;
|
7845 | destroy = prevEffect.destroy;
|
7846 |
|
7847 | if (nextDeps !== null) {
|
7848 | var prevDeps = prevEffect.deps;
|
7849 |
|
7850 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
7851 | hook.memoizedState = pushEffect(hookFlags, create, destroy, nextDeps);
|
7852 | return;
|
7853 | }
|
7854 | }
|
7855 | }
|
7856 |
|
7857 | currentlyRenderingFiber$1.flags |= fiberFlags;
|
7858 | hook.memoizedState = pushEffect(HasEffect | hookFlags, create, destroy, nextDeps);
|
7859 | }
|
7860 |
|
7861 | function mountEffect(create, deps) {
|
7862 | if ( (currentlyRenderingFiber$1.mode & StrictEffectsMode) !== NoMode) {
|
7863 | return mountEffectImpl(MountPassiveDev | Passive | PassiveStatic, Passive$1, create, deps);
|
7864 | } else {
|
7865 | return mountEffectImpl(Passive | PassiveStatic, Passive$1, create, deps);
|
7866 | }
|
7867 | }
|
7868 |
|
7869 | function updateEffect(create, deps) {
|
7870 | return updateEffectImpl(Passive, Passive$1, create, deps);
|
7871 | }
|
7872 |
|
7873 | function mountInsertionEffect(create, deps) {
|
7874 | return mountEffectImpl(Update, Insertion, create, deps);
|
7875 | }
|
7876 |
|
7877 | function updateInsertionEffect(create, deps) {
|
7878 | return updateEffectImpl(Update, Insertion, create, deps);
|
7879 | }
|
7880 |
|
7881 | function mountLayoutEffect(create, deps) {
|
7882 | var fiberFlags = Update;
|
7883 |
|
7884 | {
|
7885 | fiberFlags |= LayoutStatic;
|
7886 | }
|
7887 |
|
7888 | if ( (currentlyRenderingFiber$1.mode & StrictEffectsMode) !== NoMode) {
|
7889 | fiberFlags |= MountLayoutDev;
|
7890 | }
|
7891 |
|
7892 | return mountEffectImpl(fiberFlags, Layout, create, deps);
|
7893 | }
|
7894 |
|
7895 | function updateLayoutEffect(create, deps) {
|
7896 | return updateEffectImpl(Update, Layout, create, deps);
|
7897 | }
|
7898 |
|
7899 | function imperativeHandleEffect(create, ref) {
|
7900 | if (typeof ref === 'function') {
|
7901 | var refCallback = ref;
|
7902 |
|
7903 | var _inst = create();
|
7904 |
|
7905 | refCallback(_inst);
|
7906 | return function () {
|
7907 | refCallback(null);
|
7908 | };
|
7909 | } else if (ref !== null && ref !== undefined) {
|
7910 | var refObject = ref;
|
7911 |
|
7912 | {
|
7913 | if (!refObject.hasOwnProperty('current')) {
|
7914 | error('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(', ') + '}');
|
7915 | }
|
7916 | }
|
7917 |
|
7918 | var _inst2 = create();
|
7919 |
|
7920 | refObject.current = _inst2;
|
7921 | return function () {
|
7922 | refObject.current = null;
|
7923 | };
|
7924 | }
|
7925 | }
|
7926 |
|
7927 | function mountImperativeHandle(ref, create, deps) {
|
7928 | {
|
7929 | if (typeof create !== 'function') {
|
7930 | error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
|
7931 | }
|
7932 | }
|
7933 |
|
7934 |
|
7935 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
7936 | var fiberFlags = Update;
|
7937 |
|
7938 | {
|
7939 | fiberFlags |= LayoutStatic;
|
7940 | }
|
7941 |
|
7942 | if ( (currentlyRenderingFiber$1.mode & StrictEffectsMode) !== NoMode) {
|
7943 | fiberFlags |= MountLayoutDev;
|
7944 | }
|
7945 |
|
7946 | return mountEffectImpl(fiberFlags, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
7947 | }
|
7948 |
|
7949 | function updateImperativeHandle(ref, create, deps) {
|
7950 | {
|
7951 | if (typeof create !== 'function') {
|
7952 | error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
|
7953 | }
|
7954 | }
|
7955 |
|
7956 |
|
7957 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
7958 | return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
7959 | }
|
7960 |
|
7961 | function mountDebugValue(value, formatterFn) {
|
7962 |
|
7963 |
|
7964 | }
|
7965 |
|
7966 | var updateDebugValue = mountDebugValue;
|
7967 |
|
7968 | function mountCallback(callback, deps) {
|
7969 | var hook = mountWorkInProgressHook();
|
7970 | var nextDeps = deps === undefined ? null : deps;
|
7971 | hook.memoizedState = [callback, nextDeps];
|
7972 | return callback;
|
7973 | }
|
7974 |
|
7975 | function updateCallback(callback, deps) {
|
7976 | var hook = updateWorkInProgressHook();
|
7977 | var nextDeps = deps === undefined ? null : deps;
|
7978 | var prevState = hook.memoizedState;
|
7979 |
|
7980 | if (prevState !== null) {
|
7981 | if (nextDeps !== null) {
|
7982 | var prevDeps = prevState[1];
|
7983 |
|
7984 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
7985 | return prevState[0];
|
7986 | }
|
7987 | }
|
7988 | }
|
7989 |
|
7990 | hook.memoizedState = [callback, nextDeps];
|
7991 | return callback;
|
7992 | }
|
7993 |
|
7994 | function mountMemo(nextCreate, deps) {
|
7995 | var hook = mountWorkInProgressHook();
|
7996 | var nextDeps = deps === undefined ? null : deps;
|
7997 | var nextValue = nextCreate();
|
7998 | hook.memoizedState = [nextValue, nextDeps];
|
7999 | return nextValue;
|
8000 | }
|
8001 |
|
8002 | function updateMemo(nextCreate, deps) {
|
8003 | var hook = updateWorkInProgressHook();
|
8004 | var nextDeps = deps === undefined ? null : deps;
|
8005 | var prevState = hook.memoizedState;
|
8006 |
|
8007 | if (prevState !== null) {
|
8008 |
|
8009 | if (nextDeps !== null) {
|
8010 | var prevDeps = prevState[1];
|
8011 |
|
8012 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
8013 | return prevState[0];
|
8014 | }
|
8015 | }
|
8016 | }
|
8017 |
|
8018 | var nextValue = nextCreate();
|
8019 | hook.memoizedState = [nextValue, nextDeps];
|
8020 | return nextValue;
|
8021 | }
|
8022 |
|
8023 | function mountDeferredValue(value) {
|
8024 | var _mountState = mountState(value),
|
8025 | prevValue = _mountState[0],
|
8026 | setValue = _mountState[1];
|
8027 |
|
8028 | mountEffect(function () {
|
8029 | var prevTransition = ReactCurrentBatchConfig$1.transition;
|
8030 | ReactCurrentBatchConfig$1.transition = {};
|
8031 |
|
8032 | try {
|
8033 | setValue(value);
|
8034 | } finally {
|
8035 | ReactCurrentBatchConfig$1.transition = prevTransition;
|
8036 | }
|
8037 | }, [value]);
|
8038 | return prevValue;
|
8039 | }
|
8040 |
|
8041 | function updateDeferredValue(value) {
|
8042 | var _updateState = updateState(),
|
8043 | prevValue = _updateState[0],
|
8044 | setValue = _updateState[1];
|
8045 |
|
8046 | updateEffect(function () {
|
8047 | var prevTransition = ReactCurrentBatchConfig$1.transition;
|
8048 | ReactCurrentBatchConfig$1.transition = {};
|
8049 |
|
8050 | try {
|
8051 | setValue(value);
|
8052 | } finally {
|
8053 | ReactCurrentBatchConfig$1.transition = prevTransition;
|
8054 | }
|
8055 | }, [value]);
|
8056 | return prevValue;
|
8057 | }
|
8058 |
|
8059 | function rerenderDeferredValue(value) {
|
8060 | var _rerenderState = rerenderState(),
|
8061 | prevValue = _rerenderState[0],
|
8062 | setValue = _rerenderState[1];
|
8063 |
|
8064 | updateEffect(function () {
|
8065 | var prevTransition = ReactCurrentBatchConfig$1.transition;
|
8066 | ReactCurrentBatchConfig$1.transition = {};
|
8067 |
|
8068 | try {
|
8069 | setValue(value);
|
8070 | } finally {
|
8071 | ReactCurrentBatchConfig$1.transition = prevTransition;
|
8072 | }
|
8073 | }, [value]);
|
8074 | return prevValue;
|
8075 | }
|
8076 |
|
8077 | function startTransition(setPending, callback, options) {
|
8078 | var previousPriority = getCurrentUpdatePriority();
|
8079 | setCurrentUpdatePriority(higherEventPriority(previousPriority, ContinuousEventPriority));
|
8080 | setPending(true);
|
8081 | var prevTransition = ReactCurrentBatchConfig$1.transition;
|
8082 | ReactCurrentBatchConfig$1.transition = {};
|
8083 | var currentTransition = ReactCurrentBatchConfig$1.transition;
|
8084 |
|
8085 | {
|
8086 | ReactCurrentBatchConfig$1.transition._updatedFibers = new Set();
|
8087 | }
|
8088 |
|
8089 | try {
|
8090 | setPending(false);
|
8091 | callback();
|
8092 | } finally {
|
8093 | setCurrentUpdatePriority(previousPriority);
|
8094 | ReactCurrentBatchConfig$1.transition = prevTransition;
|
8095 |
|
8096 | {
|
8097 | if (prevTransition === null && currentTransition._updatedFibers) {
|
8098 | var updatedFibersCount = currentTransition._updatedFibers.size;
|
8099 |
|
8100 | if (updatedFibersCount > 10) {
|
8101 | warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');
|
8102 | }
|
8103 |
|
8104 | currentTransition._updatedFibers.clear();
|
8105 | }
|
8106 | }
|
8107 | }
|
8108 | }
|
8109 |
|
8110 | function mountTransition() {
|
8111 | var _mountState2 = mountState(false),
|
8112 | isPending = _mountState2[0],
|
8113 | setPending = _mountState2[1];
|
8114 |
|
8115 |
|
8116 | var start = startTransition.bind(null, setPending);
|
8117 | var hook = mountWorkInProgressHook();
|
8118 | hook.memoizedState = start;
|
8119 | return [isPending, start];
|
8120 | }
|
8121 |
|
8122 | function updateTransition() {
|
8123 | var _updateState2 = updateState(),
|
8124 | isPending = _updateState2[0];
|
8125 |
|
8126 | var hook = updateWorkInProgressHook();
|
8127 | var start = hook.memoizedState;
|
8128 | return [isPending, start];
|
8129 | }
|
8130 |
|
8131 | function rerenderTransition() {
|
8132 | var _rerenderState2 = rerenderState(),
|
8133 | isPending = _rerenderState2[0];
|
8134 |
|
8135 | var hook = updateWorkInProgressHook();
|
8136 | var start = hook.memoizedState;
|
8137 | return [isPending, start];
|
8138 | }
|
8139 |
|
8140 | var isUpdatingOpaqueValueInRenderPhase = false;
|
8141 | function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
|
8142 | {
|
8143 | return isUpdatingOpaqueValueInRenderPhase;
|
8144 | }
|
8145 | }
|
8146 |
|
8147 | function mountId() {
|
8148 | var hook = mountWorkInProgressHook();
|
8149 | var root = getWorkInProgressRoot();
|
8150 |
|
8151 |
|
8152 |
|
8153 |
|
8154 |
|
8155 | var identifierPrefix = root.identifierPrefix;
|
8156 | var id;
|
8157 |
|
8158 | {
|
8159 |
|
8160 | var globalClientId = globalClientIdCounter++;
|
8161 | id = ':' + identifierPrefix + 'r' + globalClientId.toString(32) + ':';
|
8162 | }
|
8163 |
|
8164 | hook.memoizedState = id;
|
8165 | return id;
|
8166 | }
|
8167 |
|
8168 | function updateId() {
|
8169 | var hook = updateWorkInProgressHook();
|
8170 | var id = hook.memoizedState;
|
8171 | return id;
|
8172 | }
|
8173 |
|
8174 | function dispatchReducerAction(fiber, queue, action) {
|
8175 | {
|
8176 | if (typeof arguments[3] === 'function') {
|
8177 | error("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().');
|
8178 | }
|
8179 | }
|
8180 |
|
8181 | var lane = requestUpdateLane(fiber);
|
8182 | var update = {
|
8183 | lane: lane,
|
8184 | action: action,
|
8185 | hasEagerState: false,
|
8186 | eagerState: null,
|
8187 | next: null
|
8188 | };
|
8189 |
|
8190 | if (isRenderPhaseUpdate(fiber)) {
|
8191 | enqueueRenderPhaseUpdate(queue, update);
|
8192 | } else {
|
8193 | enqueueUpdate$1(fiber, queue, update);
|
8194 | var eventTime = requestEventTime();
|
8195 | var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
|
8196 |
|
8197 | if (root !== null) {
|
8198 | entangleTransitionUpdate(root, queue, lane);
|
8199 | }
|
8200 | }
|
8201 |
|
8202 | markUpdateInDevTools(fiber, lane);
|
8203 | }
|
8204 |
|
8205 | function dispatchSetState(fiber, queue, action) {
|
8206 | {
|
8207 | if (typeof arguments[3] === 'function') {
|
8208 | error("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().');
|
8209 | }
|
8210 | }
|
8211 |
|
8212 | var lane = requestUpdateLane(fiber);
|
8213 | var update = {
|
8214 | lane: lane,
|
8215 | action: action,
|
8216 | hasEagerState: false,
|
8217 | eagerState: null,
|
8218 | next: null
|
8219 | };
|
8220 |
|
8221 | if (isRenderPhaseUpdate(fiber)) {
|
8222 | enqueueRenderPhaseUpdate(queue, update);
|
8223 | } else {
|
8224 | enqueueUpdate$1(fiber, queue, update);
|
8225 | var alternate = fiber.alternate;
|
8226 |
|
8227 | if (fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes)) {
|
8228 |
|
8229 |
|
8230 |
|
8231 | var lastRenderedReducer = queue.lastRenderedReducer;
|
8232 |
|
8233 | if (lastRenderedReducer !== null) {
|
8234 | var prevDispatcher;
|
8235 |
|
8236 | {
|
8237 | prevDispatcher = ReactCurrentDispatcher$1.current;
|
8238 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
8239 | }
|
8240 |
|
8241 | try {
|
8242 | var currentState = queue.lastRenderedState;
|
8243 | var eagerState = lastRenderedReducer(currentState, action);
|
8244 |
|
8245 |
|
8246 |
|
8247 |
|
8248 | update.hasEagerState = true;
|
8249 | update.eagerState = eagerState;
|
8250 |
|
8251 | if (objectIs(eagerState, currentState)) {
|
8252 |
|
8253 |
|
8254 |
|
8255 |
|
8256 | return;
|
8257 | }
|
8258 | } catch (error) {
|
8259 | } finally {
|
8260 | {
|
8261 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8262 | }
|
8263 | }
|
8264 | }
|
8265 | }
|
8266 |
|
8267 | var eventTime = requestEventTime();
|
8268 | var root = scheduleUpdateOnFiber(fiber, lane, eventTime);
|
8269 |
|
8270 | if (root !== null) {
|
8271 | entangleTransitionUpdate(root, queue, lane);
|
8272 | }
|
8273 | }
|
8274 |
|
8275 | markUpdateInDevTools(fiber, lane);
|
8276 | }
|
8277 |
|
8278 | function isRenderPhaseUpdate(fiber) {
|
8279 | var alternate = fiber.alternate;
|
8280 | return fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1;
|
8281 | }
|
8282 |
|
8283 | function enqueueRenderPhaseUpdate(queue, update) {
|
8284 |
|
8285 |
|
8286 |
|
8287 | didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
|
8288 | var pending = queue.pending;
|
8289 |
|
8290 | if (pending === null) {
|
8291 |
|
8292 | update.next = update;
|
8293 | } else {
|
8294 | update.next = pending.next;
|
8295 | pending.next = update;
|
8296 | }
|
8297 |
|
8298 | queue.pending = update;
|
8299 | }
|
8300 |
|
8301 | function enqueueUpdate$1(fiber, queue, update, lane) {
|
8302 | if (isInterleavedUpdate(fiber)) {
|
8303 | var interleaved = queue.interleaved;
|
8304 |
|
8305 | if (interleaved === null) {
|
8306 |
|
8307 | update.next = update;
|
8308 |
|
8309 |
|
8310 | pushInterleavedQueue(queue);
|
8311 | } else {
|
8312 | update.next = interleaved.next;
|
8313 | interleaved.next = update;
|
8314 | }
|
8315 |
|
8316 | queue.interleaved = update;
|
8317 | } else {
|
8318 | var pending = queue.pending;
|
8319 |
|
8320 | if (pending === null) {
|
8321 |
|
8322 | update.next = update;
|
8323 | } else {
|
8324 | update.next = pending.next;
|
8325 | pending.next = update;
|
8326 | }
|
8327 |
|
8328 | queue.pending = update;
|
8329 | }
|
8330 | }
|
8331 |
|
8332 | function entangleTransitionUpdate(root, queue, lane) {
|
8333 | if (isTransitionLane(lane)) {
|
8334 | var queueLanes = queue.lanes;
|
8335 |
|
8336 |
|
8337 |
|
8338 |
|
8339 |
|
8340 | queueLanes = intersectLanes(queueLanes, root.pendingLanes);
|
8341 |
|
8342 | var newQueueLanes = mergeLanes(queueLanes, lane);
|
8343 | queue.lanes = newQueueLanes;
|
8344 |
|
8345 |
|
8346 |
|
8347 | markRootEntangled(root, newQueueLanes);
|
8348 | }
|
8349 | }
|
8350 |
|
8351 | function markUpdateInDevTools(fiber, lane, action) {
|
8352 |
|
8353 | {
|
8354 | markStateUpdateScheduled(fiber, lane);
|
8355 | }
|
8356 | }
|
8357 |
|
8358 | var ContextOnlyDispatcher = {
|
8359 | readContext: readContext,
|
8360 | useCallback: throwInvalidHookError,
|
8361 | useContext: throwInvalidHookError,
|
8362 | useEffect: throwInvalidHookError,
|
8363 | useImperativeHandle: throwInvalidHookError,
|
8364 | useInsertionEffect: throwInvalidHookError,
|
8365 | useLayoutEffect: throwInvalidHookError,
|
8366 | useMemo: throwInvalidHookError,
|
8367 | useReducer: throwInvalidHookError,
|
8368 | useRef: throwInvalidHookError,
|
8369 | useState: throwInvalidHookError,
|
8370 | useDebugValue: throwInvalidHookError,
|
8371 | useDeferredValue: throwInvalidHookError,
|
8372 | useTransition: throwInvalidHookError,
|
8373 | useMutableSource: throwInvalidHookError,
|
8374 | useSyncExternalStore: throwInvalidHookError,
|
8375 | useId: throwInvalidHookError,
|
8376 | unstable_isNewReconciler: enableNewReconciler
|
8377 | };
|
8378 |
|
8379 | var HooksDispatcherOnMountInDEV = null;
|
8380 | var HooksDispatcherOnMountWithHookTypesInDEV = null;
|
8381 | var HooksDispatcherOnUpdateInDEV = null;
|
8382 | var HooksDispatcherOnRerenderInDEV = null;
|
8383 | var InvalidNestedHooksDispatcherOnMountInDEV = null;
|
8384 | var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
8385 | var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
|
8386 |
|
8387 | {
|
8388 | var warnInvalidContextAccess = function () {
|
8389 | 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().');
|
8390 | };
|
8391 |
|
8392 | var warnInvalidHookAccess = function () {
|
8393 | error('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://reactjs.org/link/rules-of-hooks');
|
8394 | };
|
8395 |
|
8396 | HooksDispatcherOnMountInDEV = {
|
8397 | readContext: function (context) {
|
8398 | return readContext(context);
|
8399 | },
|
8400 | useCallback: function (callback, deps) {
|
8401 | currentHookNameInDev = 'useCallback';
|
8402 | mountHookTypesDev();
|
8403 | checkDepsAreArrayDev(deps);
|
8404 | return mountCallback(callback, deps);
|
8405 | },
|
8406 | useContext: function (context) {
|
8407 | currentHookNameInDev = 'useContext';
|
8408 | mountHookTypesDev();
|
8409 | return readContext(context);
|
8410 | },
|
8411 | useEffect: function (create, deps) {
|
8412 | currentHookNameInDev = 'useEffect';
|
8413 | mountHookTypesDev();
|
8414 | checkDepsAreArrayDev(deps);
|
8415 | return mountEffect(create, deps);
|
8416 | },
|
8417 | useImperativeHandle: function (ref, create, deps) {
|
8418 | currentHookNameInDev = 'useImperativeHandle';
|
8419 | mountHookTypesDev();
|
8420 | checkDepsAreArrayDev(deps);
|
8421 | return mountImperativeHandle(ref, create, deps);
|
8422 | },
|
8423 | useInsertionEffect: function (create, deps) {
|
8424 | currentHookNameInDev = 'useInsertionEffect';
|
8425 | mountHookTypesDev();
|
8426 | checkDepsAreArrayDev(deps);
|
8427 | return mountInsertionEffect(create, deps);
|
8428 | },
|
8429 | useLayoutEffect: function (create, deps) {
|
8430 | currentHookNameInDev = 'useLayoutEffect';
|
8431 | mountHookTypesDev();
|
8432 | checkDepsAreArrayDev(deps);
|
8433 | return mountLayoutEffect(create, deps);
|
8434 | },
|
8435 | useMemo: function (create, deps) {
|
8436 | currentHookNameInDev = 'useMemo';
|
8437 | mountHookTypesDev();
|
8438 | checkDepsAreArrayDev(deps);
|
8439 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8440 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8441 |
|
8442 | try {
|
8443 | return mountMemo(create, deps);
|
8444 | } finally {
|
8445 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8446 | }
|
8447 | },
|
8448 | useReducer: function (reducer, initialArg, init) {
|
8449 | currentHookNameInDev = 'useReducer';
|
8450 | mountHookTypesDev();
|
8451 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8452 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8453 |
|
8454 | try {
|
8455 | return mountReducer(reducer, initialArg, init);
|
8456 | } finally {
|
8457 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8458 | }
|
8459 | },
|
8460 | useRef: function (initialValue) {
|
8461 | currentHookNameInDev = 'useRef';
|
8462 | mountHookTypesDev();
|
8463 | return mountRef(initialValue);
|
8464 | },
|
8465 | useState: function (initialState) {
|
8466 | currentHookNameInDev = 'useState';
|
8467 | mountHookTypesDev();
|
8468 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8469 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8470 |
|
8471 | try {
|
8472 | return mountState(initialState);
|
8473 | } finally {
|
8474 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8475 | }
|
8476 | },
|
8477 | useDebugValue: function (value, formatterFn) {
|
8478 | currentHookNameInDev = 'useDebugValue';
|
8479 | mountHookTypesDev();
|
8480 | return mountDebugValue();
|
8481 | },
|
8482 | useDeferredValue: function (value) {
|
8483 | currentHookNameInDev = 'useDeferredValue';
|
8484 | mountHookTypesDev();
|
8485 | return mountDeferredValue(value);
|
8486 | },
|
8487 | useTransition: function () {
|
8488 | currentHookNameInDev = 'useTransition';
|
8489 | mountHookTypesDev();
|
8490 | return mountTransition();
|
8491 | },
|
8492 | useMutableSource: function (source, getSnapshot, subscribe) {
|
8493 | currentHookNameInDev = 'useMutableSource';
|
8494 | mountHookTypesDev();
|
8495 | return mountMutableSource();
|
8496 | },
|
8497 | useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
|
8498 | currentHookNameInDev = 'useSyncExternalStore';
|
8499 | mountHookTypesDev();
|
8500 | return mountSyncExternalStore(subscribe, getSnapshot);
|
8501 | },
|
8502 | useId: function () {
|
8503 | currentHookNameInDev = 'useId';
|
8504 | mountHookTypesDev();
|
8505 | return mountId();
|
8506 | },
|
8507 | unstable_isNewReconciler: enableNewReconciler
|
8508 | };
|
8509 |
|
8510 | HooksDispatcherOnMountWithHookTypesInDEV = {
|
8511 | readContext: function (context) {
|
8512 | return readContext(context);
|
8513 | },
|
8514 | useCallback: function (callback, deps) {
|
8515 | currentHookNameInDev = 'useCallback';
|
8516 | updateHookTypesDev();
|
8517 | return mountCallback(callback, deps);
|
8518 | },
|
8519 | useContext: function (context) {
|
8520 | currentHookNameInDev = 'useContext';
|
8521 | updateHookTypesDev();
|
8522 | return readContext(context);
|
8523 | },
|
8524 | useEffect: function (create, deps) {
|
8525 | currentHookNameInDev = 'useEffect';
|
8526 | updateHookTypesDev();
|
8527 | return mountEffect(create, deps);
|
8528 | },
|
8529 | useImperativeHandle: function (ref, create, deps) {
|
8530 | currentHookNameInDev = 'useImperativeHandle';
|
8531 | updateHookTypesDev();
|
8532 | return mountImperativeHandle(ref, create, deps);
|
8533 | },
|
8534 | useInsertionEffect: function (create, deps) {
|
8535 | currentHookNameInDev = 'useInsertionEffect';
|
8536 | updateHookTypesDev();
|
8537 | return mountInsertionEffect(create, deps);
|
8538 | },
|
8539 | useLayoutEffect: function (create, deps) {
|
8540 | currentHookNameInDev = 'useLayoutEffect';
|
8541 | updateHookTypesDev();
|
8542 | return mountLayoutEffect(create, deps);
|
8543 | },
|
8544 | useMemo: function (create, deps) {
|
8545 | currentHookNameInDev = 'useMemo';
|
8546 | updateHookTypesDev();
|
8547 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8548 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8549 |
|
8550 | try {
|
8551 | return mountMemo(create, deps);
|
8552 | } finally {
|
8553 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8554 | }
|
8555 | },
|
8556 | useReducer: function (reducer, initialArg, init) {
|
8557 | currentHookNameInDev = 'useReducer';
|
8558 | updateHookTypesDev();
|
8559 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8560 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8561 |
|
8562 | try {
|
8563 | return mountReducer(reducer, initialArg, init);
|
8564 | } finally {
|
8565 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8566 | }
|
8567 | },
|
8568 | useRef: function (initialValue) {
|
8569 | currentHookNameInDev = 'useRef';
|
8570 | updateHookTypesDev();
|
8571 | return mountRef(initialValue);
|
8572 | },
|
8573 | useState: function (initialState) {
|
8574 | currentHookNameInDev = 'useState';
|
8575 | updateHookTypesDev();
|
8576 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8577 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8578 |
|
8579 | try {
|
8580 | return mountState(initialState);
|
8581 | } finally {
|
8582 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8583 | }
|
8584 | },
|
8585 | useDebugValue: function (value, formatterFn) {
|
8586 | currentHookNameInDev = 'useDebugValue';
|
8587 | updateHookTypesDev();
|
8588 | return mountDebugValue();
|
8589 | },
|
8590 | useDeferredValue: function (value) {
|
8591 | currentHookNameInDev = 'useDeferredValue';
|
8592 | updateHookTypesDev();
|
8593 | return mountDeferredValue(value);
|
8594 | },
|
8595 | useTransition: function () {
|
8596 | currentHookNameInDev = 'useTransition';
|
8597 | updateHookTypesDev();
|
8598 | return mountTransition();
|
8599 | },
|
8600 | useMutableSource: function (source, getSnapshot, subscribe) {
|
8601 | currentHookNameInDev = 'useMutableSource';
|
8602 | updateHookTypesDev();
|
8603 | return mountMutableSource();
|
8604 | },
|
8605 | useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
|
8606 | currentHookNameInDev = 'useSyncExternalStore';
|
8607 | updateHookTypesDev();
|
8608 | return mountSyncExternalStore(subscribe, getSnapshot);
|
8609 | },
|
8610 | useId: function () {
|
8611 | currentHookNameInDev = 'useId';
|
8612 | updateHookTypesDev();
|
8613 | return mountId();
|
8614 | },
|
8615 | unstable_isNewReconciler: enableNewReconciler
|
8616 | };
|
8617 |
|
8618 | HooksDispatcherOnUpdateInDEV = {
|
8619 | readContext: function (context) {
|
8620 | return readContext(context);
|
8621 | },
|
8622 | useCallback: function (callback, deps) {
|
8623 | currentHookNameInDev = 'useCallback';
|
8624 | updateHookTypesDev();
|
8625 | return updateCallback(callback, deps);
|
8626 | },
|
8627 | useContext: function (context) {
|
8628 | currentHookNameInDev = 'useContext';
|
8629 | updateHookTypesDev();
|
8630 | return readContext(context);
|
8631 | },
|
8632 | useEffect: function (create, deps) {
|
8633 | currentHookNameInDev = 'useEffect';
|
8634 | updateHookTypesDev();
|
8635 | return updateEffect(create, deps);
|
8636 | },
|
8637 | useImperativeHandle: function (ref, create, deps) {
|
8638 | currentHookNameInDev = 'useImperativeHandle';
|
8639 | updateHookTypesDev();
|
8640 | return updateImperativeHandle(ref, create, deps);
|
8641 | },
|
8642 | useInsertionEffect: function (create, deps) {
|
8643 | currentHookNameInDev = 'useInsertionEffect';
|
8644 | updateHookTypesDev();
|
8645 | return updateInsertionEffect(create, deps);
|
8646 | },
|
8647 | useLayoutEffect: function (create, deps) {
|
8648 | currentHookNameInDev = 'useLayoutEffect';
|
8649 | updateHookTypesDev();
|
8650 | return updateLayoutEffect(create, deps);
|
8651 | },
|
8652 | useMemo: function (create, deps) {
|
8653 | currentHookNameInDev = 'useMemo';
|
8654 | updateHookTypesDev();
|
8655 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8656 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
8657 |
|
8658 | try {
|
8659 | return updateMemo(create, deps);
|
8660 | } finally {
|
8661 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8662 | }
|
8663 | },
|
8664 | useReducer: function (reducer, initialArg, init) {
|
8665 | currentHookNameInDev = 'useReducer';
|
8666 | updateHookTypesDev();
|
8667 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8668 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
8669 |
|
8670 | try {
|
8671 | return updateReducer(reducer, initialArg, init);
|
8672 | } finally {
|
8673 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8674 | }
|
8675 | },
|
8676 | useRef: function (initialValue) {
|
8677 | currentHookNameInDev = 'useRef';
|
8678 | updateHookTypesDev();
|
8679 | return updateRef();
|
8680 | },
|
8681 | useState: function (initialState) {
|
8682 | currentHookNameInDev = 'useState';
|
8683 | updateHookTypesDev();
|
8684 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8685 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
8686 |
|
8687 | try {
|
8688 | return updateState(initialState);
|
8689 | } finally {
|
8690 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8691 | }
|
8692 | },
|
8693 | useDebugValue: function (value, formatterFn) {
|
8694 | currentHookNameInDev = 'useDebugValue';
|
8695 | updateHookTypesDev();
|
8696 | return updateDebugValue();
|
8697 | },
|
8698 | useDeferredValue: function (value) {
|
8699 | currentHookNameInDev = 'useDeferredValue';
|
8700 | updateHookTypesDev();
|
8701 | return updateDeferredValue(value);
|
8702 | },
|
8703 | useTransition: function () {
|
8704 | currentHookNameInDev = 'useTransition';
|
8705 | updateHookTypesDev();
|
8706 | return updateTransition();
|
8707 | },
|
8708 | useMutableSource: function (source, getSnapshot, subscribe) {
|
8709 | currentHookNameInDev = 'useMutableSource';
|
8710 | updateHookTypesDev();
|
8711 | return updateMutableSource();
|
8712 | },
|
8713 | useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
|
8714 | currentHookNameInDev = 'useSyncExternalStore';
|
8715 | updateHookTypesDev();
|
8716 | return updateSyncExternalStore(subscribe, getSnapshot);
|
8717 | },
|
8718 | useId: function () {
|
8719 | currentHookNameInDev = 'useId';
|
8720 | updateHookTypesDev();
|
8721 | return updateId();
|
8722 | },
|
8723 | unstable_isNewReconciler: enableNewReconciler
|
8724 | };
|
8725 |
|
8726 | HooksDispatcherOnRerenderInDEV = {
|
8727 | readContext: function (context) {
|
8728 | return readContext(context);
|
8729 | },
|
8730 | useCallback: function (callback, deps) {
|
8731 | currentHookNameInDev = 'useCallback';
|
8732 | updateHookTypesDev();
|
8733 | return updateCallback(callback, deps);
|
8734 | },
|
8735 | useContext: function (context) {
|
8736 | currentHookNameInDev = 'useContext';
|
8737 | updateHookTypesDev();
|
8738 | return readContext(context);
|
8739 | },
|
8740 | useEffect: function (create, deps) {
|
8741 | currentHookNameInDev = 'useEffect';
|
8742 | updateHookTypesDev();
|
8743 | return updateEffect(create, deps);
|
8744 | },
|
8745 | useImperativeHandle: function (ref, create, deps) {
|
8746 | currentHookNameInDev = 'useImperativeHandle';
|
8747 | updateHookTypesDev();
|
8748 | return updateImperativeHandle(ref, create, deps);
|
8749 | },
|
8750 | useInsertionEffect: function (create, deps) {
|
8751 | currentHookNameInDev = 'useInsertionEffect';
|
8752 | updateHookTypesDev();
|
8753 | return updateInsertionEffect(create, deps);
|
8754 | },
|
8755 | useLayoutEffect: function (create, deps) {
|
8756 | currentHookNameInDev = 'useLayoutEffect';
|
8757 | updateHookTypesDev();
|
8758 | return updateLayoutEffect(create, deps);
|
8759 | },
|
8760 | useMemo: function (create, deps) {
|
8761 | currentHookNameInDev = 'useMemo';
|
8762 | updateHookTypesDev();
|
8763 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8764 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
8765 |
|
8766 | try {
|
8767 | return updateMemo(create, deps);
|
8768 | } finally {
|
8769 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8770 | }
|
8771 | },
|
8772 | useReducer: function (reducer, initialArg, init) {
|
8773 | currentHookNameInDev = 'useReducer';
|
8774 | updateHookTypesDev();
|
8775 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8776 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
8777 |
|
8778 | try {
|
8779 | return rerenderReducer(reducer, initialArg, init);
|
8780 | } finally {
|
8781 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8782 | }
|
8783 | },
|
8784 | useRef: function (initialValue) {
|
8785 | currentHookNameInDev = 'useRef';
|
8786 | updateHookTypesDev();
|
8787 | return updateRef();
|
8788 | },
|
8789 | useState: function (initialState) {
|
8790 | currentHookNameInDev = 'useState';
|
8791 | updateHookTypesDev();
|
8792 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8793 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
8794 |
|
8795 | try {
|
8796 | return rerenderState(initialState);
|
8797 | } finally {
|
8798 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8799 | }
|
8800 | },
|
8801 | useDebugValue: function (value, formatterFn) {
|
8802 | currentHookNameInDev = 'useDebugValue';
|
8803 | updateHookTypesDev();
|
8804 | return updateDebugValue();
|
8805 | },
|
8806 | useDeferredValue: function (value) {
|
8807 | currentHookNameInDev = 'useDeferredValue';
|
8808 | updateHookTypesDev();
|
8809 | return rerenderDeferredValue(value);
|
8810 | },
|
8811 | useTransition: function () {
|
8812 | currentHookNameInDev = 'useTransition';
|
8813 | updateHookTypesDev();
|
8814 | return rerenderTransition();
|
8815 | },
|
8816 | useMutableSource: function (source, getSnapshot, subscribe) {
|
8817 | currentHookNameInDev = 'useMutableSource';
|
8818 | updateHookTypesDev();
|
8819 | return updateMutableSource();
|
8820 | },
|
8821 | useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
|
8822 | currentHookNameInDev = 'useSyncExternalStore';
|
8823 | updateHookTypesDev();
|
8824 | return updateSyncExternalStore(subscribe, getSnapshot);
|
8825 | },
|
8826 | useId: function () {
|
8827 | currentHookNameInDev = 'useId';
|
8828 | updateHookTypesDev();
|
8829 | return updateId();
|
8830 | },
|
8831 | unstable_isNewReconciler: enableNewReconciler
|
8832 | };
|
8833 |
|
8834 | InvalidNestedHooksDispatcherOnMountInDEV = {
|
8835 | readContext: function (context) {
|
8836 | warnInvalidContextAccess();
|
8837 | return readContext(context);
|
8838 | },
|
8839 | useCallback: function (callback, deps) {
|
8840 | currentHookNameInDev = 'useCallback';
|
8841 | warnInvalidHookAccess();
|
8842 | mountHookTypesDev();
|
8843 | return mountCallback(callback, deps);
|
8844 | },
|
8845 | useContext: function (context) {
|
8846 | currentHookNameInDev = 'useContext';
|
8847 | warnInvalidHookAccess();
|
8848 | mountHookTypesDev();
|
8849 | return readContext(context);
|
8850 | },
|
8851 | useEffect: function (create, deps) {
|
8852 | currentHookNameInDev = 'useEffect';
|
8853 | warnInvalidHookAccess();
|
8854 | mountHookTypesDev();
|
8855 | return mountEffect(create, deps);
|
8856 | },
|
8857 | useImperativeHandle: function (ref, create, deps) {
|
8858 | currentHookNameInDev = 'useImperativeHandle';
|
8859 | warnInvalidHookAccess();
|
8860 | mountHookTypesDev();
|
8861 | return mountImperativeHandle(ref, create, deps);
|
8862 | },
|
8863 | useInsertionEffect: function (create, deps) {
|
8864 | currentHookNameInDev = 'useInsertionEffect';
|
8865 | warnInvalidHookAccess();
|
8866 | mountHookTypesDev();
|
8867 | return mountInsertionEffect(create, deps);
|
8868 | },
|
8869 | useLayoutEffect: function (create, deps) {
|
8870 | currentHookNameInDev = 'useLayoutEffect';
|
8871 | warnInvalidHookAccess();
|
8872 | mountHookTypesDev();
|
8873 | return mountLayoutEffect(create, deps);
|
8874 | },
|
8875 | useMemo: function (create, deps) {
|
8876 | currentHookNameInDev = 'useMemo';
|
8877 | warnInvalidHookAccess();
|
8878 | mountHookTypesDev();
|
8879 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8880 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8881 |
|
8882 | try {
|
8883 | return mountMemo(create, deps);
|
8884 | } finally {
|
8885 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8886 | }
|
8887 | },
|
8888 | useReducer: function (reducer, initialArg, init) {
|
8889 | currentHookNameInDev = 'useReducer';
|
8890 | warnInvalidHookAccess();
|
8891 | mountHookTypesDev();
|
8892 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8893 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8894 |
|
8895 | try {
|
8896 | return mountReducer(reducer, initialArg, init);
|
8897 | } finally {
|
8898 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8899 | }
|
8900 | },
|
8901 | useRef: function (initialValue) {
|
8902 | currentHookNameInDev = 'useRef';
|
8903 | warnInvalidHookAccess();
|
8904 | mountHookTypesDev();
|
8905 | return mountRef(initialValue);
|
8906 | },
|
8907 | useState: function (initialState) {
|
8908 | currentHookNameInDev = 'useState';
|
8909 | warnInvalidHookAccess();
|
8910 | mountHookTypesDev();
|
8911 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
8912 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
8913 |
|
8914 | try {
|
8915 | return mountState(initialState);
|
8916 | } finally {
|
8917 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
8918 | }
|
8919 | },
|
8920 | useDebugValue: function (value, formatterFn) {
|
8921 | currentHookNameInDev = 'useDebugValue';
|
8922 | warnInvalidHookAccess();
|
8923 | mountHookTypesDev();
|
8924 | return mountDebugValue();
|
8925 | },
|
8926 | useDeferredValue: function (value) {
|
8927 | currentHookNameInDev = 'useDeferredValue';
|
8928 | warnInvalidHookAccess();
|
8929 | mountHookTypesDev();
|
8930 | return mountDeferredValue(value);
|
8931 | },
|
8932 | useTransition: function () {
|
8933 | currentHookNameInDev = 'useTransition';
|
8934 | warnInvalidHookAccess();
|
8935 | mountHookTypesDev();
|
8936 | return mountTransition();
|
8937 | },
|
8938 | useMutableSource: function (source, getSnapshot, subscribe) {
|
8939 | currentHookNameInDev = 'useMutableSource';
|
8940 | warnInvalidHookAccess();
|
8941 | mountHookTypesDev();
|
8942 | return mountMutableSource();
|
8943 | },
|
8944 | useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
|
8945 | currentHookNameInDev = 'useSyncExternalStore';
|
8946 | warnInvalidHookAccess();
|
8947 | mountHookTypesDev();
|
8948 | return mountSyncExternalStore(subscribe, getSnapshot);
|
8949 | },
|
8950 | useId: function () {
|
8951 | currentHookNameInDev = 'useId';
|
8952 | warnInvalidHookAccess();
|
8953 | mountHookTypesDev();
|
8954 | return mountId();
|
8955 | },
|
8956 | unstable_isNewReconciler: enableNewReconciler
|
8957 | };
|
8958 |
|
8959 | InvalidNestedHooksDispatcherOnUpdateInDEV = {
|
8960 | readContext: function (context) {
|
8961 | warnInvalidContextAccess();
|
8962 | return readContext(context);
|
8963 | },
|
8964 | useCallback: function (callback, deps) {
|
8965 | currentHookNameInDev = 'useCallback';
|
8966 | warnInvalidHookAccess();
|
8967 | updateHookTypesDev();
|
8968 | return updateCallback(callback, deps);
|
8969 | },
|
8970 | useContext: function (context) {
|
8971 | currentHookNameInDev = 'useContext';
|
8972 | warnInvalidHookAccess();
|
8973 | updateHookTypesDev();
|
8974 | return readContext(context);
|
8975 | },
|
8976 | useEffect: function (create, deps) {
|
8977 | currentHookNameInDev = 'useEffect';
|
8978 | warnInvalidHookAccess();
|
8979 | updateHookTypesDev();
|
8980 | return updateEffect(create, deps);
|
8981 | },
|
8982 | useImperativeHandle: function (ref, create, deps) {
|
8983 | currentHookNameInDev = 'useImperativeHandle';
|
8984 | warnInvalidHookAccess();
|
8985 | updateHookTypesDev();
|
8986 | return updateImperativeHandle(ref, create, deps);
|
8987 | },
|
8988 | useInsertionEffect: function (create, deps) {
|
8989 | currentHookNameInDev = 'useInsertionEffect';
|
8990 | warnInvalidHookAccess();
|
8991 | updateHookTypesDev();
|
8992 | return updateInsertionEffect(create, deps);
|
8993 | },
|
8994 | useLayoutEffect: function (create, deps) {
|
8995 | currentHookNameInDev = 'useLayoutEffect';
|
8996 | warnInvalidHookAccess();
|
8997 | updateHookTypesDev();
|
8998 | return updateLayoutEffect(create, deps);
|
8999 | },
|
9000 | useMemo: function (create, deps) {
|
9001 | currentHookNameInDev = 'useMemo';
|
9002 | warnInvalidHookAccess();
|
9003 | updateHookTypesDev();
|
9004 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
9005 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
9006 |
|
9007 | try {
|
9008 | return updateMemo(create, deps);
|
9009 | } finally {
|
9010 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
9011 | }
|
9012 | },
|
9013 | useReducer: function (reducer, initialArg, init) {
|
9014 | currentHookNameInDev = 'useReducer';
|
9015 | warnInvalidHookAccess();
|
9016 | updateHookTypesDev();
|
9017 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
9018 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
9019 |
|
9020 | try {
|
9021 | return updateReducer(reducer, initialArg, init);
|
9022 | } finally {
|
9023 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
9024 | }
|
9025 | },
|
9026 | useRef: function (initialValue) {
|
9027 | currentHookNameInDev = 'useRef';
|
9028 | warnInvalidHookAccess();
|
9029 | updateHookTypesDev();
|
9030 | return updateRef();
|
9031 | },
|
9032 | useState: function (initialState) {
|
9033 | currentHookNameInDev = 'useState';
|
9034 | warnInvalidHookAccess();
|
9035 | updateHookTypesDev();
|
9036 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
9037 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
9038 |
|
9039 | try {
|
9040 | return updateState(initialState);
|
9041 | } finally {
|
9042 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
9043 | }
|
9044 | },
|
9045 | useDebugValue: function (value, formatterFn) {
|
9046 | currentHookNameInDev = 'useDebugValue';
|
9047 | warnInvalidHookAccess();
|
9048 | updateHookTypesDev();
|
9049 | return updateDebugValue();
|
9050 | },
|
9051 | useDeferredValue: function (value) {
|
9052 | currentHookNameInDev = 'useDeferredValue';
|
9053 | warnInvalidHookAccess();
|
9054 | updateHookTypesDev();
|
9055 | return updateDeferredValue(value);
|
9056 | },
|
9057 | useTransition: function () {
|
9058 | currentHookNameInDev = 'useTransition';
|
9059 | warnInvalidHookAccess();
|
9060 | updateHookTypesDev();
|
9061 | return updateTransition();
|
9062 | },
|
9063 | useMutableSource: function (source, getSnapshot, subscribe) {
|
9064 | currentHookNameInDev = 'useMutableSource';
|
9065 | warnInvalidHookAccess();
|
9066 | updateHookTypesDev();
|
9067 | return updateMutableSource();
|
9068 | },
|
9069 | useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
|
9070 | currentHookNameInDev = 'useSyncExternalStore';
|
9071 | warnInvalidHookAccess();
|
9072 | updateHookTypesDev();
|
9073 | return updateSyncExternalStore(subscribe, getSnapshot);
|
9074 | },
|
9075 | useId: function () {
|
9076 | currentHookNameInDev = 'useId';
|
9077 | warnInvalidHookAccess();
|
9078 | updateHookTypesDev();
|
9079 | return updateId();
|
9080 | },
|
9081 | unstable_isNewReconciler: enableNewReconciler
|
9082 | };
|
9083 |
|
9084 | InvalidNestedHooksDispatcherOnRerenderInDEV = {
|
9085 | readContext: function (context) {
|
9086 | warnInvalidContextAccess();
|
9087 | return readContext(context);
|
9088 | },
|
9089 | useCallback: function (callback, deps) {
|
9090 | currentHookNameInDev = 'useCallback';
|
9091 | warnInvalidHookAccess();
|
9092 | updateHookTypesDev();
|
9093 | return updateCallback(callback, deps);
|
9094 | },
|
9095 | useContext: function (context) {
|
9096 | currentHookNameInDev = 'useContext';
|
9097 | warnInvalidHookAccess();
|
9098 | updateHookTypesDev();
|
9099 | return readContext(context);
|
9100 | },
|
9101 | useEffect: function (create, deps) {
|
9102 | currentHookNameInDev = 'useEffect';
|
9103 | warnInvalidHookAccess();
|
9104 | updateHookTypesDev();
|
9105 | return updateEffect(create, deps);
|
9106 | },
|
9107 | useImperativeHandle: function (ref, create, deps) {
|
9108 | currentHookNameInDev = 'useImperativeHandle';
|
9109 | warnInvalidHookAccess();
|
9110 | updateHookTypesDev();
|
9111 | return updateImperativeHandle(ref, create, deps);
|
9112 | },
|
9113 | useInsertionEffect: function (create, deps) {
|
9114 | currentHookNameInDev = 'useInsertionEffect';
|
9115 | warnInvalidHookAccess();
|
9116 | updateHookTypesDev();
|
9117 | return updateInsertionEffect(create, deps);
|
9118 | },
|
9119 | useLayoutEffect: function (create, deps) {
|
9120 | currentHookNameInDev = 'useLayoutEffect';
|
9121 | warnInvalidHookAccess();
|
9122 | updateHookTypesDev();
|
9123 | return updateLayoutEffect(create, deps);
|
9124 | },
|
9125 | useMemo: function (create, deps) {
|
9126 | currentHookNameInDev = 'useMemo';
|
9127 | warnInvalidHookAccess();
|
9128 | updateHookTypesDev();
|
9129 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
9130 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
9131 |
|
9132 | try {
|
9133 | return updateMemo(create, deps);
|
9134 | } finally {
|
9135 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
9136 | }
|
9137 | },
|
9138 | useReducer: function (reducer, initialArg, init) {
|
9139 | currentHookNameInDev = 'useReducer';
|
9140 | warnInvalidHookAccess();
|
9141 | updateHookTypesDev();
|
9142 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
9143 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
9144 |
|
9145 | try {
|
9146 | return rerenderReducer(reducer, initialArg, init);
|
9147 | } finally {
|
9148 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
9149 | }
|
9150 | },
|
9151 | useRef: function (initialValue) {
|
9152 | currentHookNameInDev = 'useRef';
|
9153 | warnInvalidHookAccess();
|
9154 | updateHookTypesDev();
|
9155 | return updateRef();
|
9156 | },
|
9157 | useState: function (initialState) {
|
9158 | currentHookNameInDev = 'useState';
|
9159 | warnInvalidHookAccess();
|
9160 | updateHookTypesDev();
|
9161 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
9162 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
9163 |
|
9164 | try {
|
9165 | return rerenderState(initialState);
|
9166 | } finally {
|
9167 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
9168 | }
|
9169 | },
|
9170 | useDebugValue: function (value, formatterFn) {
|
9171 | currentHookNameInDev = 'useDebugValue';
|
9172 | warnInvalidHookAccess();
|
9173 | updateHookTypesDev();
|
9174 | return updateDebugValue();
|
9175 | },
|
9176 | useDeferredValue: function (value) {
|
9177 | currentHookNameInDev = 'useDeferredValue';
|
9178 | warnInvalidHookAccess();
|
9179 | updateHookTypesDev();
|
9180 | return rerenderDeferredValue(value);
|
9181 | },
|
9182 | useTransition: function () {
|
9183 | currentHookNameInDev = 'useTransition';
|
9184 | warnInvalidHookAccess();
|
9185 | updateHookTypesDev();
|
9186 | return rerenderTransition();
|
9187 | },
|
9188 | useMutableSource: function (source, getSnapshot, subscribe) {
|
9189 | currentHookNameInDev = 'useMutableSource';
|
9190 | warnInvalidHookAccess();
|
9191 | updateHookTypesDev();
|
9192 | return updateMutableSource();
|
9193 | },
|
9194 | useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
|
9195 | currentHookNameInDev = 'useSyncExternalStore';
|
9196 | warnInvalidHookAccess();
|
9197 | updateHookTypesDev();
|
9198 | return updateSyncExternalStore(subscribe, getSnapshot);
|
9199 | },
|
9200 | useId: function () {
|
9201 | currentHookNameInDev = 'useId';
|
9202 | warnInvalidHookAccess();
|
9203 | updateHookTypesDev();
|
9204 | return updateId();
|
9205 | },
|
9206 | unstable_isNewReconciler: enableNewReconciler
|
9207 | };
|
9208 | }
|
9209 |
|
9210 | var now$1 = unstable_now;
|
9211 | var commitTime = 0;
|
9212 | var layoutEffectStartTime = -1;
|
9213 | var profilerStartTime = -1;
|
9214 | var passiveEffectStartTime = -1;
|
9215 | |
9216 |
|
9217 |
|
9218 |
|
9219 |
|
9220 |
|
9221 |
|
9222 |
|
9223 |
|
9224 |
|
9225 |
|
9226 |
|
9227 |
|
9228 |
|
9229 |
|
9230 |
|
9231 |
|
9232 | var currentUpdateIsNested = false;
|
9233 | var nestedUpdateScheduled = false;
|
9234 |
|
9235 | function isCurrentUpdateNested() {
|
9236 | return currentUpdateIsNested;
|
9237 | }
|
9238 |
|
9239 | function markNestedUpdateScheduled() {
|
9240 | {
|
9241 | nestedUpdateScheduled = true;
|
9242 | }
|
9243 | }
|
9244 |
|
9245 | function resetNestedUpdateFlag() {
|
9246 | {
|
9247 | currentUpdateIsNested = false;
|
9248 | nestedUpdateScheduled = false;
|
9249 | }
|
9250 | }
|
9251 |
|
9252 | function syncNestedUpdateFlag() {
|
9253 | {
|
9254 | currentUpdateIsNested = nestedUpdateScheduled;
|
9255 | nestedUpdateScheduled = false;
|
9256 | }
|
9257 | }
|
9258 |
|
9259 | function getCommitTime() {
|
9260 | return commitTime;
|
9261 | }
|
9262 |
|
9263 | function recordCommitTime() {
|
9264 |
|
9265 | commitTime = now$1();
|
9266 | }
|
9267 |
|
9268 | function startProfilerTimer(fiber) {
|
9269 |
|
9270 | profilerStartTime = now$1();
|
9271 |
|
9272 | if (fiber.actualStartTime < 0) {
|
9273 | fiber.actualStartTime = now$1();
|
9274 | }
|
9275 | }
|
9276 |
|
9277 | function stopProfilerTimerIfRunning(fiber) {
|
9278 |
|
9279 | profilerStartTime = -1;
|
9280 | }
|
9281 |
|
9282 | function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
|
9283 |
|
9284 | if (profilerStartTime >= 0) {
|
9285 | var elapsedTime = now$1() - profilerStartTime;
|
9286 | fiber.actualDuration += elapsedTime;
|
9287 |
|
9288 | if (overrideBaseTime) {
|
9289 | fiber.selfBaseDuration = elapsedTime;
|
9290 | }
|
9291 |
|
9292 | profilerStartTime = -1;
|
9293 | }
|
9294 | }
|
9295 |
|
9296 | function recordLayoutEffectDuration(fiber) {
|
9297 |
|
9298 | if (layoutEffectStartTime >= 0) {
|
9299 | var elapsedTime = now$1() - layoutEffectStartTime;
|
9300 | layoutEffectStartTime = -1;
|
9301 |
|
9302 |
|
9303 | var parentFiber = fiber.return;
|
9304 |
|
9305 | while (parentFiber !== null) {
|
9306 | switch (parentFiber.tag) {
|
9307 | case HostRoot:
|
9308 | var root = parentFiber.stateNode;
|
9309 | root.effectDuration += elapsedTime;
|
9310 | return;
|
9311 |
|
9312 | case Profiler:
|
9313 | var parentStateNode = parentFiber.stateNode;
|
9314 | parentStateNode.effectDuration += elapsedTime;
|
9315 | return;
|
9316 | }
|
9317 |
|
9318 | parentFiber = parentFiber.return;
|
9319 | }
|
9320 | }
|
9321 | }
|
9322 |
|
9323 | function recordPassiveEffectDuration(fiber) {
|
9324 |
|
9325 | if (passiveEffectStartTime >= 0) {
|
9326 | var elapsedTime = now$1() - passiveEffectStartTime;
|
9327 | passiveEffectStartTime = -1;
|
9328 |
|
9329 |
|
9330 | var parentFiber = fiber.return;
|
9331 |
|
9332 | while (parentFiber !== null) {
|
9333 | switch (parentFiber.tag) {
|
9334 | case HostRoot:
|
9335 | var root = parentFiber.stateNode;
|
9336 |
|
9337 | if (root !== null) {
|
9338 | root.passiveEffectDuration += elapsedTime;
|
9339 | }
|
9340 |
|
9341 | return;
|
9342 |
|
9343 | case Profiler:
|
9344 | var parentStateNode = parentFiber.stateNode;
|
9345 |
|
9346 | if (parentStateNode !== null) {
|
9347 |
|
9348 |
|
9349 |
|
9350 | parentStateNode.passiveEffectDuration += elapsedTime;
|
9351 | }
|
9352 |
|
9353 | return;
|
9354 | }
|
9355 |
|
9356 | parentFiber = parentFiber.return;
|
9357 | }
|
9358 | }
|
9359 | }
|
9360 |
|
9361 | function startLayoutEffectTimer() {
|
9362 |
|
9363 | layoutEffectStartTime = now$1();
|
9364 | }
|
9365 |
|
9366 | function startPassiveEffectTimer() {
|
9367 |
|
9368 | passiveEffectStartTime = now$1();
|
9369 | }
|
9370 |
|
9371 | function transferActualDuration(fiber) {
|
9372 |
|
9373 |
|
9374 |
|
9375 | var child = fiber.child;
|
9376 |
|
9377 | while (child) {
|
9378 | fiber.actualDuration += child.actualDuration;
|
9379 | child = child.sibling;
|
9380 | }
|
9381 | }
|
9382 |
|
9383 | function createCapturedValue(value, source) {
|
9384 |
|
9385 |
|
9386 | return {
|
9387 | value: value,
|
9388 | source: source,
|
9389 | stack: getStackByFiberInDevAndProd(source)
|
9390 | };
|
9391 | }
|
9392 |
|
9393 |
|
9394 |
|
9395 |
|
9396 | function showErrorDialog(boundary, errorInfo) {
|
9397 | return true;
|
9398 | }
|
9399 |
|
9400 | function logCapturedError(boundary, errorInfo) {
|
9401 | try {
|
9402 | var logError = showErrorDialog(boundary, errorInfo);
|
9403 |
|
9404 |
|
9405 | if (logError === false) {
|
9406 | return;
|
9407 | }
|
9408 |
|
9409 | var error = errorInfo.value;
|
9410 |
|
9411 | if (true) {
|
9412 | var source = errorInfo.source;
|
9413 | var stack = errorInfo.stack;
|
9414 | var componentStack = stack !== null ? stack : '';
|
9415 |
|
9416 |
|
9417 |
|
9418 | if (error != null && error._suppressLogging) {
|
9419 | if (boundary.tag === ClassComponent) {
|
9420 |
|
9421 |
|
9422 |
|
9423 | return;
|
9424 | }
|
9425 |
|
9426 |
|
9427 |
|
9428 |
|
9429 |
|
9430 | console['error'](error);
|
9431 |
|
9432 |
|
9433 | }
|
9434 |
|
9435 | var componentName = source ? getComponentNameFromFiber(source) : null;
|
9436 | var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
|
9437 | var errorBoundaryMessage;
|
9438 |
|
9439 | if (boundary.tag === HostRoot) {
|
9440 | errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.';
|
9441 | } else {
|
9442 | var errorBoundaryName = getComponentNameFromFiber(boundary) || 'Anonymous';
|
9443 | errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
|
9444 | }
|
9445 |
|
9446 | var combinedMessage = componentNameMessage + "\n" + componentStack + "\n\n" + ("" + errorBoundaryMessage);
|
9447 |
|
9448 |
|
9449 |
|
9450 |
|
9451 | console['error'](combinedMessage);
|
9452 | } else {
|
9453 |
|
9454 |
|
9455 |
|
9456 | console['error'](error);
|
9457 | }
|
9458 | } catch (e) {
|
9459 |
|
9460 |
|
9461 |
|
9462 |
|
9463 | setTimeout(function () {
|
9464 | throw e;
|
9465 | });
|
9466 | }
|
9467 | }
|
9468 |
|
9469 | var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map;
|
9470 |
|
9471 | function createRootErrorUpdate(fiber, errorInfo, lane) {
|
9472 | var update = createUpdate(NoTimestamp, lane);
|
9473 |
|
9474 | update.tag = CaptureUpdate;
|
9475 |
|
9476 |
|
9477 | update.payload = {
|
9478 | element: null
|
9479 | };
|
9480 | var error = errorInfo.value;
|
9481 |
|
9482 | update.callback = function () {
|
9483 | onUncaughtError(error);
|
9484 | logCapturedError(fiber, errorInfo);
|
9485 | };
|
9486 |
|
9487 | return update;
|
9488 | }
|
9489 |
|
9490 | function createClassErrorUpdate(fiber, errorInfo, lane) {
|
9491 | var update = createUpdate(NoTimestamp, lane);
|
9492 | update.tag = CaptureUpdate;
|
9493 | var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
|
9494 |
|
9495 | if (typeof getDerivedStateFromError === 'function') {
|
9496 | var error$1 = errorInfo.value;
|
9497 |
|
9498 | update.payload = function () {
|
9499 | return getDerivedStateFromError(error$1);
|
9500 | };
|
9501 |
|
9502 | update.callback = function () {
|
9503 | {
|
9504 | markFailedErrorBoundaryForHotReloading(fiber);
|
9505 | }
|
9506 |
|
9507 | logCapturedError(fiber, errorInfo);
|
9508 | };
|
9509 | }
|
9510 |
|
9511 | var inst = fiber.stateNode;
|
9512 |
|
9513 | if (inst !== null && typeof inst.componentDidCatch === 'function') {
|
9514 | update.callback = function callback() {
|
9515 | {
|
9516 | markFailedErrorBoundaryForHotReloading(fiber);
|
9517 | }
|
9518 |
|
9519 | logCapturedError(fiber, errorInfo);
|
9520 |
|
9521 | if (typeof getDerivedStateFromError !== 'function') {
|
9522 |
|
9523 |
|
9524 |
|
9525 |
|
9526 |
|
9527 | markLegacyErrorBoundaryAsFailed(this);
|
9528 | }
|
9529 |
|
9530 | var error$1 = errorInfo.value;
|
9531 | var stack = errorInfo.stack;
|
9532 | this.componentDidCatch(error$1, {
|
9533 | componentStack: stack !== null ? stack : ''
|
9534 | });
|
9535 |
|
9536 | {
|
9537 | if (typeof getDerivedStateFromError !== 'function') {
|
9538 |
|
9539 |
|
9540 |
|
9541 | if (!includesSomeLane(fiber.lanes, SyncLane)) {
|
9542 | error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentNameFromFiber(fiber) || 'Unknown');
|
9543 | }
|
9544 | }
|
9545 | }
|
9546 | };
|
9547 | }
|
9548 |
|
9549 | return update;
|
9550 | }
|
9551 |
|
9552 | function attachPingListener(root, wakeable, lanes) {
|
9553 |
|
9554 |
|
9555 |
|
9556 |
|
9557 |
|
9558 |
|
9559 |
|
9560 |
|
9561 |
|
9562 |
|
9563 |
|
9564 |
|
9565 | var pingCache = root.pingCache;
|
9566 | var threadIDs;
|
9567 |
|
9568 | if (pingCache === null) {
|
9569 | pingCache = root.pingCache = new PossiblyWeakMap$1();
|
9570 | threadIDs = new Set();
|
9571 | pingCache.set(wakeable, threadIDs);
|
9572 | } else {
|
9573 | threadIDs = pingCache.get(wakeable);
|
9574 |
|
9575 | if (threadIDs === undefined) {
|
9576 | threadIDs = new Set();
|
9577 | pingCache.set(wakeable, threadIDs);
|
9578 | }
|
9579 | }
|
9580 |
|
9581 | if (!threadIDs.has(lanes)) {
|
9582 |
|
9583 | threadIDs.add(lanes);
|
9584 | var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes);
|
9585 |
|
9586 | {
|
9587 | if (isDevToolsPresent) {
|
9588 |
|
9589 | restorePendingUpdaters(root, lanes);
|
9590 | }
|
9591 | }
|
9592 |
|
9593 | wakeable.then(ping, ping);
|
9594 | }
|
9595 | }
|
9596 |
|
9597 | function attachRetryListener(suspenseBoundary, root, wakeable, lanes) {
|
9598 |
|
9599 |
|
9600 |
|
9601 |
|
9602 |
|
9603 |
|
9604 |
|
9605 |
|
9606 |
|
9607 |
|
9608 |
|
9609 | var wakeables = suspenseBoundary.updateQueue;
|
9610 |
|
9611 | if (wakeables === null) {
|
9612 | var updateQueue = new Set();
|
9613 | updateQueue.add(wakeable);
|
9614 | suspenseBoundary.updateQueue = updateQueue;
|
9615 | } else {
|
9616 | wakeables.add(wakeable);
|
9617 | }
|
9618 | }
|
9619 |
|
9620 | function resetSuspendedComponent(sourceFiber, rootRenderLanes) {
|
9621 |
|
9622 |
|
9623 |
|
9624 | var tag = sourceFiber.tag;
|
9625 |
|
9626 | if ((sourceFiber.mode & ConcurrentMode) === NoMode && (tag === FunctionComponent || tag === ForwardRef || tag === SimpleMemoComponent)) {
|
9627 | var currentSource = sourceFiber.alternate;
|
9628 |
|
9629 | if (currentSource) {
|
9630 | sourceFiber.updateQueue = currentSource.updateQueue;
|
9631 | sourceFiber.memoizedState = currentSource.memoizedState;
|
9632 | sourceFiber.lanes = currentSource.lanes;
|
9633 | } else {
|
9634 | sourceFiber.updateQueue = null;
|
9635 | sourceFiber.memoizedState = null;
|
9636 | }
|
9637 | }
|
9638 | }
|
9639 |
|
9640 | function getNearestSuspenseBoundaryToCapture(returnFiber) {
|
9641 | var node = returnFiber;
|
9642 |
|
9643 | do {
|
9644 | if (node.tag === SuspenseComponent && shouldCaptureSuspense(node)) {
|
9645 | return node;
|
9646 | }
|
9647 |
|
9648 |
|
9649 |
|
9650 | node = node.return;
|
9651 | } while (node !== null);
|
9652 |
|
9653 | return null;
|
9654 | }
|
9655 |
|
9656 | function markSuspenseBoundaryShouldCapture(suspenseBoundary, returnFiber, sourceFiber, root, rootRenderLanes) {
|
9657 |
|
9658 |
|
9659 | if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) {
|
9660 |
|
9661 |
|
9662 |
|
9663 |
|
9664 |
|
9665 |
|
9666 | if (suspenseBoundary === returnFiber) {
|
9667 |
|
9668 |
|
9669 |
|
9670 |
|
9671 |
|
9672 |
|
9673 |
|
9674 |
|
9675 |
|
9676 |
|
9677 |
|
9678 |
|
9679 |
|
9680 |
|
9681 |
|
9682 | suspenseBoundary.flags |= ShouldCapture;
|
9683 | } else {
|
9684 | suspenseBoundary.flags |= DidCapture;
|
9685 | sourceFiber.flags |= ForceUpdateForLegacySuspense;
|
9686 |
|
9687 |
|
9688 |
|
9689 | sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
|
9690 |
|
9691 | if (sourceFiber.tag === ClassComponent) {
|
9692 | var currentSourceFiber = sourceFiber.alternate;
|
9693 |
|
9694 | if (currentSourceFiber === null) {
|
9695 |
|
9696 |
|
9697 |
|
9698 | sourceFiber.tag = IncompleteClassComponent;
|
9699 | } else {
|
9700 |
|
9701 |
|
9702 |
|
9703 | var update = createUpdate(NoTimestamp, SyncLane);
|
9704 | update.tag = ForceUpdate;
|
9705 | enqueueUpdate(sourceFiber, update);
|
9706 | }
|
9707 | }
|
9708 |
|
9709 |
|
9710 |
|
9711 | sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane);
|
9712 | }
|
9713 |
|
9714 | return suspenseBoundary;
|
9715 | }
|
9716 |
|
9717 |
|
9718 |
|
9719 |
|
9720 |
|
9721 |
|
9722 |
|
9723 |
|
9724 |
|
9725 |
|
9726 |
|
9727 |
|
9728 |
|
9729 |
|
9730 |
|
9731 |
|
9732 |
|
9733 |
|
9734 |
|
9735 |
|
9736 |
|
9737 |
|
9738 |
|
9739 |
|
9740 |
|
9741 |
|
9742 |
|
9743 |
|
9744 |
|
9745 |
|
9746 |
|
9747 |
|
9748 |
|
9749 |
|
9750 |
|
9751 |
|
9752 |
|
9753 |
|
9754 |
|
9755 |
|
9756 |
|
9757 | suspenseBoundary.flags |= ShouldCapture;
|
9758 |
|
9759 |
|
9760 | suspenseBoundary.lanes = rootRenderLanes;
|
9761 | return suspenseBoundary;
|
9762 | }
|
9763 |
|
9764 | function throwException(root, returnFiber, sourceFiber, value, rootRenderLanes) {
|
9765 |
|
9766 | sourceFiber.flags |= Incomplete;
|
9767 |
|
9768 | {
|
9769 | if (isDevToolsPresent) {
|
9770 |
|
9771 | restorePendingUpdaters(root, rootRenderLanes);
|
9772 | }
|
9773 | }
|
9774 |
|
9775 | if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
|
9776 |
|
9777 | var wakeable = value;
|
9778 | resetSuspendedComponent(sourceFiber);
|
9779 |
|
9780 |
|
9781 | var suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
|
9782 |
|
9783 | if (suspenseBoundary !== null) {
|
9784 | suspenseBoundary.flags &= ~ForceClientRender;
|
9785 | markSuspenseBoundaryShouldCapture(suspenseBoundary, returnFiber, sourceFiber, root, rootRenderLanes);
|
9786 |
|
9787 |
|
9788 | if (suspenseBoundary.mode & ConcurrentMode) {
|
9789 | attachPingListener(root, wakeable, rootRenderLanes);
|
9790 | }
|
9791 |
|
9792 | attachRetryListener(suspenseBoundary, root, wakeable);
|
9793 | return;
|
9794 | } else {
|
9795 |
|
9796 |
|
9797 | if (!includesSyncLane(rootRenderLanes)) {
|
9798 |
|
9799 |
|
9800 |
|
9801 |
|
9802 |
|
9803 |
|
9804 |
|
9805 | attachPingListener(root, wakeable, rootRenderLanes);
|
9806 | renderDidSuspendDelayIfPossible();
|
9807 | return;
|
9808 | }
|
9809 |
|
9810 |
|
9811 |
|
9812 |
|
9813 | var uncaughtSuspenseError = new Error('A component suspended while responding to synchronous input. This ' + 'will cause the UI to be replaced with a loading indicator. To ' + 'fix, updates that suspend should be wrapped ' + 'with startTransition.');
|
9814 |
|
9815 |
|
9816 | value = uncaughtSuspenseError;
|
9817 | }
|
9818 | }
|
9819 |
|
9820 |
|
9821 |
|
9822 |
|
9823 | renderDidError(value);
|
9824 | value = createCapturedValue(value, sourceFiber);
|
9825 | var workInProgress = returnFiber;
|
9826 |
|
9827 | do {
|
9828 | switch (workInProgress.tag) {
|
9829 | case HostRoot:
|
9830 | {
|
9831 | var _errorInfo = value;
|
9832 | workInProgress.flags |= ShouldCapture;
|
9833 | var lane = pickArbitraryLane(rootRenderLanes);
|
9834 | workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
|
9835 | var update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
|
9836 | enqueueCapturedUpdate(workInProgress, update);
|
9837 | return;
|
9838 | }
|
9839 |
|
9840 | case ClassComponent:
|
9841 |
|
9842 | var errorInfo = value;
|
9843 | var ctor = workInProgress.type;
|
9844 | var instance = workInProgress.stateNode;
|
9845 |
|
9846 | if ((workInProgress.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
|
9847 | workInProgress.flags |= ShouldCapture;
|
9848 |
|
9849 | var _lane = pickArbitraryLane(rootRenderLanes);
|
9850 |
|
9851 | workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane);
|
9852 |
|
9853 | var _update = createClassErrorUpdate(workInProgress, errorInfo, _lane);
|
9854 |
|
9855 | enqueueCapturedUpdate(workInProgress, _update);
|
9856 | return;
|
9857 | }
|
9858 |
|
9859 | break;
|
9860 | }
|
9861 |
|
9862 | workInProgress = workInProgress.return;
|
9863 | } while (workInProgress !== null);
|
9864 | }
|
9865 |
|
9866 | function getSuspendedCache() {
|
9867 | {
|
9868 | return null;
|
9869 | }
|
9870 | }
|
9871 |
|
9872 | function markUpdate(workInProgress) {
|
9873 |
|
9874 |
|
9875 | workInProgress.flags |= Update;
|
9876 | }
|
9877 |
|
9878 | function markRef(workInProgress) {
|
9879 | workInProgress.flags |= Ref;
|
9880 |
|
9881 | {
|
9882 | workInProgress.flags |= RefStatic;
|
9883 | }
|
9884 | }
|
9885 |
|
9886 | var appendAllChildren;
|
9887 | var updateHostContainer;
|
9888 | var updateHostComponent;
|
9889 | var updateHostText;
|
9890 |
|
9891 | {
|
9892 |
|
9893 | appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
|
9894 |
|
9895 |
|
9896 | var node = workInProgress.child;
|
9897 |
|
9898 | while (node !== null) {
|
9899 | if (node.tag === HostComponent || node.tag === HostText) {
|
9900 | appendInitialChild(parent, node.stateNode);
|
9901 | } else if (node.tag === HostPortal) ; else if (node.child !== null) {
|
9902 | node.child.return = node;
|
9903 | node = node.child;
|
9904 | continue;
|
9905 | }
|
9906 |
|
9907 | if (node === workInProgress) {
|
9908 | return;
|
9909 | }
|
9910 |
|
9911 | while (node.sibling === null) {
|
9912 | if (node.return === null || node.return === workInProgress) {
|
9913 | return;
|
9914 | }
|
9915 |
|
9916 | node = node.return;
|
9917 | }
|
9918 |
|
9919 | node.sibling.return = node.return;
|
9920 | node = node.sibling;
|
9921 | }
|
9922 | };
|
9923 |
|
9924 | updateHostContainer = function (current, workInProgress) {
|
9925 | };
|
9926 |
|
9927 | updateHostComponent = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
9928 |
|
9929 |
|
9930 | var oldProps = current.memoizedProps;
|
9931 |
|
9932 | if (oldProps === newProps) {
|
9933 |
|
9934 |
|
9935 | return;
|
9936 | }
|
9937 |
|
9938 |
|
9939 |
|
9940 |
|
9941 |
|
9942 | var instance = workInProgress.stateNode;
|
9943 | var currentHostContext = getHostContext();
|
9944 |
|
9945 |
|
9946 |
|
9947 | var updatePayload = prepareUpdate();
|
9948 |
|
9949 | workInProgress.updateQueue = updatePayload;
|
9950 |
|
9951 |
|
9952 | if (updatePayload) {
|
9953 | markUpdate(workInProgress);
|
9954 | }
|
9955 | };
|
9956 |
|
9957 | updateHostText = function (current, workInProgress, oldText, newText) {
|
9958 |
|
9959 | if (oldText !== newText) {
|
9960 | markUpdate(workInProgress);
|
9961 | }
|
9962 | };
|
9963 | }
|
9964 |
|
9965 | function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
|
9966 |
|
9967 | switch (renderState.tailMode) {
|
9968 | case 'hidden':
|
9969 | {
|
9970 |
|
9971 |
|
9972 |
|
9973 |
|
9974 |
|
9975 | var tailNode = renderState.tail;
|
9976 | var lastTailNode = null;
|
9977 |
|
9978 | while (tailNode !== null) {
|
9979 | if (tailNode.alternate !== null) {
|
9980 | lastTailNode = tailNode;
|
9981 | }
|
9982 |
|
9983 | tailNode = tailNode.sibling;
|
9984 | }
|
9985 |
|
9986 |
|
9987 |
|
9988 | if (lastTailNode === null) {
|
9989 |
|
9990 | renderState.tail = null;
|
9991 | } else {
|
9992 |
|
9993 |
|
9994 | lastTailNode.sibling = null;
|
9995 | }
|
9996 |
|
9997 | break;
|
9998 | }
|
9999 |
|
10000 | case 'collapsed':
|
10001 | {
|
10002 |
|
10003 |
|
10004 |
|
10005 |
|
10006 |
|
10007 | var _tailNode = renderState.tail;
|
10008 | var _lastTailNode = null;
|
10009 |
|
10010 | while (_tailNode !== null) {
|
10011 | if (_tailNode.alternate !== null) {
|
10012 | _lastTailNode = _tailNode;
|
10013 | }
|
10014 |
|
10015 | _tailNode = _tailNode.sibling;
|
10016 | }
|
10017 |
|
10018 |
|
10019 |
|
10020 | if (_lastTailNode === null) {
|
10021 |
|
10022 | if (!hasRenderedATailFallback && renderState.tail !== null) {
|
10023 |
|
10024 |
|
10025 | renderState.tail.sibling = null;
|
10026 | } else {
|
10027 | renderState.tail = null;
|
10028 | }
|
10029 | } else {
|
10030 |
|
10031 |
|
10032 | _lastTailNode.sibling = null;
|
10033 | }
|
10034 |
|
10035 | break;
|
10036 | }
|
10037 | }
|
10038 | }
|
10039 |
|
10040 | function bubbleProperties(completedWork) {
|
10041 | var didBailout = completedWork.alternate !== null && completedWork.alternate.child === completedWork.child;
|
10042 | var newChildLanes = NoLanes;
|
10043 | var subtreeFlags = NoFlags;
|
10044 |
|
10045 | if (!didBailout) {
|
10046 |
|
10047 | if ( (completedWork.mode & ProfileMode) !== NoMode) {
|
10048 |
|
10049 |
|
10050 | var actualDuration = completedWork.actualDuration;
|
10051 | var treeBaseDuration = completedWork.selfBaseDuration;
|
10052 | var child = completedWork.child;
|
10053 |
|
10054 | while (child !== null) {
|
10055 | newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes));
|
10056 | subtreeFlags |= child.subtreeFlags;
|
10057 | subtreeFlags |= child.flags;
|
10058 |
|
10059 |
|
10060 |
|
10061 |
|
10062 |
|
10063 |
|
10064 |
|
10065 | actualDuration += child.actualDuration;
|
10066 | treeBaseDuration += child.treeBaseDuration;
|
10067 | child = child.sibling;
|
10068 | }
|
10069 |
|
10070 | completedWork.actualDuration = actualDuration;
|
10071 | completedWork.treeBaseDuration = treeBaseDuration;
|
10072 | } else {
|
10073 | var _child = completedWork.child;
|
10074 |
|
10075 | while (_child !== null) {
|
10076 | newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes));
|
10077 | subtreeFlags |= _child.subtreeFlags;
|
10078 | subtreeFlags |= _child.flags;
|
10079 |
|
10080 |
|
10081 |
|
10082 | _child.return = completedWork;
|
10083 | _child = _child.sibling;
|
10084 | }
|
10085 | }
|
10086 |
|
10087 | completedWork.subtreeFlags |= subtreeFlags;
|
10088 | } else {
|
10089 |
|
10090 | if ( (completedWork.mode & ProfileMode) !== NoMode) {
|
10091 |
|
10092 |
|
10093 | var _treeBaseDuration = completedWork.selfBaseDuration;
|
10094 | var _child2 = completedWork.child;
|
10095 |
|
10096 | while (_child2 !== null) {
|
10097 | newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child2.lanes, _child2.childLanes));
|
10098 |
|
10099 |
|
10100 |
|
10101 |
|
10102 | subtreeFlags |= _child2.subtreeFlags & StaticMask;
|
10103 | subtreeFlags |= _child2.flags & StaticMask;
|
10104 | _treeBaseDuration += _child2.treeBaseDuration;
|
10105 | _child2 = _child2.sibling;
|
10106 | }
|
10107 |
|
10108 | completedWork.treeBaseDuration = _treeBaseDuration;
|
10109 | } else {
|
10110 | var _child3 = completedWork.child;
|
10111 |
|
10112 | while (_child3 !== null) {
|
10113 | newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child3.lanes, _child3.childLanes));
|
10114 |
|
10115 |
|
10116 |
|
10117 |
|
10118 | subtreeFlags |= _child3.subtreeFlags & StaticMask;
|
10119 | subtreeFlags |= _child3.flags & StaticMask;
|
10120 |
|
10121 |
|
10122 |
|
10123 | _child3.return = completedWork;
|
10124 | _child3 = _child3.sibling;
|
10125 | }
|
10126 | }
|
10127 |
|
10128 | completedWork.subtreeFlags |= subtreeFlags;
|
10129 | }
|
10130 |
|
10131 | completedWork.childLanes = newChildLanes;
|
10132 | return didBailout;
|
10133 | }
|
10134 |
|
10135 | function completeWork(current, workInProgress, renderLanes) {
|
10136 | var newProps = workInProgress.pendingProps;
|
10137 |
|
10138 |
|
10139 |
|
10140 |
|
10141 | popTreeContext(workInProgress);
|
10142 |
|
10143 | switch (workInProgress.tag) {
|
10144 | case IndeterminateComponent:
|
10145 | case LazyComponent:
|
10146 | case SimpleMemoComponent:
|
10147 | case FunctionComponent:
|
10148 | case ForwardRef:
|
10149 | case Fragment:
|
10150 | case Mode:
|
10151 | case Profiler:
|
10152 | case ContextConsumer:
|
10153 | case MemoComponent:
|
10154 | bubbleProperties(workInProgress);
|
10155 | return null;
|
10156 |
|
10157 | case ClassComponent:
|
10158 | {
|
10159 | var Component = workInProgress.type;
|
10160 |
|
10161 | if (isContextProvider(Component)) {
|
10162 | popContext(workInProgress);
|
10163 | }
|
10164 |
|
10165 | bubbleProperties(workInProgress);
|
10166 | return null;
|
10167 | }
|
10168 |
|
10169 | case HostRoot:
|
10170 | {
|
10171 | var fiberRoot = workInProgress.stateNode;
|
10172 |
|
10173 | popHostContainer(workInProgress);
|
10174 | popTopLevelContextObject(workInProgress);
|
10175 | resetWorkInProgressVersions();
|
10176 |
|
10177 | if (fiberRoot.pendingContext) {
|
10178 | fiberRoot.context = fiberRoot.pendingContext;
|
10179 | fiberRoot.pendingContext = null;
|
10180 | }
|
10181 |
|
10182 | if (current === null || current.child === null) {
|
10183 |
|
10184 |
|
10185 | var wasHydrated = popHydrationState();
|
10186 |
|
10187 | if (wasHydrated) {
|
10188 |
|
10189 |
|
10190 | markUpdate(workInProgress);
|
10191 | } else {
|
10192 | if (current !== null) {
|
10193 | var prevState = current.memoizedState;
|
10194 |
|
10195 | if (
|
10196 | !prevState.isDehydrated ||
|
10197 | (workInProgress.flags & ForceClientRender) !== NoFlags) {
|
10198 |
|
10199 |
|
10200 |
|
10201 |
|
10202 |
|
10203 |
|
10204 | workInProgress.flags |= Snapshot;
|
10205 |
|
10206 |
|
10207 |
|
10208 | upgradeHydrationErrorsToRecoverable();
|
10209 | }
|
10210 | }
|
10211 | }
|
10212 | }
|
10213 |
|
10214 | updateHostContainer(current, workInProgress);
|
10215 | bubbleProperties(workInProgress);
|
10216 | return null;
|
10217 | }
|
10218 |
|
10219 | case HostComponent:
|
10220 | {
|
10221 | popHostContext(workInProgress);
|
10222 | var rootContainerInstance = getRootHostContainer();
|
10223 | var type = workInProgress.type;
|
10224 |
|
10225 | if (current !== null && workInProgress.stateNode != null) {
|
10226 | updateHostComponent(current, workInProgress, type, newProps, rootContainerInstance);
|
10227 |
|
10228 | if (current.ref !== workInProgress.ref) {
|
10229 | markRef(workInProgress);
|
10230 | }
|
10231 | } else {
|
10232 | if (!newProps) {
|
10233 | if (workInProgress.stateNode === null) {
|
10234 | throw new Error('We must have new props for new mounts. This error is likely ' + 'caused by a bug in React. Please file an issue.');
|
10235 | }
|
10236 |
|
10237 |
|
10238 | bubbleProperties(workInProgress);
|
10239 | return null;
|
10240 | }
|
10241 |
|
10242 | var currentHostContext = getHostContext();
|
10243 |
|
10244 |
|
10245 |
|
10246 |
|
10247 | var _wasHydrated = popHydrationState();
|
10248 |
|
10249 | if (_wasHydrated) {
|
10250 |
|
10251 |
|
10252 | if (prepareToHydrateHostInstance()) {
|
10253 |
|
10254 |
|
10255 | markUpdate(workInProgress);
|
10256 | }
|
10257 | } else {
|
10258 | var instance = createInstance(type, newProps);
|
10259 | appendAllChildren(instance, workInProgress, false, false);
|
10260 | workInProgress.stateNode = instance;
|
10261 | }
|
10262 |
|
10263 | if (workInProgress.ref !== null) {
|
10264 |
|
10265 | markRef(workInProgress);
|
10266 | }
|
10267 | }
|
10268 |
|
10269 | bubbleProperties(workInProgress);
|
10270 | return null;
|
10271 | }
|
10272 |
|
10273 | case HostText:
|
10274 | {
|
10275 | var newText = newProps;
|
10276 |
|
10277 | if (current && workInProgress.stateNode != null) {
|
10278 | var oldText = current.memoizedProps;
|
10279 |
|
10280 |
|
10281 | updateHostText(current, workInProgress, oldText, newText);
|
10282 | } else {
|
10283 | if (typeof newText !== 'string') {
|
10284 | if (workInProgress.stateNode === null) {
|
10285 | throw new Error('We must have new props for new mounts. This error is likely ' + 'caused by a bug in React. Please file an issue.');
|
10286 | }
|
10287 |
|
10288 | }
|
10289 |
|
10290 | var _rootContainerInstance = getRootHostContainer();
|
10291 |
|
10292 | var _currentHostContext = getHostContext();
|
10293 |
|
10294 | var _wasHydrated2 = popHydrationState();
|
10295 |
|
10296 | if (_wasHydrated2) {
|
10297 | if (prepareToHydrateHostTextInstance()) {
|
10298 | markUpdate(workInProgress);
|
10299 | }
|
10300 | } else {
|
10301 | workInProgress.stateNode = createTextInstance(newText);
|
10302 | }
|
10303 | }
|
10304 |
|
10305 | bubbleProperties(workInProgress);
|
10306 | return null;
|
10307 | }
|
10308 |
|
10309 | case SuspenseComponent:
|
10310 | {
|
10311 | popSuspenseContext(workInProgress);
|
10312 | var nextState = workInProgress.memoizedState;
|
10313 |
|
10314 | {
|
10315 |
|
10316 | if (nextState !== null && nextState.dehydrated !== null) {
|
10317 |
|
10318 |
|
10319 | var _wasHydrated3 = popHydrationState();
|
10320 |
|
10321 | if (current === null) {
|
10322 | if (!_wasHydrated3) {
|
10323 | throw new Error('A dehydrated suspense component was completed without a hydrated node. ' + 'This is probably a bug in React.');
|
10324 | }
|
10325 |
|
10326 | prepareToHydrateHostSuspenseInstance();
|
10327 | bubbleProperties(workInProgress);
|
10328 |
|
10329 | {
|
10330 | if ((workInProgress.mode & ProfileMode) !== NoMode) {
|
10331 | var isTimedOutSuspense = nextState !== null;
|
10332 |
|
10333 | if (isTimedOutSuspense) {
|
10334 |
|
10335 | var primaryChildFragment = workInProgress.child;
|
10336 |
|
10337 | if (primaryChildFragment !== null) {
|
10338 |
|
10339 | workInProgress.treeBaseDuration -= primaryChildFragment.treeBaseDuration;
|
10340 | }
|
10341 | }
|
10342 | }
|
10343 | }
|
10344 |
|
10345 | return null;
|
10346 | } else {
|
10347 |
|
10348 | if ((workInProgress.flags & DidCapture) === NoFlags) {
|
10349 |
|
10350 | workInProgress.memoizedState = null;
|
10351 | }
|
10352 |
|
10353 |
|
10354 |
|
10355 |
|
10356 |
|
10357 |
|
10358 | workInProgress.flags |= Update;
|
10359 | bubbleProperties(workInProgress);
|
10360 |
|
10361 | {
|
10362 | if ((workInProgress.mode & ProfileMode) !== NoMode) {
|
10363 | var _isTimedOutSuspense = nextState !== null;
|
10364 |
|
10365 | if (_isTimedOutSuspense) {
|
10366 |
|
10367 | var _primaryChildFragment = workInProgress.child;
|
10368 |
|
10369 | if (_primaryChildFragment !== null) {
|
10370 |
|
10371 | workInProgress.treeBaseDuration -= _primaryChildFragment.treeBaseDuration;
|
10372 | }
|
10373 | }
|
10374 | }
|
10375 | }
|
10376 |
|
10377 | return null;
|
10378 | }
|
10379 | }
|
10380 |
|
10381 |
|
10382 |
|
10383 |
|
10384 |
|
10385 | upgradeHydrationErrorsToRecoverable();
|
10386 | }
|
10387 |
|
10388 | if ((workInProgress.flags & DidCapture) !== NoFlags) {
|
10389 |
|
10390 | workInProgress.lanes = renderLanes;
|
10391 |
|
10392 | if ( (workInProgress.mode & ProfileMode) !== NoMode) {
|
10393 | transferActualDuration(workInProgress);
|
10394 | }
|
10395 |
|
10396 |
|
10397 | return workInProgress;
|
10398 | }
|
10399 |
|
10400 | var nextDidTimeout = nextState !== null;
|
10401 | var prevDidTimeout = false;
|
10402 |
|
10403 | if (current === null) ; else {
|
10404 | var _prevState = current.memoizedState;
|
10405 | prevDidTimeout = _prevState !== null;
|
10406 | }
|
10407 |
|
10408 |
|
10409 |
|
10410 |
|
10411 |
|
10412 |
|
10413 |
|
10414 |
|
10415 |
|
10416 |
|
10417 |
|
10418 |
|
10419 | if (nextDidTimeout && !prevDidTimeout) {
|
10420 | var _offscreenFiber = workInProgress.child;
|
10421 | _offscreenFiber.flags |= Visibility;
|
10422 |
|
10423 |
|
10424 |
|
10425 | if ((workInProgress.mode & ConcurrentMode) !== NoMode) {
|
10426 |
|
10427 |
|
10428 |
|
10429 |
|
10430 |
|
10431 |
|
10432 |
|
10433 | var hasInvisibleChildContext = current === null && (workInProgress.memoizedProps.unstable_avoidThisFallback !== true || !enableSuspenseAvoidThisFallback);
|
10434 |
|
10435 | if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
|
10436 |
|
10437 |
|
10438 | renderDidSuspend();
|
10439 | } else {
|
10440 |
|
10441 |
|
10442 | renderDidSuspendDelayIfPossible();
|
10443 | }
|
10444 | }
|
10445 | }
|
10446 |
|
10447 | var wakeables = workInProgress.updateQueue;
|
10448 |
|
10449 | if (wakeables !== null) {
|
10450 |
|
10451 |
|
10452 | workInProgress.flags |= Update;
|
10453 | }
|
10454 |
|
10455 | bubbleProperties(workInProgress);
|
10456 |
|
10457 | {
|
10458 | if ((workInProgress.mode & ProfileMode) !== NoMode) {
|
10459 | if (nextDidTimeout) {
|
10460 |
|
10461 | var _primaryChildFragment2 = workInProgress.child;
|
10462 |
|
10463 | if (_primaryChildFragment2 !== null) {
|
10464 |
|
10465 | workInProgress.treeBaseDuration -= _primaryChildFragment2.treeBaseDuration;
|
10466 | }
|
10467 | }
|
10468 | }
|
10469 | }
|
10470 |
|
10471 | return null;
|
10472 | }
|
10473 |
|
10474 | case HostPortal:
|
10475 | popHostContainer(workInProgress);
|
10476 | updateHostContainer(current, workInProgress);
|
10477 |
|
10478 | if (current === null) {
|
10479 | preparePortalMount(workInProgress.stateNode.containerInfo);
|
10480 | }
|
10481 |
|
10482 | bubbleProperties(workInProgress);
|
10483 | return null;
|
10484 |
|
10485 | case ContextProvider:
|
10486 |
|
10487 | var context = workInProgress.type._context;
|
10488 | popProvider(context, workInProgress);
|
10489 | bubbleProperties(workInProgress);
|
10490 | return null;
|
10491 |
|
10492 | case IncompleteClassComponent:
|
10493 | {
|
10494 |
|
10495 |
|
10496 | var _Component = workInProgress.type;
|
10497 |
|
10498 | if (isContextProvider(_Component)) {
|
10499 | popContext(workInProgress);
|
10500 | }
|
10501 |
|
10502 | bubbleProperties(workInProgress);
|
10503 | return null;
|
10504 | }
|
10505 |
|
10506 | case SuspenseListComponent:
|
10507 | {
|
10508 | popSuspenseContext(workInProgress);
|
10509 | var renderState = workInProgress.memoizedState;
|
10510 |
|
10511 | if (renderState === null) {
|
10512 |
|
10513 |
|
10514 | bubbleProperties(workInProgress);
|
10515 | return null;
|
10516 | }
|
10517 |
|
10518 | var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags;
|
10519 | var renderedTail = renderState.rendering;
|
10520 |
|
10521 | if (renderedTail === null) {
|
10522 |
|
10523 | if (!didSuspendAlready) {
|
10524 |
|
10525 |
|
10526 |
|
10527 |
|
10528 |
|
10529 |
|
10530 |
|
10531 |
|
10532 |
|
10533 | var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.flags & DidCapture) === NoFlags);
|
10534 |
|
10535 | if (!cannotBeSuspended) {
|
10536 | var row = workInProgress.child;
|
10537 |
|
10538 | while (row !== null) {
|
10539 | var suspended = findFirstSuspended(row);
|
10540 |
|
10541 | if (suspended !== null) {
|
10542 | didSuspendAlready = true;
|
10543 | workInProgress.flags |= DidCapture;
|
10544 | cutOffTailIfNeeded(renderState, false);
|
10545 |
|
10546 |
|
10547 |
|
10548 |
|
10549 |
|
10550 |
|
10551 |
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 | var newThenables = suspended.updateQueue;
|
10558 |
|
10559 | if (newThenables !== null) {
|
10560 | workInProgress.updateQueue = newThenables;
|
10561 | workInProgress.flags |= Update;
|
10562 | }
|
10563 |
|
10564 |
|
10565 |
|
10566 |
|
10567 |
|
10568 | workInProgress.subtreeFlags = NoFlags;
|
10569 | resetChildFibers(workInProgress, renderLanes);
|
10570 |
|
10571 |
|
10572 | pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
|
10573 |
|
10574 | return workInProgress.child;
|
10575 | }
|
10576 |
|
10577 | row = row.sibling;
|
10578 | }
|
10579 | }
|
10580 |
|
10581 | if (renderState.tail !== null && now() > getRenderTargetTime()) {
|
10582 |
|
10583 |
|
10584 |
|
10585 | workInProgress.flags |= DidCapture;
|
10586 | didSuspendAlready = true;
|
10587 | cutOffTailIfNeeded(renderState, false);
|
10588 |
|
10589 |
|
10590 |
|
10591 |
|
10592 |
|
10593 |
|
10594 |
|
10595 |
|
10596 | workInProgress.lanes = SomeRetryLane;
|
10597 | }
|
10598 | } else {
|
10599 | cutOffTailIfNeeded(renderState, false);
|
10600 | }
|
10601 |
|
10602 | } else {
|
10603 |
|
10604 | if (!didSuspendAlready) {
|
10605 | var _suspended = findFirstSuspended(renderedTail);
|
10606 |
|
10607 | if (_suspended !== null) {
|
10608 | workInProgress.flags |= DidCapture;
|
10609 | didSuspendAlready = true;
|
10610 |
|
10611 |
|
10612 | var _newThenables = _suspended.updateQueue;
|
10613 |
|
10614 | if (_newThenables !== null) {
|
10615 | workInProgress.updateQueue = _newThenables;
|
10616 | workInProgress.flags |= Update;
|
10617 | }
|
10618 |
|
10619 | cutOffTailIfNeeded(renderState, true);
|
10620 |
|
10621 | if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate && !getIsHydrating()
|
10622 | ) {
|
10623 |
|
10624 | bubbleProperties(workInProgress);
|
10625 | return null;
|
10626 | }
|
10627 | } else if (
|
10628 |
|
10629 |
|
10630 | now() * 2 - renderState.renderingStartTime > getRenderTargetTime() && renderLanes !== OffscreenLane) {
|
10631 |
|
10632 |
|
10633 |
|
10634 | workInProgress.flags |= DidCapture;
|
10635 | didSuspendAlready = true;
|
10636 | cutOffTailIfNeeded(renderState, false);
|
10637 |
|
10638 |
|
10639 |
|
10640 |
|
10641 |
|
10642 |
|
10643 |
|
10644 |
|
10645 | workInProgress.lanes = SomeRetryLane;
|
10646 | }
|
10647 | }
|
10648 |
|
10649 | if (renderState.isBackwards) {
|
10650 |
|
10651 |
|
10652 |
|
10653 |
|
10654 |
|
10655 | renderedTail.sibling = workInProgress.child;
|
10656 | workInProgress.child = renderedTail;
|
10657 | } else {
|
10658 | var previousSibling = renderState.last;
|
10659 |
|
10660 | if (previousSibling !== null) {
|
10661 | previousSibling.sibling = renderedTail;
|
10662 | } else {
|
10663 | workInProgress.child = renderedTail;
|
10664 | }
|
10665 |
|
10666 | renderState.last = renderedTail;
|
10667 | }
|
10668 | }
|
10669 |
|
10670 | if (renderState.tail !== null) {
|
10671 |
|
10672 |
|
10673 | var next = renderState.tail;
|
10674 | renderState.rendering = next;
|
10675 | renderState.tail = next.sibling;
|
10676 | renderState.renderingStartTime = now();
|
10677 | next.sibling = null;
|
10678 |
|
10679 |
|
10680 |
|
10681 | var suspenseContext = suspenseStackCursor.current;
|
10682 |
|
10683 | if (didSuspendAlready) {
|
10684 | suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
10685 | } else {
|
10686 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
10687 | }
|
10688 |
|
10689 | pushSuspenseContext(workInProgress, suspenseContext);
|
10690 |
|
10691 |
|
10692 | return next;
|
10693 | }
|
10694 |
|
10695 | bubbleProperties(workInProgress);
|
10696 | return null;
|
10697 | }
|
10698 |
|
10699 | case ScopeComponent:
|
10700 | {
|
10701 |
|
10702 | break;
|
10703 | }
|
10704 |
|
10705 | case OffscreenComponent:
|
10706 | case LegacyHiddenComponent:
|
10707 | {
|
10708 | popRenderLanes(workInProgress);
|
10709 | var _nextState = workInProgress.memoizedState;
|
10710 | var nextIsHidden = _nextState !== null;
|
10711 |
|
10712 | if (current !== null) {
|
10713 | var _prevState2 = current.memoizedState;
|
10714 | var prevIsHidden = _prevState2 !== null;
|
10715 |
|
10716 | if (prevIsHidden !== nextIsHidden && (
|
10717 | !enableLegacyHidden )) {
|
10718 | workInProgress.flags |= Visibility;
|
10719 | }
|
10720 | }
|
10721 |
|
10722 | if (!nextIsHidden || (workInProgress.mode & ConcurrentMode) === NoMode) {
|
10723 | bubbleProperties(workInProgress);
|
10724 | } else {
|
10725 |
|
10726 |
|
10727 | if (includesSomeLane(subtreeRenderLanes, OffscreenLane)) {
|
10728 | bubbleProperties(workInProgress);
|
10729 |
|
10730 | {
|
10731 |
|
10732 |
|
10733 |
|
10734 | if ( workInProgress.subtreeFlags & (Placement | Update)) {
|
10735 | workInProgress.flags |= Visibility;
|
10736 | }
|
10737 | }
|
10738 | }
|
10739 | }
|
10740 |
|
10741 | return null;
|
10742 | }
|
10743 |
|
10744 | case CacheComponent:
|
10745 | {
|
10746 |
|
10747 | return null;
|
10748 | }
|
10749 |
|
10750 | case TracingMarkerComponent:
|
10751 | {
|
10752 |
|
10753 | return null;
|
10754 | }
|
10755 | }
|
10756 |
|
10757 | throw new Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in " + 'React. Please file an issue.');
|
10758 | }
|
10759 |
|
10760 | var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
10761 | var didReceiveUpdate = false;
|
10762 | var didWarnAboutBadClass;
|
10763 | var didWarnAboutModulePatternComponent;
|
10764 | var didWarnAboutContextTypeOnFunctionComponent;
|
10765 | var didWarnAboutGetDerivedStateOnFunctionComponent;
|
10766 | var didWarnAboutFunctionRefs;
|
10767 | var didWarnAboutReassigningProps;
|
10768 | var didWarnAboutRevealOrder;
|
10769 | var didWarnAboutTailOptions;
|
10770 |
|
10771 | {
|
10772 | didWarnAboutBadClass = {};
|
10773 | didWarnAboutModulePatternComponent = {};
|
10774 | didWarnAboutContextTypeOnFunctionComponent = {};
|
10775 | didWarnAboutGetDerivedStateOnFunctionComponent = {};
|
10776 | didWarnAboutFunctionRefs = {};
|
10777 | didWarnAboutReassigningProps = false;
|
10778 | didWarnAboutRevealOrder = {};
|
10779 | didWarnAboutTailOptions = {};
|
10780 | }
|
10781 |
|
10782 | function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
|
10783 | if (current === null) {
|
10784 |
|
10785 |
|
10786 |
|
10787 |
|
10788 | workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderLanes);
|
10789 | } else {
|
10790 |
|
10791 |
|
10792 |
|
10793 |
|
10794 |
|
10795 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderLanes);
|
10796 | }
|
10797 | }
|
10798 |
|
10799 | function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes) {
|
10800 |
|
10801 |
|
10802 |
|
10803 |
|
10804 |
|
10805 |
|
10806 |
|
10807 |
|
10808 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderLanes);
|
10809 |
|
10810 |
|
10811 |
|
10812 |
|
10813 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes);
|
10814 | }
|
10815 |
|
10816 | function updateForwardRef(current, workInProgress, Component, nextProps, renderLanes) {
|
10817 |
|
10818 |
|
10819 |
|
10820 | {
|
10821 | if (workInProgress.type !== workInProgress.elementType) {
|
10822 |
|
10823 |
|
10824 | var innerPropTypes = Component.propTypes;
|
10825 |
|
10826 | if (innerPropTypes) {
|
10827 | checkPropTypes(innerPropTypes, nextProps,
|
10828 | 'prop', getComponentNameFromType(Component));
|
10829 | }
|
10830 | }
|
10831 | }
|
10832 |
|
10833 | var render = Component.render;
|
10834 | var ref = workInProgress.ref;
|
10835 |
|
10836 | var nextChildren;
|
10837 | var hasId;
|
10838 | prepareToReadContext(workInProgress, renderLanes);
|
10839 |
|
10840 | {
|
10841 | markComponentRenderStarted(workInProgress);
|
10842 | }
|
10843 |
|
10844 | {
|
10845 | ReactCurrentOwner$1.current = workInProgress;
|
10846 | setIsRendering(true);
|
10847 | nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes);
|
10848 | hasId = checkDidRenderIdHook();
|
10849 |
|
10850 | if ( workInProgress.mode & StrictLegacyMode) {
|
10851 | setIsStrictModeForDevtools(true);
|
10852 |
|
10853 | try {
|
10854 | nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes);
|
10855 | hasId = checkDidRenderIdHook();
|
10856 | } finally {
|
10857 | setIsStrictModeForDevtools(false);
|
10858 | }
|
10859 | }
|
10860 |
|
10861 | setIsRendering(false);
|
10862 | }
|
10863 |
|
10864 | {
|
10865 | markComponentRenderStopped();
|
10866 | }
|
10867 |
|
10868 | if (current !== null && !didReceiveUpdate) {
|
10869 | bailoutHooks(current, workInProgress, renderLanes);
|
10870 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
10871 | }
|
10872 |
|
10873 |
|
10874 | workInProgress.flags |= PerformedWork;
|
10875 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
10876 | return workInProgress.child;
|
10877 | }
|
10878 |
|
10879 | function updateMemoComponent(current, workInProgress, Component, nextProps, renderLanes) {
|
10880 | if (current === null) {
|
10881 | var type = Component.type;
|
10882 |
|
10883 | if (isSimpleFunctionComponent(type) && Component.compare === null &&
|
10884 | Component.defaultProps === undefined) {
|
10885 | var resolvedType = type;
|
10886 |
|
10887 | {
|
10888 | resolvedType = resolveFunctionForHotReloading(type);
|
10889 | }
|
10890 |
|
10891 |
|
10892 |
|
10893 |
|
10894 | workInProgress.tag = SimpleMemoComponent;
|
10895 | workInProgress.type = resolvedType;
|
10896 |
|
10897 | {
|
10898 | validateFunctionComponentInDev(workInProgress, type);
|
10899 | }
|
10900 |
|
10901 | return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, renderLanes);
|
10902 | }
|
10903 |
|
10904 | {
|
10905 | var innerPropTypes = type.propTypes;
|
10906 |
|
10907 | if (innerPropTypes) {
|
10908 |
|
10909 |
|
10910 | checkPropTypes(innerPropTypes, nextProps,
|
10911 | 'prop', getComponentNameFromType(type));
|
10912 | }
|
10913 | }
|
10914 |
|
10915 | var child = createFiberFromTypeAndProps(Component.type, null, nextProps, workInProgress, workInProgress.mode, renderLanes);
|
10916 | child.ref = workInProgress.ref;
|
10917 | child.return = workInProgress;
|
10918 | workInProgress.child = child;
|
10919 | return child;
|
10920 | }
|
10921 |
|
10922 | {
|
10923 | var _type = Component.type;
|
10924 | var _innerPropTypes = _type.propTypes;
|
10925 |
|
10926 | if (_innerPropTypes) {
|
10927 |
|
10928 |
|
10929 | checkPropTypes(_innerPropTypes, nextProps,
|
10930 | 'prop', getComponentNameFromType(_type));
|
10931 | }
|
10932 | }
|
10933 |
|
10934 | var currentChild = current.child;
|
10935 |
|
10936 | var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(current, renderLanes);
|
10937 |
|
10938 | if (!hasScheduledUpdateOrContext) {
|
10939 |
|
10940 |
|
10941 | var prevProps = currentChild.memoizedProps;
|
10942 |
|
10943 | var compare = Component.compare;
|
10944 | compare = compare !== null ? compare : shallowEqual;
|
10945 |
|
10946 | if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
|
10947 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
10948 | }
|
10949 | }
|
10950 |
|
10951 |
|
10952 | workInProgress.flags |= PerformedWork;
|
10953 | var newChild = createWorkInProgress(currentChild, nextProps);
|
10954 | newChild.ref = workInProgress.ref;
|
10955 | newChild.return = workInProgress;
|
10956 | workInProgress.child = newChild;
|
10957 | return newChild;
|
10958 | }
|
10959 |
|
10960 | function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, renderLanes) {
|
10961 |
|
10962 |
|
10963 |
|
10964 | {
|
10965 | if (workInProgress.type !== workInProgress.elementType) {
|
10966 |
|
10967 |
|
10968 | var outerMemoType = workInProgress.elementType;
|
10969 |
|
10970 | if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
|
10971 |
|
10972 |
|
10973 |
|
10974 | var lazyComponent = outerMemoType;
|
10975 | var payload = lazyComponent._payload;
|
10976 | var init = lazyComponent._init;
|
10977 |
|
10978 | try {
|
10979 | outerMemoType = init(payload);
|
10980 | } catch (x) {
|
10981 | outerMemoType = null;
|
10982 | }
|
10983 |
|
10984 |
|
10985 | var outerPropTypes = outerMemoType && outerMemoType.propTypes;
|
10986 |
|
10987 | if (outerPropTypes) {
|
10988 | checkPropTypes(outerPropTypes, nextProps,
|
10989 | 'prop', getComponentNameFromType(outerMemoType));
|
10990 | }
|
10991 | }
|
10992 | }
|
10993 | }
|
10994 |
|
10995 | if (current !== null) {
|
10996 | var prevProps = current.memoizedProps;
|
10997 |
|
10998 | if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && (
|
10999 | workInProgress.type === current.type )) {
|
11000 | didReceiveUpdate = false;
|
11001 |
|
11002 | if (!checkScheduledUpdateOrContext(current, renderLanes)) {
|
11003 |
|
11004 |
|
11005 |
|
11006 |
|
11007 |
|
11008 |
|
11009 |
|
11010 |
|
11011 |
|
11012 |
|
11013 |
|
11014 |
|
11015 |
|
11016 | workInProgress.lanes = current.lanes;
|
11017 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
11018 | } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
|
11019 |
|
11020 |
|
11021 | didReceiveUpdate = true;
|
11022 | }
|
11023 | }
|
11024 | }
|
11025 |
|
11026 | return updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes);
|
11027 | }
|
11028 |
|
11029 | function updateOffscreenComponent(current, workInProgress, renderLanes) {
|
11030 | var nextProps = workInProgress.pendingProps;
|
11031 | var nextChildren = nextProps.children;
|
11032 | var prevState = current !== null ? current.memoizedState : null;
|
11033 |
|
11034 | if (nextProps.mode === 'hidden' || enableLegacyHidden ) {
|
11035 |
|
11036 | if ((workInProgress.mode & ConcurrentMode) === NoMode) {
|
11037 |
|
11038 | var nextState = {
|
11039 | baseLanes: NoLanes,
|
11040 | cachePool: null
|
11041 | };
|
11042 | workInProgress.memoizedState = nextState;
|
11043 |
|
11044 | pushRenderLanes(workInProgress, renderLanes);
|
11045 | } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
|
11046 | var spawnedCachePool = null;
|
11047 |
|
11048 |
|
11049 | var nextBaseLanes;
|
11050 |
|
11051 | if (prevState !== null) {
|
11052 | var prevBaseLanes = prevState.baseLanes;
|
11053 | nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes);
|
11054 | } else {
|
11055 | nextBaseLanes = renderLanes;
|
11056 | }
|
11057 |
|
11058 |
|
11059 | workInProgress.lanes = workInProgress.childLanes = laneToLanes(OffscreenLane);
|
11060 | var _nextState = {
|
11061 | baseLanes: nextBaseLanes,
|
11062 | cachePool: spawnedCachePool
|
11063 | };
|
11064 | workInProgress.memoizedState = _nextState;
|
11065 | workInProgress.updateQueue = null;
|
11066 |
|
11067 |
|
11068 |
|
11069 | pushRenderLanes(workInProgress, nextBaseLanes);
|
11070 |
|
11071 | return null;
|
11072 | } else {
|
11073 |
|
11074 |
|
11075 |
|
11076 | var _nextState2 = {
|
11077 | baseLanes: NoLanes,
|
11078 | cachePool: null
|
11079 | };
|
11080 | workInProgress.memoizedState = _nextState2;
|
11081 |
|
11082 | var subtreeRenderLanes = prevState !== null ? prevState.baseLanes : renderLanes;
|
11083 |
|
11084 | pushRenderLanes(workInProgress, subtreeRenderLanes);
|
11085 | }
|
11086 | } else {
|
11087 |
|
11088 | var _subtreeRenderLanes;
|
11089 |
|
11090 | if (prevState !== null) {
|
11091 |
|
11092 | _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes);
|
11093 |
|
11094 |
|
11095 | workInProgress.memoizedState = null;
|
11096 | } else {
|
11097 |
|
11098 |
|
11099 |
|
11100 | _subtreeRenderLanes = renderLanes;
|
11101 | }
|
11102 |
|
11103 | pushRenderLanes(workInProgress, _subtreeRenderLanes);
|
11104 | }
|
11105 |
|
11106 | {
|
11107 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11108 | return workInProgress.child;
|
11109 | }
|
11110 | }
|
11111 |
|
11112 | function updateFragment(current, workInProgress, renderLanes) {
|
11113 | var nextChildren = workInProgress.pendingProps;
|
11114 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11115 | return workInProgress.child;
|
11116 | }
|
11117 |
|
11118 | function updateMode(current, workInProgress, renderLanes) {
|
11119 | var nextChildren = workInProgress.pendingProps.children;
|
11120 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11121 | return workInProgress.child;
|
11122 | }
|
11123 |
|
11124 | function updateProfiler(current, workInProgress, renderLanes) {
|
11125 | {
|
11126 | workInProgress.flags |= Update;
|
11127 |
|
11128 | {
|
11129 |
|
11130 |
|
11131 | var stateNode = workInProgress.stateNode;
|
11132 | stateNode.effectDuration = 0;
|
11133 | stateNode.passiveEffectDuration = 0;
|
11134 | }
|
11135 | }
|
11136 |
|
11137 | var nextProps = workInProgress.pendingProps;
|
11138 | var nextChildren = nextProps.children;
|
11139 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11140 | return workInProgress.child;
|
11141 | }
|
11142 |
|
11143 | function markRef$1(current, workInProgress) {
|
11144 | var ref = workInProgress.ref;
|
11145 |
|
11146 | if (current === null && ref !== null || current !== null && current.ref !== ref) {
|
11147 |
|
11148 | workInProgress.flags |= Ref;
|
11149 |
|
11150 | {
|
11151 | workInProgress.flags |= RefStatic;
|
11152 | }
|
11153 | }
|
11154 | }
|
11155 |
|
11156 | function updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes) {
|
11157 | {
|
11158 | if (workInProgress.type !== workInProgress.elementType) {
|
11159 |
|
11160 |
|
11161 | var innerPropTypes = Component.propTypes;
|
11162 |
|
11163 | if (innerPropTypes) {
|
11164 | checkPropTypes(innerPropTypes, nextProps,
|
11165 | 'prop', getComponentNameFromType(Component));
|
11166 | }
|
11167 | }
|
11168 | }
|
11169 |
|
11170 | var context;
|
11171 |
|
11172 | {
|
11173 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
|
11174 | context = getMaskedContext(workInProgress, unmaskedContext);
|
11175 | }
|
11176 |
|
11177 | var nextChildren;
|
11178 | var hasId;
|
11179 | prepareToReadContext(workInProgress, renderLanes);
|
11180 |
|
11181 | {
|
11182 | markComponentRenderStarted(workInProgress);
|
11183 | }
|
11184 |
|
11185 | {
|
11186 | ReactCurrentOwner$1.current = workInProgress;
|
11187 | setIsRendering(true);
|
11188 | nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes);
|
11189 | hasId = checkDidRenderIdHook();
|
11190 |
|
11191 | if ( workInProgress.mode & StrictLegacyMode) {
|
11192 | setIsStrictModeForDevtools(true);
|
11193 |
|
11194 | try {
|
11195 | nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes);
|
11196 | hasId = checkDidRenderIdHook();
|
11197 | } finally {
|
11198 | setIsStrictModeForDevtools(false);
|
11199 | }
|
11200 | }
|
11201 |
|
11202 | setIsRendering(false);
|
11203 | }
|
11204 |
|
11205 | {
|
11206 | markComponentRenderStopped();
|
11207 | }
|
11208 |
|
11209 | if (current !== null && !didReceiveUpdate) {
|
11210 | bailoutHooks(current, workInProgress, renderLanes);
|
11211 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
11212 | }
|
11213 |
|
11214 |
|
11215 | workInProgress.flags |= PerformedWork;
|
11216 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11217 | return workInProgress.child;
|
11218 | }
|
11219 |
|
11220 | function updateClassComponent(current, workInProgress, Component, nextProps, renderLanes) {
|
11221 | {
|
11222 |
|
11223 | switch (shouldError(workInProgress)) {
|
11224 | case false:
|
11225 | {
|
11226 | var _instance = workInProgress.stateNode;
|
11227 | var ctor = workInProgress.type;
|
11228 |
|
11229 |
|
11230 | var tempInstance = new ctor(workInProgress.memoizedProps, _instance.context);
|
11231 | var state = tempInstance.state;
|
11232 |
|
11233 | _instance.updater.enqueueSetState(_instance, state, null);
|
11234 |
|
11235 | break;
|
11236 | }
|
11237 |
|
11238 | case true:
|
11239 | {
|
11240 | workInProgress.flags |= DidCapture;
|
11241 | workInProgress.flags |= ShouldCapture;
|
11242 |
|
11243 | var error$1 = new Error('Simulated error coming from DevTools');
|
11244 | var lane = pickArbitraryLane(renderLanes);
|
11245 | workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
|
11246 |
|
11247 | var update = createClassErrorUpdate(workInProgress, createCapturedValue(error$1, workInProgress), lane);
|
11248 | enqueueCapturedUpdate(workInProgress, update);
|
11249 | break;
|
11250 | }
|
11251 | }
|
11252 |
|
11253 | if (workInProgress.type !== workInProgress.elementType) {
|
11254 |
|
11255 |
|
11256 | var innerPropTypes = Component.propTypes;
|
11257 |
|
11258 | if (innerPropTypes) {
|
11259 | checkPropTypes(innerPropTypes, nextProps,
|
11260 | 'prop', getComponentNameFromType(Component));
|
11261 | }
|
11262 | }
|
11263 | }
|
11264 |
|
11265 |
|
11266 |
|
11267 |
|
11268 | var hasContext;
|
11269 |
|
11270 | if (isContextProvider(Component)) {
|
11271 | hasContext = true;
|
11272 | pushContextProvider(workInProgress);
|
11273 | } else {
|
11274 | hasContext = false;
|
11275 | }
|
11276 |
|
11277 | prepareToReadContext(workInProgress, renderLanes);
|
11278 | var instance = workInProgress.stateNode;
|
11279 | var shouldUpdate;
|
11280 |
|
11281 | if (instance === null) {
|
11282 | if (current !== null) {
|
11283 |
|
11284 |
|
11285 |
|
11286 |
|
11287 | current.alternate = null;
|
11288 | workInProgress.alternate = null;
|
11289 |
|
11290 | workInProgress.flags |= Placement;
|
11291 | }
|
11292 |
|
11293 |
|
11294 | constructClassInstance(workInProgress, Component, nextProps);
|
11295 | mountClassInstance(workInProgress, Component, nextProps, renderLanes);
|
11296 | shouldUpdate = true;
|
11297 | } else if (current === null) {
|
11298 |
|
11299 | shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderLanes);
|
11300 | } else {
|
11301 | shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderLanes);
|
11302 | }
|
11303 |
|
11304 | var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes);
|
11305 |
|
11306 | {
|
11307 | var inst = workInProgress.stateNode;
|
11308 |
|
11309 | if (shouldUpdate && inst.props !== nextProps) {
|
11310 | if (!didWarnAboutReassigningProps) {
|
11311 | error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentNameFromFiber(workInProgress) || 'a component');
|
11312 | }
|
11313 |
|
11314 | didWarnAboutReassigningProps = true;
|
11315 | }
|
11316 | }
|
11317 |
|
11318 | return nextUnitOfWork;
|
11319 | }
|
11320 |
|
11321 | function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes) {
|
11322 |
|
11323 | markRef$1(current, workInProgress);
|
11324 | var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags;
|
11325 |
|
11326 | if (!shouldUpdate && !didCaptureError) {
|
11327 |
|
11328 | if (hasContext) {
|
11329 | invalidateContextProvider(workInProgress, Component, false);
|
11330 | }
|
11331 |
|
11332 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
11333 | }
|
11334 |
|
11335 | var instance = workInProgress.stateNode;
|
11336 |
|
11337 | ReactCurrentOwner$1.current = workInProgress;
|
11338 | var nextChildren;
|
11339 |
|
11340 | if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
|
11341 |
|
11342 |
|
11343 |
|
11344 |
|
11345 |
|
11346 | nextChildren = null;
|
11347 |
|
11348 | {
|
11349 | stopProfilerTimerIfRunning();
|
11350 | }
|
11351 | } else {
|
11352 | {
|
11353 | markComponentRenderStarted(workInProgress);
|
11354 | }
|
11355 |
|
11356 | {
|
11357 | setIsRendering(true);
|
11358 | nextChildren = instance.render();
|
11359 |
|
11360 | if ( workInProgress.mode & StrictLegacyMode) {
|
11361 | setIsStrictModeForDevtools(true);
|
11362 |
|
11363 | try {
|
11364 | instance.render();
|
11365 | } finally {
|
11366 | setIsStrictModeForDevtools(false);
|
11367 | }
|
11368 | }
|
11369 |
|
11370 | setIsRendering(false);
|
11371 | }
|
11372 |
|
11373 | {
|
11374 | markComponentRenderStopped();
|
11375 | }
|
11376 | }
|
11377 |
|
11378 |
|
11379 | workInProgress.flags |= PerformedWork;
|
11380 |
|
11381 | if (current !== null && didCaptureError) {
|
11382 |
|
11383 |
|
11384 |
|
11385 |
|
11386 | forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes);
|
11387 | } else {
|
11388 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11389 | }
|
11390 |
|
11391 |
|
11392 |
|
11393 | workInProgress.memoizedState = instance.state;
|
11394 |
|
11395 | if (hasContext) {
|
11396 | invalidateContextProvider(workInProgress, Component, true);
|
11397 | }
|
11398 |
|
11399 | return workInProgress.child;
|
11400 | }
|
11401 |
|
11402 | function pushHostRootContext(workInProgress) {
|
11403 | var root = workInProgress.stateNode;
|
11404 |
|
11405 | if (root.pendingContext) {
|
11406 | pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
|
11407 | } else if (root.context) {
|
11408 |
|
11409 | pushTopLevelContextObject(workInProgress, root.context, false);
|
11410 | }
|
11411 |
|
11412 | pushHostContainer(workInProgress, root.containerInfo);
|
11413 | }
|
11414 |
|
11415 | function updateHostRoot(current, workInProgress, renderLanes) {
|
11416 | pushHostRootContext(workInProgress);
|
11417 |
|
11418 | if (current === null) {
|
11419 | throw new Error('Should have a current fiber. This is a bug in React.');
|
11420 | }
|
11421 |
|
11422 | var nextProps = workInProgress.pendingProps;
|
11423 | var prevState = workInProgress.memoizedState;
|
11424 | var prevChildren = prevState.element;
|
11425 | cloneUpdateQueue(current, workInProgress);
|
11426 | processUpdateQueue(workInProgress, nextProps, null, renderLanes);
|
11427 | var nextState = workInProgress.memoizedState;
|
11428 | var root = workInProgress.stateNode;
|
11429 |
|
11430 |
|
11431 |
|
11432 | var nextChildren = nextState.element;
|
11433 |
|
11434 | {
|
11435 |
|
11436 | if (nextChildren === prevChildren) {
|
11437 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
11438 | }
|
11439 |
|
11440 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11441 | }
|
11442 |
|
11443 | return workInProgress.child;
|
11444 | }
|
11445 |
|
11446 | function updateHostComponent$1(current, workInProgress, renderLanes) {
|
11447 | pushHostContext(workInProgress);
|
11448 |
|
11449 | var type = workInProgress.type;
|
11450 | var nextProps = workInProgress.pendingProps;
|
11451 | var prevProps = current !== null ? current.memoizedProps : null;
|
11452 | var nextChildren = nextProps.children;
|
11453 | var isDirectTextChild = shouldSetTextContent(type, nextProps);
|
11454 |
|
11455 | if (isDirectTextChild) {
|
11456 |
|
11457 |
|
11458 |
|
11459 |
|
11460 | nextChildren = null;
|
11461 | } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
|
11462 |
|
11463 |
|
11464 | workInProgress.flags |= ContentReset;
|
11465 | }
|
11466 |
|
11467 | markRef$1(current, workInProgress);
|
11468 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
11469 | return workInProgress.child;
|
11470 | }
|
11471 |
|
11472 | function updateHostText$1(current, workInProgress) {
|
11473 |
|
11474 |
|
11475 |
|
11476 | return null;
|
11477 | }
|
11478 |
|
11479 | function mountLazyComponent(_current, workInProgress, elementType, renderLanes) {
|
11480 | if (_current !== null) {
|
11481 |
|
11482 |
|
11483 |
|
11484 |
|
11485 | _current.alternate = null;
|
11486 | workInProgress.alternate = null;
|
11487 |
|
11488 | workInProgress.flags |= Placement;
|
11489 | }
|
11490 |
|
11491 | var props = workInProgress.pendingProps;
|
11492 | var lazyComponent = elementType;
|
11493 | var payload = lazyComponent._payload;
|
11494 | var init = lazyComponent._init;
|
11495 | var Component = init(payload);
|
11496 |
|
11497 | workInProgress.type = Component;
|
11498 | var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
|
11499 | var resolvedProps = resolveDefaultProps(Component, props);
|
11500 | var child;
|
11501 |
|
11502 | switch (resolvedTag) {
|
11503 | case FunctionComponent:
|
11504 | {
|
11505 | {
|
11506 | validateFunctionComponentInDev(workInProgress, Component);
|
11507 | workInProgress.type = Component = resolveFunctionForHotReloading(Component);
|
11508 | }
|
11509 |
|
11510 | child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderLanes);
|
11511 | return child;
|
11512 | }
|
11513 |
|
11514 | case ClassComponent:
|
11515 | {
|
11516 | {
|
11517 | workInProgress.type = Component = resolveClassForHotReloading(Component);
|
11518 | }
|
11519 |
|
11520 | child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderLanes);
|
11521 | return child;
|
11522 | }
|
11523 |
|
11524 | case ForwardRef:
|
11525 | {
|
11526 | {
|
11527 | workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
|
11528 | }
|
11529 |
|
11530 | child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderLanes);
|
11531 | return child;
|
11532 | }
|
11533 |
|
11534 | case MemoComponent:
|
11535 | {
|
11536 | {
|
11537 | if (workInProgress.type !== workInProgress.elementType) {
|
11538 | var outerPropTypes = Component.propTypes;
|
11539 |
|
11540 | if (outerPropTypes) {
|
11541 | checkPropTypes(outerPropTypes, resolvedProps,
|
11542 | 'prop', getComponentNameFromType(Component));
|
11543 | }
|
11544 | }
|
11545 | }
|
11546 |
|
11547 | child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps),
|
11548 | renderLanes);
|
11549 | return child;
|
11550 | }
|
11551 | }
|
11552 |
|
11553 | var hint = '';
|
11554 |
|
11555 | {
|
11556 | if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
|
11557 | hint = ' Did you wrap a component in React.lazy() more than once?';
|
11558 | }
|
11559 | }
|
11560 |
|
11561 |
|
11562 |
|
11563 |
|
11564 | throw new Error("Element type is invalid. Received a promise that resolves to: " + Component + ". " + ("Lazy element type must resolve to a class or function." + hint));
|
11565 | }
|
11566 |
|
11567 | function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderLanes) {
|
11568 | if (_current !== null) {
|
11569 |
|
11570 |
|
11571 |
|
11572 |
|
11573 | _current.alternate = null;
|
11574 | workInProgress.alternate = null;
|
11575 |
|
11576 | workInProgress.flags |= Placement;
|
11577 | }
|
11578 |
|
11579 |
|
11580 | workInProgress.tag = ClassComponent;
|
11581 |
|
11582 |
|
11583 |
|
11584 |
|
11585 | var hasContext;
|
11586 |
|
11587 | if (isContextProvider(Component)) {
|
11588 | hasContext = true;
|
11589 | pushContextProvider(workInProgress);
|
11590 | } else {
|
11591 | hasContext = false;
|
11592 | }
|
11593 |
|
11594 | prepareToReadContext(workInProgress, renderLanes);
|
11595 | constructClassInstance(workInProgress, Component, nextProps);
|
11596 | mountClassInstance(workInProgress, Component, nextProps, renderLanes);
|
11597 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes);
|
11598 | }
|
11599 |
|
11600 | function mountIndeterminateComponent(_current, workInProgress, Component, renderLanes) {
|
11601 | if (_current !== null) {
|
11602 |
|
11603 |
|
11604 |
|
11605 |
|
11606 | _current.alternate = null;
|
11607 | workInProgress.alternate = null;
|
11608 |
|
11609 | workInProgress.flags |= Placement;
|
11610 | }
|
11611 |
|
11612 | var props = workInProgress.pendingProps;
|
11613 | var context;
|
11614 |
|
11615 | {
|
11616 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
|
11617 | context = getMaskedContext(workInProgress, unmaskedContext);
|
11618 | }
|
11619 |
|
11620 | prepareToReadContext(workInProgress, renderLanes);
|
11621 | var value;
|
11622 | var hasId;
|
11623 |
|
11624 | {
|
11625 | markComponentRenderStarted(workInProgress);
|
11626 | }
|
11627 |
|
11628 | {
|
11629 | if (Component.prototype && typeof Component.prototype.render === 'function') {
|
11630 | var componentName = getComponentNameFromType(Component) || 'Unknown';
|
11631 |
|
11632 | if (!didWarnAboutBadClass[componentName]) {
|
11633 | error("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);
|
11634 |
|
11635 | didWarnAboutBadClass[componentName] = true;
|
11636 | }
|
11637 | }
|
11638 |
|
11639 | if (workInProgress.mode & StrictLegacyMode) {
|
11640 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
|
11641 | }
|
11642 |
|
11643 | setIsRendering(true);
|
11644 | ReactCurrentOwner$1.current = workInProgress;
|
11645 | value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes);
|
11646 | hasId = checkDidRenderIdHook();
|
11647 | setIsRendering(false);
|
11648 | }
|
11649 |
|
11650 | {
|
11651 | markComponentRenderStopped();
|
11652 | }
|
11653 |
|
11654 |
|
11655 | workInProgress.flags |= PerformedWork;
|
11656 |
|
11657 | {
|
11658 |
|
11659 |
|
11660 | if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
|
11661 | var _componentName = getComponentNameFromType(Component) || 'Unknown';
|
11662 |
|
11663 | if (!didWarnAboutModulePatternComponent[_componentName]) {
|
11664 | error('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);
|
11665 |
|
11666 | didWarnAboutModulePatternComponent[_componentName] = true;
|
11667 | }
|
11668 | }
|
11669 | }
|
11670 |
|
11671 | if (
|
11672 |
|
11673 | typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
|
11674 | {
|
11675 | var _componentName2 = getComponentNameFromType(Component) || 'Unknown';
|
11676 |
|
11677 | if (!didWarnAboutModulePatternComponent[_componentName2]) {
|
11678 | error('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.', _componentName2, _componentName2, _componentName2);
|
11679 |
|
11680 | didWarnAboutModulePatternComponent[_componentName2] = true;
|
11681 | }
|
11682 | }
|
11683 |
|
11684 |
|
11685 | workInProgress.tag = ClassComponent;
|
11686 |
|
11687 | workInProgress.memoizedState = null;
|
11688 | workInProgress.updateQueue = null;
|
11689 |
|
11690 |
|
11691 |
|
11692 | var hasContext = false;
|
11693 |
|
11694 | if (isContextProvider(Component)) {
|
11695 | hasContext = true;
|
11696 | pushContextProvider(workInProgress);
|
11697 | } else {
|
11698 | hasContext = false;
|
11699 | }
|
11700 |
|
11701 | workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
|
11702 | initializeUpdateQueue(workInProgress);
|
11703 | adoptClassInstance(workInProgress, value);
|
11704 | mountClassInstance(workInProgress, Component, props, renderLanes);
|
11705 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes);
|
11706 | } else {
|
11707 |
|
11708 | workInProgress.tag = FunctionComponent;
|
11709 |
|
11710 | {
|
11711 |
|
11712 | if ( workInProgress.mode & StrictLegacyMode) {
|
11713 | setIsStrictModeForDevtools(true);
|
11714 |
|
11715 | try {
|
11716 | value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes);
|
11717 | hasId = checkDidRenderIdHook();
|
11718 | } finally {
|
11719 | setIsStrictModeForDevtools(false);
|
11720 | }
|
11721 | }
|
11722 | }
|
11723 |
|
11724 | reconcileChildren(null, workInProgress, value, renderLanes);
|
11725 |
|
11726 | {
|
11727 | validateFunctionComponentInDev(workInProgress, Component);
|
11728 | }
|
11729 |
|
11730 | return workInProgress.child;
|
11731 | }
|
11732 | }
|
11733 |
|
11734 | function validateFunctionComponentInDev(workInProgress, Component) {
|
11735 | {
|
11736 | if (Component) {
|
11737 | if (Component.childContextTypes) {
|
11738 | error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
|
11739 | }
|
11740 | }
|
11741 |
|
11742 | if (workInProgress.ref !== null) {
|
11743 | var info = '';
|
11744 | var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
11745 |
|
11746 | if (ownerName) {
|
11747 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
11748 | }
|
11749 |
|
11750 | var warningKey = ownerName || '';
|
11751 | var debugSource = workInProgress._debugSource;
|
11752 |
|
11753 | if (debugSource) {
|
11754 | warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
|
11755 | }
|
11756 |
|
11757 | if (!didWarnAboutFunctionRefs[warningKey]) {
|
11758 | didWarnAboutFunctionRefs[warningKey] = true;
|
11759 |
|
11760 | error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
|
11761 | }
|
11762 | }
|
11763 |
|
11764 | if (typeof Component.getDerivedStateFromProps === 'function') {
|
11765 | var _componentName3 = getComponentNameFromType(Component) || 'Unknown';
|
11766 |
|
11767 | if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
|
11768 | error('%s: Function components do not support getDerivedStateFromProps.', _componentName3);
|
11769 |
|
11770 | didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
|
11771 | }
|
11772 | }
|
11773 |
|
11774 | if (typeof Component.contextType === 'object' && Component.contextType !== null) {
|
11775 | var _componentName4 = getComponentNameFromType(Component) || 'Unknown';
|
11776 |
|
11777 | if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
|
11778 | error('%s: Function components do not support contextType.', _componentName4);
|
11779 |
|
11780 | didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
|
11781 | }
|
11782 | }
|
11783 | }
|
11784 | }
|
11785 |
|
11786 | var SUSPENDED_MARKER = {
|
11787 | dehydrated: null,
|
11788 | treeContext: null,
|
11789 | retryLane: NoLane
|
11790 | };
|
11791 |
|
11792 | function mountSuspenseOffscreenState(renderLanes) {
|
11793 | return {
|
11794 | baseLanes: renderLanes,
|
11795 | cachePool: getSuspendedCache()
|
11796 | };
|
11797 | }
|
11798 |
|
11799 | function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
|
11800 | var cachePool = null;
|
11801 |
|
11802 | return {
|
11803 | baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes),
|
11804 | cachePool: cachePool
|
11805 | };
|
11806 | }
|
11807 |
|
11808 |
|
11809 | function shouldRemainOnFallback(suspenseContext, current, workInProgress, renderLanes) {
|
11810 |
|
11811 |
|
11812 |
|
11813 | if (current !== null) {
|
11814 | var suspenseState = current.memoizedState;
|
11815 |
|
11816 | if (suspenseState === null) {
|
11817 |
|
11818 |
|
11819 |
|
11820 |
|
11821 | return false;
|
11822 | }
|
11823 | }
|
11824 |
|
11825 |
|
11826 | return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
11827 | }
|
11828 |
|
11829 | function getRemainingWorkInPrimaryTree(current, renderLanes) {
|
11830 |
|
11831 | return removeLanes(current.childLanes, renderLanes);
|
11832 | }
|
11833 |
|
11834 | function updateSuspenseComponent(current, workInProgress, renderLanes) {
|
11835 | var nextProps = workInProgress.pendingProps;
|
11836 |
|
11837 | {
|
11838 | if (shouldSuspend(workInProgress)) {
|
11839 | workInProgress.flags |= DidCapture;
|
11840 | }
|
11841 | }
|
11842 |
|
11843 | var suspenseContext = suspenseStackCursor.current;
|
11844 | var showFallback = false;
|
11845 | var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags;
|
11846 |
|
11847 | if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
|
11848 |
|
11849 |
|
11850 | showFallback = true;
|
11851 | workInProgress.flags &= ~DidCapture;
|
11852 | } else {
|
11853 |
|
11854 | if (current === null || current.memoizedState !== null) {
|
11855 |
|
11856 |
|
11857 |
|
11858 |
|
11859 | {
|
11860 | suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
|
11861 | }
|
11862 | }
|
11863 | }
|
11864 |
|
11865 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
11866 | pushSuspenseContext(workInProgress, suspenseContext);
|
11867 |
|
11868 |
|
11869 |
|
11870 |
|
11871 |
|
11872 |
|
11873 |
|
11874 |
|
11875 |
|
11876 |
|
11877 |
|
11878 |
|
11879 |
|
11880 |
|
11881 |
|
11882 |
|
11883 |
|
11884 |
|
11885 |
|
11886 |
|
11887 |
|
11888 |
|
11889 | if (current === null) {
|
11890 |
|
11891 | {
|
11892 | var suspenseState = workInProgress.memoizedState;
|
11893 |
|
11894 | if (suspenseState !== null) {
|
11895 | var dehydrated = suspenseState.dehydrated;
|
11896 |
|
11897 | if (dehydrated !== null) {
|
11898 | return mountDehydratedSuspenseComponent(workInProgress);
|
11899 | }
|
11900 | }
|
11901 | }
|
11902 |
|
11903 | var nextPrimaryChildren = nextProps.children;
|
11904 | var nextFallbackChildren = nextProps.fallback;
|
11905 |
|
11906 | if (showFallback) {
|
11907 | var fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes);
|
11908 | var primaryChildFragment = workInProgress.child;
|
11909 | primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes);
|
11910 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
11911 | return fallbackFragment;
|
11912 | } else {
|
11913 | return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren);
|
11914 | }
|
11915 | } else {
|
11916 |
|
11917 |
|
11918 |
|
11919 | var prevState = current.memoizedState;
|
11920 |
|
11921 | if (prevState !== null) {
|
11922 |
|
11923 |
|
11924 | {
|
11925 | var _dehydrated = prevState.dehydrated;
|
11926 |
|
11927 | if (_dehydrated !== null) {
|
11928 | if (!didSuspend) {
|
11929 | return updateDehydratedSuspenseComponent(current, workInProgress, _dehydrated, prevState, renderLanes);
|
11930 | } else if (workInProgress.flags & ForceClientRender) {
|
11931 |
|
11932 | workInProgress.flags &= ~ForceClientRender;
|
11933 | return retrySuspenseComponentWithoutHydrating(current, workInProgress, renderLanes, new Error('There was an error while hydrating this Suspense boundary. ' + 'Switched to client rendering.'));
|
11934 | } else if (workInProgress.memoizedState !== null) {
|
11935 |
|
11936 |
|
11937 | workInProgress.child = current.child;
|
11938 |
|
11939 |
|
11940 | workInProgress.flags |= DidCapture;
|
11941 | return null;
|
11942 | } else {
|
11943 |
|
11944 |
|
11945 | var _nextPrimaryChildren = nextProps.children;
|
11946 | var _nextFallbackChildren = nextProps.fallback;
|
11947 | var fallbackChildFragment = mountSuspenseFallbackAfterRetryWithoutHydrating(current, workInProgress, _nextPrimaryChildren, _nextFallbackChildren, renderLanes);
|
11948 | var _primaryChildFragment2 = workInProgress.child;
|
11949 | _primaryChildFragment2.memoizedState = mountSuspenseOffscreenState(renderLanes);
|
11950 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
11951 | return fallbackChildFragment;
|
11952 | }
|
11953 | }
|
11954 | }
|
11955 |
|
11956 | if (showFallback) {
|
11957 | var _nextFallbackChildren2 = nextProps.fallback;
|
11958 | var _nextPrimaryChildren2 = nextProps.children;
|
11959 |
|
11960 | var _fallbackChildFragment = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes);
|
11961 |
|
11962 | var _primaryChildFragment3 = workInProgress.child;
|
11963 | var prevOffscreenState = current.child.memoizedState;
|
11964 | _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
|
11965 | _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes);
|
11966 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
11967 | return _fallbackChildFragment;
|
11968 | } else {
|
11969 | var _nextPrimaryChildren3 = nextProps.children;
|
11970 |
|
11971 | var _primaryChildFragment4 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren3, renderLanes);
|
11972 |
|
11973 | workInProgress.memoizedState = null;
|
11974 | return _primaryChildFragment4;
|
11975 | }
|
11976 | } else {
|
11977 |
|
11978 | if (showFallback) {
|
11979 |
|
11980 | var _nextFallbackChildren3 = nextProps.fallback;
|
11981 | var _nextPrimaryChildren4 = nextProps.children;
|
11982 |
|
11983 | var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes);
|
11984 |
|
11985 | var _primaryChildFragment5 = workInProgress.child;
|
11986 | var _prevOffscreenState = current.child.memoizedState;
|
11987 | _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
|
11988 | _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes);
|
11989 |
|
11990 |
|
11991 | workInProgress.memoizedState = SUSPENDED_MARKER;
|
11992 | return _fallbackChildFragment2;
|
11993 | } else {
|
11994 |
|
11995 |
|
11996 | var _nextPrimaryChildren5 = nextProps.children;
|
11997 |
|
11998 | var _primaryChildFragment6 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren5, renderLanes);
|
11999 |
|
12000 | workInProgress.memoizedState = null;
|
12001 | return _primaryChildFragment6;
|
12002 | }
|
12003 | }
|
12004 | }
|
12005 | }
|
12006 |
|
12007 | function mountSuspensePrimaryChildren(workInProgress, primaryChildren, renderLanes) {
|
12008 | var mode = workInProgress.mode;
|
12009 | var primaryChildProps = {
|
12010 | mode: 'visible',
|
12011 | children: primaryChildren
|
12012 | };
|
12013 | var primaryChildFragment = mountWorkInProgressOffscreenFiber(primaryChildProps, mode);
|
12014 | primaryChildFragment.return = workInProgress;
|
12015 | workInProgress.child = primaryChildFragment;
|
12016 | return primaryChildFragment;
|
12017 | }
|
12018 |
|
12019 | function mountSuspenseFallbackChildren(workInProgress, primaryChildren, fallbackChildren, renderLanes) {
|
12020 | var mode = workInProgress.mode;
|
12021 | var progressedPrimaryFragment = workInProgress.child;
|
12022 | var primaryChildProps = {
|
12023 | mode: 'hidden',
|
12024 | children: primaryChildren
|
12025 | };
|
12026 | var primaryChildFragment;
|
12027 | var fallbackChildFragment;
|
12028 |
|
12029 | if ((mode & ConcurrentMode) === NoMode && progressedPrimaryFragment !== null) {
|
12030 |
|
12031 |
|
12032 | primaryChildFragment = progressedPrimaryFragment;
|
12033 | primaryChildFragment.childLanes = NoLanes;
|
12034 | primaryChildFragment.pendingProps = primaryChildProps;
|
12035 |
|
12036 | if ( workInProgress.mode & ProfileMode) {
|
12037 |
|
12038 |
|
12039 |
|
12040 |
|
12041 | primaryChildFragment.actualDuration = 0;
|
12042 | primaryChildFragment.actualStartTime = -1;
|
12043 | primaryChildFragment.selfBaseDuration = 0;
|
12044 | primaryChildFragment.treeBaseDuration = 0;
|
12045 | }
|
12046 |
|
12047 | fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null);
|
12048 | } else {
|
12049 | primaryChildFragment = mountWorkInProgressOffscreenFiber(primaryChildProps, mode);
|
12050 | fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null);
|
12051 | }
|
12052 |
|
12053 | primaryChildFragment.return = workInProgress;
|
12054 | fallbackChildFragment.return = workInProgress;
|
12055 | primaryChildFragment.sibling = fallbackChildFragment;
|
12056 | workInProgress.child = primaryChildFragment;
|
12057 | return fallbackChildFragment;
|
12058 | }
|
12059 |
|
12060 | function mountWorkInProgressOffscreenFiber(offscreenProps, mode, renderLanes) {
|
12061 |
|
12062 |
|
12063 | return createFiberFromOffscreen(offscreenProps, mode, NoLanes, null);
|
12064 | }
|
12065 |
|
12066 | function updateWorkInProgressOffscreenFiber(current, offscreenProps) {
|
12067 |
|
12068 |
|
12069 | return createWorkInProgress(current, offscreenProps);
|
12070 | }
|
12071 |
|
12072 | function updateSuspensePrimaryChildren(current, workInProgress, primaryChildren, renderLanes) {
|
12073 | var currentPrimaryChildFragment = current.child;
|
12074 | var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
12075 | var primaryChildFragment = updateWorkInProgressOffscreenFiber(currentPrimaryChildFragment, {
|
12076 | mode: 'visible',
|
12077 | children: primaryChildren
|
12078 | });
|
12079 |
|
12080 | if ((workInProgress.mode & ConcurrentMode) === NoMode) {
|
12081 | primaryChildFragment.lanes = renderLanes;
|
12082 | }
|
12083 |
|
12084 | primaryChildFragment.return = workInProgress;
|
12085 | primaryChildFragment.sibling = null;
|
12086 |
|
12087 | if (currentFallbackChildFragment !== null) {
|
12088 |
|
12089 | var deletions = workInProgress.deletions;
|
12090 |
|
12091 | if (deletions === null) {
|
12092 | workInProgress.deletions = [currentFallbackChildFragment];
|
12093 | workInProgress.flags |= ChildDeletion;
|
12094 | } else {
|
12095 | deletions.push(currentFallbackChildFragment);
|
12096 | }
|
12097 | }
|
12098 |
|
12099 | workInProgress.child = primaryChildFragment;
|
12100 | return primaryChildFragment;
|
12101 | }
|
12102 |
|
12103 | function updateSuspenseFallbackChildren(current, workInProgress, primaryChildren, fallbackChildren, renderLanes) {
|
12104 | var mode = workInProgress.mode;
|
12105 | var currentPrimaryChildFragment = current.child;
|
12106 | var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
12107 | var primaryChildProps = {
|
12108 | mode: 'hidden',
|
12109 | children: primaryChildren
|
12110 | };
|
12111 | var primaryChildFragment;
|
12112 |
|
12113 | if (
|
12114 |
|
12115 | (mode & ConcurrentMode) === NoMode &&
|
12116 |
|
12117 |
|
12118 |
|
12119 |
|
12120 |
|
12121 | workInProgress.child !== currentPrimaryChildFragment) {
|
12122 | var progressedPrimaryFragment = workInProgress.child;
|
12123 | primaryChildFragment = progressedPrimaryFragment;
|
12124 | primaryChildFragment.childLanes = NoLanes;
|
12125 | primaryChildFragment.pendingProps = primaryChildProps;
|
12126 |
|
12127 | if ( workInProgress.mode & ProfileMode) {
|
12128 |
|
12129 |
|
12130 |
|
12131 |
|
12132 | primaryChildFragment.actualDuration = 0;
|
12133 | primaryChildFragment.actualStartTime = -1;
|
12134 | primaryChildFragment.selfBaseDuration = currentPrimaryChildFragment.selfBaseDuration;
|
12135 | primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration;
|
12136 | }
|
12137 |
|
12138 |
|
12139 |
|
12140 |
|
12141 | workInProgress.deletions = null;
|
12142 | } else {
|
12143 | primaryChildFragment = updateWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps);
|
12144 |
|
12145 |
|
12146 |
|
12147 |
|
12148 | primaryChildFragment.subtreeFlags = currentPrimaryChildFragment.subtreeFlags & StaticMask;
|
12149 | }
|
12150 |
|
12151 | var fallbackChildFragment;
|
12152 |
|
12153 | if (currentFallbackChildFragment !== null) {
|
12154 | fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, fallbackChildren);
|
12155 | } else {
|
12156 | fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null);
|
12157 |
|
12158 |
|
12159 | fallbackChildFragment.flags |= Placement;
|
12160 | }
|
12161 |
|
12162 | fallbackChildFragment.return = workInProgress;
|
12163 | primaryChildFragment.return = workInProgress;
|
12164 | primaryChildFragment.sibling = fallbackChildFragment;
|
12165 | workInProgress.child = primaryChildFragment;
|
12166 | return fallbackChildFragment;
|
12167 | }
|
12168 |
|
12169 | function retrySuspenseComponentWithoutHydrating(current, workInProgress, renderLanes, recoverableError) {
|
12170 |
|
12171 |
|
12172 |
|
12173 |
|
12174 |
|
12175 |
|
12176 |
|
12177 | if (recoverableError !== null) {
|
12178 | queueHydrationError(recoverableError);
|
12179 | }
|
12180 |
|
12181 |
|
12182 | reconcileChildFibers(workInProgress, current.child, null, renderLanes);
|
12183 |
|
12184 | var nextProps = workInProgress.pendingProps;
|
12185 | var primaryChildren = nextProps.children;
|
12186 | var primaryChildFragment = mountSuspensePrimaryChildren(workInProgress, primaryChildren);
|
12187 |
|
12188 |
|
12189 | primaryChildFragment.flags |= Placement;
|
12190 | workInProgress.memoizedState = null;
|
12191 | return primaryChildFragment;
|
12192 | }
|
12193 |
|
12194 | function mountSuspenseFallbackAfterRetryWithoutHydrating(current, workInProgress, primaryChildren, fallbackChildren, renderLanes) {
|
12195 | var fiberMode = workInProgress.mode;
|
12196 | var primaryChildProps = {
|
12197 | mode: 'visible',
|
12198 | children: primaryChildren
|
12199 | };
|
12200 | var primaryChildFragment = mountWorkInProgressOffscreenFiber(primaryChildProps, fiberMode);
|
12201 | var fallbackChildFragment = createFiberFromFragment(fallbackChildren, fiberMode, renderLanes, null);
|
12202 |
|
12203 |
|
12204 | fallbackChildFragment.flags |= Placement;
|
12205 | primaryChildFragment.return = workInProgress;
|
12206 | fallbackChildFragment.return = workInProgress;
|
12207 | primaryChildFragment.sibling = fallbackChildFragment;
|
12208 | workInProgress.child = primaryChildFragment;
|
12209 |
|
12210 | if ((workInProgress.mode & ConcurrentMode) !== NoMode) {
|
12211 |
|
12212 |
|
12213 | reconcileChildFibers(workInProgress, current.child, null, renderLanes);
|
12214 | }
|
12215 |
|
12216 | return fallbackChildFragment;
|
12217 | }
|
12218 |
|
12219 | function mountDehydratedSuspenseComponent(workInProgress, suspenseInstance, renderLanes) {
|
12220 |
|
12221 |
|
12222 | if ((workInProgress.mode & ConcurrentMode) === NoMode) {
|
12223 | {
|
12224 | error('Cannot hydrate Suspense in legacy mode. Switch from ' + 'ReactDOM.hydrate(element, container) to ' + 'ReactDOMClient.hydrateRoot(container, <App />)' + '.render(element) or remove the Suspense components from ' + 'the server rendered components.');
|
12225 | }
|
12226 |
|
12227 | workInProgress.lanes = laneToLanes(SyncLane);
|
12228 | } else if (isSuspenseInstanceFallback()) {
|
12229 |
|
12230 |
|
12231 |
|
12232 |
|
12233 |
|
12234 |
|
12235 |
|
12236 |
|
12237 |
|
12238 |
|
12239 |
|
12240 | workInProgress.lanes = laneToLanes(DefaultHydrationLane);
|
12241 | } else {
|
12242 |
|
12243 |
|
12244 | workInProgress.lanes = laneToLanes(OffscreenLane);
|
12245 | }
|
12246 |
|
12247 | return null;
|
12248 | }
|
12249 |
|
12250 | function updateDehydratedSuspenseComponent(current, workInProgress, suspenseInstance, suspenseState, renderLanes) {
|
12251 |
|
12252 | if ((workInProgress.mode & ConcurrentMode) === NoMode) {
|
12253 | return retrySuspenseComponentWithoutHydrating(current, workInProgress, renderLanes,
|
12254 |
|
12255 |
|
12256 | null);
|
12257 | }
|
12258 |
|
12259 | if (isSuspenseInstanceFallback()) {
|
12260 |
|
12261 |
|
12262 |
|
12263 | return retrySuspenseComponentWithoutHydrating(current, workInProgress, renderLanes,
|
12264 |
|
12265 |
|
12266 | new Error('The server could not finish this Suspense boundary, likely ' + 'due to an error during server rendering. Switched to ' + 'client rendering.'));
|
12267 | }
|
12268 |
|
12269 |
|
12270 |
|
12271 | var hasContextChanged = includesSomeLane(renderLanes, current.childLanes);
|
12272 |
|
12273 | if (didReceiveUpdate || hasContextChanged) {
|
12274 |
|
12275 |
|
12276 | var root = getWorkInProgressRoot();
|
12277 |
|
12278 | if (root !== null) {
|
12279 | var attemptHydrationAtLane = getBumpedLaneForHydration(root, renderLanes);
|
12280 |
|
12281 | if (attemptHydrationAtLane !== NoLane && attemptHydrationAtLane !== suspenseState.retryLane) {
|
12282 |
|
12283 |
|
12284 |
|
12285 | suspenseState.retryLane = attemptHydrationAtLane;
|
12286 |
|
12287 | var eventTime = NoTimestamp;
|
12288 | scheduleUpdateOnFiber(current, attemptHydrationAtLane, eventTime);
|
12289 | }
|
12290 | }
|
12291 |
|
12292 |
|
12293 |
|
12294 |
|
12295 |
|
12296 |
|
12297 | renderDidSuspendDelayIfPossible();
|
12298 | return retrySuspenseComponentWithoutHydrating(current, workInProgress, renderLanes, new Error('This Suspense boundary received an update before it finished ' + 'hydrating. This caused the boundary to switch to client rendering. ' + 'The usual way to fix this is to wrap the original update ' + 'in startTransition.'));
|
12299 | } else if (isSuspenseInstancePending()) {
|
12300 |
|
12301 |
|
12302 |
|
12303 |
|
12304 |
|
12305 |
|
12306 |
|
12307 |
|
12308 |
|
12309 | workInProgress.flags |= DidCapture;
|
12310 |
|
12311 | workInProgress.child = current.child;
|
12312 |
|
12313 | var retry = retryDehydratedSuspenseBoundary.bind(null, current);
|
12314 | registerSuspenseInstanceRetry();
|
12315 | return null;
|
12316 | } else {
|
12317 |
|
12318 | reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress, suspenseInstance, suspenseState.treeContext);
|
12319 | var nextProps = workInProgress.pendingProps;
|
12320 | var primaryChildren = nextProps.children;
|
12321 | var primaryChildFragment = mountSuspensePrimaryChildren(workInProgress, primaryChildren);
|
12322 |
|
12323 |
|
12324 |
|
12325 |
|
12326 |
|
12327 |
|
12328 | primaryChildFragment.flags |= Hydrating;
|
12329 | return primaryChildFragment;
|
12330 | }
|
12331 | }
|
12332 |
|
12333 | function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) {
|
12334 | fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
|
12335 | var alternate = fiber.alternate;
|
12336 |
|
12337 | if (alternate !== null) {
|
12338 | alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
|
12339 | }
|
12340 |
|
12341 | scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot);
|
12342 | }
|
12343 |
|
12344 | function propagateSuspenseContextChange(workInProgress, firstChild, renderLanes) {
|
12345 |
|
12346 |
|
12347 |
|
12348 | var node = firstChild;
|
12349 |
|
12350 | while (node !== null) {
|
12351 | if (node.tag === SuspenseComponent) {
|
12352 | var state = node.memoizedState;
|
12353 |
|
12354 | if (state !== null) {
|
12355 | scheduleSuspenseWorkOnFiber(node, renderLanes, workInProgress);
|
12356 | }
|
12357 | } else if (node.tag === SuspenseListComponent) {
|
12358 |
|
12359 |
|
12360 |
|
12361 |
|
12362 |
|
12363 | scheduleSuspenseWorkOnFiber(node, renderLanes, workInProgress);
|
12364 | } else if (node.child !== null) {
|
12365 | node.child.return = node;
|
12366 | node = node.child;
|
12367 | continue;
|
12368 | }
|
12369 |
|
12370 | if (node === workInProgress) {
|
12371 | return;
|
12372 | }
|
12373 |
|
12374 | while (node.sibling === null) {
|
12375 | if (node.return === null || node.return === workInProgress) {
|
12376 | return;
|
12377 | }
|
12378 |
|
12379 | node = node.return;
|
12380 | }
|
12381 |
|
12382 | node.sibling.return = node.return;
|
12383 | node = node.sibling;
|
12384 | }
|
12385 | }
|
12386 |
|
12387 | function findLastContentRow(firstChild) {
|
12388 |
|
12389 |
|
12390 |
|
12391 |
|
12392 |
|
12393 |
|
12394 |
|
12395 | var row = firstChild;
|
12396 | var lastContentRow = null;
|
12397 |
|
12398 | while (row !== null) {
|
12399 | var currentRow = row.alternate;
|
12400 |
|
12401 | if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
12402 | lastContentRow = row;
|
12403 | }
|
12404 |
|
12405 | row = row.sibling;
|
12406 | }
|
12407 |
|
12408 | return lastContentRow;
|
12409 | }
|
12410 |
|
12411 | function validateRevealOrder(revealOrder) {
|
12412 | {
|
12413 | if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
|
12414 | didWarnAboutRevealOrder[revealOrder] = true;
|
12415 |
|
12416 | if (typeof revealOrder === 'string') {
|
12417 | switch (revealOrder.toLowerCase()) {
|
12418 | case 'together':
|
12419 | case 'forwards':
|
12420 | case 'backwards':
|
12421 | {
|
12422 | error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
|
12423 |
|
12424 | break;
|
12425 | }
|
12426 |
|
12427 | case 'forward':
|
12428 | case 'backward':
|
12429 | {
|
12430 | error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
|
12431 |
|
12432 | break;
|
12433 | }
|
12434 |
|
12435 | default:
|
12436 | error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
12437 |
|
12438 | break;
|
12439 | }
|
12440 | } else {
|
12441 | error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
12442 | }
|
12443 | }
|
12444 | }
|
12445 | }
|
12446 |
|
12447 | function validateTailOptions(tailMode, revealOrder) {
|
12448 | {
|
12449 | if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
|
12450 | if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
|
12451 | didWarnAboutTailOptions[tailMode] = true;
|
12452 |
|
12453 | error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
|
12454 | } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
|
12455 | didWarnAboutTailOptions[tailMode] = true;
|
12456 |
|
12457 | error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
|
12458 | }
|
12459 | }
|
12460 | }
|
12461 | }
|
12462 |
|
12463 | function validateSuspenseListNestedChild(childSlot, index) {
|
12464 | {
|
12465 | var isAnArray = isArray(childSlot);
|
12466 | var isIterable = !isAnArray && typeof getIteratorFn(childSlot) === 'function';
|
12467 |
|
12468 | if (isAnArray || isIterable) {
|
12469 | var type = isAnArray ? 'array' : 'iterable';
|
12470 |
|
12471 | error('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);
|
12472 |
|
12473 | return false;
|
12474 | }
|
12475 | }
|
12476 |
|
12477 | return true;
|
12478 | }
|
12479 |
|
12480 | function validateSuspenseListChildren(children, revealOrder) {
|
12481 | {
|
12482 | if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
|
12483 | if (isArray(children)) {
|
12484 | for (var i = 0; i < children.length; i++) {
|
12485 | if (!validateSuspenseListNestedChild(children[i], i)) {
|
12486 | return;
|
12487 | }
|
12488 | }
|
12489 | } else {
|
12490 | var iteratorFn = getIteratorFn(children);
|
12491 |
|
12492 | if (typeof iteratorFn === 'function') {
|
12493 | var childrenIterator = iteratorFn.call(children);
|
12494 |
|
12495 | if (childrenIterator) {
|
12496 | var step = childrenIterator.next();
|
12497 | var _i = 0;
|
12498 |
|
12499 | for (; !step.done; step = childrenIterator.next()) {
|
12500 | if (!validateSuspenseListNestedChild(step.value, _i)) {
|
12501 | return;
|
12502 | }
|
12503 |
|
12504 | _i++;
|
12505 | }
|
12506 | }
|
12507 | } else {
|
12508 | error('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);
|
12509 | }
|
12510 | }
|
12511 | }
|
12512 | }
|
12513 | }
|
12514 |
|
12515 | function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode) {
|
12516 | var renderState = workInProgress.memoizedState;
|
12517 |
|
12518 | if (renderState === null) {
|
12519 | workInProgress.memoizedState = {
|
12520 | isBackwards: isBackwards,
|
12521 | rendering: null,
|
12522 | renderingStartTime: 0,
|
12523 | last: lastContentRow,
|
12524 | tail: tail,
|
12525 | tailMode: tailMode
|
12526 | };
|
12527 | } else {
|
12528 |
|
12529 | renderState.isBackwards = isBackwards;
|
12530 | renderState.rendering = null;
|
12531 | renderState.renderingStartTime = 0;
|
12532 | renderState.last = lastContentRow;
|
12533 | renderState.tail = tail;
|
12534 | renderState.tailMode = tailMode;
|
12535 | }
|
12536 | }
|
12537 |
|
12538 |
|
12539 |
|
12540 |
|
12541 |
|
12542 |
|
12543 |
|
12544 |
|
12545 | function updateSuspenseListComponent(current, workInProgress, renderLanes) {
|
12546 | var nextProps = workInProgress.pendingProps;
|
12547 | var revealOrder = nextProps.revealOrder;
|
12548 | var tailMode = nextProps.tail;
|
12549 | var newChildren = nextProps.children;
|
12550 | validateRevealOrder(revealOrder);
|
12551 | validateTailOptions(tailMode, revealOrder);
|
12552 | validateSuspenseListChildren(newChildren, revealOrder);
|
12553 | reconcileChildren(current, workInProgress, newChildren, renderLanes);
|
12554 | var suspenseContext = suspenseStackCursor.current;
|
12555 | var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
12556 |
|
12557 | if (shouldForceFallback) {
|
12558 | suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
12559 | workInProgress.flags |= DidCapture;
|
12560 | } else {
|
12561 | var didSuspendBefore = current !== null && (current.flags & DidCapture) !== NoFlags;
|
12562 |
|
12563 | if (didSuspendBefore) {
|
12564 |
|
12565 |
|
12566 |
|
12567 | propagateSuspenseContextChange(workInProgress, workInProgress.child, renderLanes);
|
12568 | }
|
12569 |
|
12570 | suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
12571 | }
|
12572 |
|
12573 | pushSuspenseContext(workInProgress, suspenseContext);
|
12574 |
|
12575 | if ((workInProgress.mode & ConcurrentMode) === NoMode) {
|
12576 |
|
12577 |
|
12578 | workInProgress.memoizedState = null;
|
12579 | } else {
|
12580 | switch (revealOrder) {
|
12581 | case 'forwards':
|
12582 | {
|
12583 | var lastContentRow = findLastContentRow(workInProgress.child);
|
12584 | var tail;
|
12585 |
|
12586 | if (lastContentRow === null) {
|
12587 |
|
12588 |
|
12589 | tail = workInProgress.child;
|
12590 | workInProgress.child = null;
|
12591 | } else {
|
12592 |
|
12593 |
|
12594 | tail = lastContentRow.sibling;
|
12595 | lastContentRow.sibling = null;
|
12596 | }
|
12597 |
|
12598 | initSuspenseListRenderState(workInProgress, false,
|
12599 | tail, lastContentRow, tailMode);
|
12600 | break;
|
12601 | }
|
12602 |
|
12603 | case 'backwards':
|
12604 | {
|
12605 |
|
12606 |
|
12607 |
|
12608 |
|
12609 | var _tail = null;
|
12610 | var row = workInProgress.child;
|
12611 | workInProgress.child = null;
|
12612 |
|
12613 | while (row !== null) {
|
12614 | var currentRow = row.alternate;
|
12615 |
|
12616 | if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
12617 |
|
12618 | workInProgress.child = row;
|
12619 | break;
|
12620 | }
|
12621 |
|
12622 | var nextRow = row.sibling;
|
12623 | row.sibling = _tail;
|
12624 | _tail = row;
|
12625 | row = nextRow;
|
12626 | }
|
12627 |
|
12628 |
|
12629 | initSuspenseListRenderState(workInProgress, true,
|
12630 | _tail, null,
|
12631 | tailMode);
|
12632 | break;
|
12633 | }
|
12634 |
|
12635 | case 'together':
|
12636 | {
|
12637 | initSuspenseListRenderState(workInProgress, false,
|
12638 | null,
|
12639 | null,
|
12640 | undefined);
|
12641 | break;
|
12642 | }
|
12643 |
|
12644 | default:
|
12645 | {
|
12646 |
|
12647 |
|
12648 | workInProgress.memoizedState = null;
|
12649 | }
|
12650 | }
|
12651 | }
|
12652 |
|
12653 | return workInProgress.child;
|
12654 | }
|
12655 |
|
12656 | function updatePortalComponent(current, workInProgress, renderLanes) {
|
12657 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
12658 | var nextChildren = workInProgress.pendingProps;
|
12659 |
|
12660 | if (current === null) {
|
12661 |
|
12662 |
|
12663 |
|
12664 |
|
12665 |
|
12666 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes);
|
12667 | } else {
|
12668 | reconcileChildren(current, workInProgress, nextChildren, renderLanes);
|
12669 | }
|
12670 |
|
12671 | return workInProgress.child;
|
12672 | }
|
12673 |
|
12674 | var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
|
12675 |
|
12676 | function updateContextProvider(current, workInProgress, renderLanes) {
|
12677 | var providerType = workInProgress.type;
|
12678 | var context = providerType._context;
|
12679 | var newProps = workInProgress.pendingProps;
|
12680 | var oldProps = workInProgress.memoizedProps;
|
12681 | var newValue = newProps.value;
|
12682 |
|
12683 | {
|
12684 | if (!('value' in newProps)) {
|
12685 | if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
|
12686 | hasWarnedAboutUsingNoValuePropOnContextProvider = true;
|
12687 |
|
12688 | error('The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?');
|
12689 | }
|
12690 | }
|
12691 |
|
12692 | var providerPropTypes = workInProgress.type.propTypes;
|
12693 |
|
12694 | if (providerPropTypes) {
|
12695 | checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider');
|
12696 | }
|
12697 | }
|
12698 |
|
12699 | pushProvider(workInProgress, context, newValue);
|
12700 |
|
12701 | {
|
12702 | if (oldProps !== null) {
|
12703 | var oldValue = oldProps.value;
|
12704 |
|
12705 | if (objectIs(oldValue, newValue)) {
|
12706 |
|
12707 | if (oldProps.children === newProps.children && !hasContextChanged()) {
|
12708 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
12709 | }
|
12710 | } else {
|
12711 |
|
12712 |
|
12713 | propagateContextChange(workInProgress, context, renderLanes);
|
12714 | }
|
12715 | }
|
12716 | }
|
12717 |
|
12718 | var newChildren = newProps.children;
|
12719 | reconcileChildren(current, workInProgress, newChildren, renderLanes);
|
12720 | return workInProgress.child;
|
12721 | }
|
12722 |
|
12723 | var hasWarnedAboutUsingContextAsConsumer = false;
|
12724 |
|
12725 | function updateContextConsumer(current, workInProgress, renderLanes) {
|
12726 | var context = workInProgress.type;
|
12727 |
|
12728 |
|
12729 |
|
12730 |
|
12731 |
|
12732 |
|
12733 |
|
12734 | {
|
12735 | if (context._context === undefined) {
|
12736 |
|
12737 |
|
12738 |
|
12739 | if (context !== context.Consumer) {
|
12740 | if (!hasWarnedAboutUsingContextAsConsumer) {
|
12741 | hasWarnedAboutUsingContextAsConsumer = true;
|
12742 |
|
12743 | error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
|
12744 | }
|
12745 | }
|
12746 | } else {
|
12747 | context = context._context;
|
12748 | }
|
12749 | }
|
12750 |
|
12751 | var newProps = workInProgress.pendingProps;
|
12752 | var render = newProps.children;
|
12753 |
|
12754 | {
|
12755 | if (typeof render !== 'function') {
|
12756 | error('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.');
|
12757 | }
|
12758 | }
|
12759 |
|
12760 | prepareToReadContext(workInProgress, renderLanes);
|
12761 | var newValue = readContext(context);
|
12762 |
|
12763 | {
|
12764 | markComponentRenderStarted(workInProgress);
|
12765 | }
|
12766 |
|
12767 | var newChildren;
|
12768 |
|
12769 | {
|
12770 | ReactCurrentOwner$1.current = workInProgress;
|
12771 | setIsRendering(true);
|
12772 | newChildren = render(newValue);
|
12773 | setIsRendering(false);
|
12774 | }
|
12775 |
|
12776 | {
|
12777 | markComponentRenderStopped();
|
12778 | }
|
12779 |
|
12780 |
|
12781 | workInProgress.flags |= PerformedWork;
|
12782 | reconcileChildren(current, workInProgress, newChildren, renderLanes);
|
12783 | return workInProgress.child;
|
12784 | }
|
12785 |
|
12786 | function markWorkInProgressReceivedUpdate() {
|
12787 | didReceiveUpdate = true;
|
12788 | }
|
12789 |
|
12790 | function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
|
12791 | if (current !== null) {
|
12792 |
|
12793 | workInProgress.dependencies = current.dependencies;
|
12794 | }
|
12795 |
|
12796 | {
|
12797 |
|
12798 | stopProfilerTimerIfRunning();
|
12799 | }
|
12800 |
|
12801 | markSkippedUpdateLanes(workInProgress.lanes);
|
12802 |
|
12803 | if (!includesSomeLane(renderLanes, workInProgress.childLanes)) {
|
12804 |
|
12805 |
|
12806 |
|
12807 | {
|
12808 | return null;
|
12809 | }
|
12810 | }
|
12811 |
|
12812 |
|
12813 |
|
12814 | cloneChildFibers(current, workInProgress);
|
12815 | return workInProgress.child;
|
12816 | }
|
12817 |
|
12818 | function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
|
12819 | {
|
12820 | var returnFiber = oldWorkInProgress.return;
|
12821 |
|
12822 | if (returnFiber === null) {
|
12823 |
|
12824 | throw new Error('Cannot swap the root fiber.');
|
12825 | }
|
12826 |
|
12827 |
|
12828 |
|
12829 | current.alternate = null;
|
12830 | oldWorkInProgress.alternate = null;
|
12831 |
|
12832 | newWorkInProgress.index = oldWorkInProgress.index;
|
12833 | newWorkInProgress.sibling = oldWorkInProgress.sibling;
|
12834 | newWorkInProgress.return = oldWorkInProgress.return;
|
12835 | newWorkInProgress.ref = oldWorkInProgress.ref;
|
12836 |
|
12837 | if (oldWorkInProgress === returnFiber.child) {
|
12838 | returnFiber.child = newWorkInProgress;
|
12839 | } else {
|
12840 | var prevSibling = returnFiber.child;
|
12841 |
|
12842 | if (prevSibling === null) {
|
12843 |
|
12844 | throw new Error('Expected parent to have a child.');
|
12845 | }
|
12846 |
|
12847 | while (prevSibling.sibling !== oldWorkInProgress) {
|
12848 | prevSibling = prevSibling.sibling;
|
12849 |
|
12850 | if (prevSibling === null) {
|
12851 |
|
12852 | throw new Error('Expected to find the previous sibling.');
|
12853 | }
|
12854 | }
|
12855 |
|
12856 | prevSibling.sibling = newWorkInProgress;
|
12857 | }
|
12858 |
|
12859 |
|
12860 |
|
12861 | var deletions = returnFiber.deletions;
|
12862 |
|
12863 | if (deletions === null) {
|
12864 | returnFiber.deletions = [current];
|
12865 | returnFiber.flags |= ChildDeletion;
|
12866 | } else {
|
12867 | deletions.push(current);
|
12868 | }
|
12869 |
|
12870 | newWorkInProgress.flags |= Placement;
|
12871 |
|
12872 | return newWorkInProgress;
|
12873 | }
|
12874 | }
|
12875 |
|
12876 | function checkScheduledUpdateOrContext(current, renderLanes) {
|
12877 |
|
12878 |
|
12879 | var updateLanes = current.lanes;
|
12880 |
|
12881 | if (includesSomeLane(updateLanes, renderLanes)) {
|
12882 | return true;
|
12883 | }
|
12884 |
|
12885 | return false;
|
12886 | }
|
12887 |
|
12888 | function attemptEarlyBailoutIfNoScheduledUpdate(current, workInProgress, renderLanes) {
|
12889 |
|
12890 |
|
12891 |
|
12892 | switch (workInProgress.tag) {
|
12893 | case HostRoot:
|
12894 | pushHostRootContext(workInProgress);
|
12895 | var root = workInProgress.stateNode;
|
12896 | break;
|
12897 |
|
12898 | case HostComponent:
|
12899 | pushHostContext(workInProgress);
|
12900 | break;
|
12901 |
|
12902 | case ClassComponent:
|
12903 | {
|
12904 | var Component = workInProgress.type;
|
12905 |
|
12906 | if (isContextProvider(Component)) {
|
12907 | pushContextProvider(workInProgress);
|
12908 | }
|
12909 |
|
12910 | break;
|
12911 | }
|
12912 |
|
12913 | case HostPortal:
|
12914 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
12915 | break;
|
12916 |
|
12917 | case ContextProvider:
|
12918 | {
|
12919 | var newValue = workInProgress.memoizedProps.value;
|
12920 | var context = workInProgress.type._context;
|
12921 | pushProvider(workInProgress, context, newValue);
|
12922 | break;
|
12923 | }
|
12924 |
|
12925 | case Profiler:
|
12926 | {
|
12927 |
|
12928 | var hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes);
|
12929 |
|
12930 | if (hasChildWork) {
|
12931 | workInProgress.flags |= Update;
|
12932 | }
|
12933 |
|
12934 | {
|
12935 |
|
12936 |
|
12937 | var stateNode = workInProgress.stateNode;
|
12938 | stateNode.effectDuration = 0;
|
12939 | stateNode.passiveEffectDuration = 0;
|
12940 | }
|
12941 | }
|
12942 |
|
12943 | break;
|
12944 |
|
12945 | case SuspenseComponent:
|
12946 | {
|
12947 | var state = workInProgress.memoizedState;
|
12948 |
|
12949 | if (state !== null) {
|
12950 | {
|
12951 | if (state.dehydrated !== null) {
|
12952 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
12953 |
|
12954 |
|
12955 |
|
12956 | workInProgress.flags |= DidCapture;
|
12957 |
|
12958 |
|
12959 | return null;
|
12960 | }
|
12961 | }
|
12962 |
|
12963 |
|
12964 |
|
12965 |
|
12966 |
|
12967 | var primaryChildFragment = workInProgress.child;
|
12968 | var primaryChildLanes = primaryChildFragment.childLanes;
|
12969 |
|
12970 | if (includesSomeLane(renderLanes, primaryChildLanes)) {
|
12971 |
|
12972 |
|
12973 | return updateSuspenseComponent(current, workInProgress, renderLanes);
|
12974 | } else {
|
12975 |
|
12976 |
|
12977 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
12978 |
|
12979 |
|
12980 | var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
12981 |
|
12982 | if (child !== null) {
|
12983 |
|
12984 |
|
12985 | return child.sibling;
|
12986 | } else {
|
12987 |
|
12988 |
|
12989 |
|
12990 | return null;
|
12991 | }
|
12992 | }
|
12993 | } else {
|
12994 | pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
12995 | }
|
12996 |
|
12997 | break;
|
12998 | }
|
12999 |
|
13000 | case SuspenseListComponent:
|
13001 | {
|
13002 | var didSuspendBefore = (current.flags & DidCapture) !== NoFlags;
|
13003 |
|
13004 | var _hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes);
|
13005 |
|
13006 | if (didSuspendBefore) {
|
13007 | if (_hasChildWork) {
|
13008 |
|
13009 |
|
13010 |
|
13011 |
|
13012 |
|
13013 | return updateSuspenseListComponent(current, workInProgress, renderLanes);
|
13014 | }
|
13015 |
|
13016 |
|
13017 |
|
13018 |
|
13019 | workInProgress.flags |= DidCapture;
|
13020 | }
|
13021 |
|
13022 |
|
13023 |
|
13024 |
|
13025 | var renderState = workInProgress.memoizedState;
|
13026 |
|
13027 | if (renderState !== null) {
|
13028 |
|
13029 |
|
13030 | renderState.rendering = null;
|
13031 | renderState.tail = null;
|
13032 | renderState.lastEffect = null;
|
13033 | }
|
13034 |
|
13035 | pushSuspenseContext(workInProgress, suspenseStackCursor.current);
|
13036 |
|
13037 | if (_hasChildWork) {
|
13038 | break;
|
13039 | } else {
|
13040 |
|
13041 |
|
13042 |
|
13043 | return null;
|
13044 | }
|
13045 | }
|
13046 |
|
13047 | case OffscreenComponent:
|
13048 | case LegacyHiddenComponent:
|
13049 | {
|
13050 |
|
13051 |
|
13052 |
|
13053 |
|
13054 |
|
13055 |
|
13056 |
|
13057 |
|
13058 | workInProgress.lanes = NoLanes;
|
13059 | return updateOffscreenComponent(current, workInProgress, renderLanes);
|
13060 | }
|
13061 | }
|
13062 |
|
13063 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
|
13064 | }
|
13065 |
|
13066 | function beginWork(current, workInProgress, renderLanes) {
|
13067 | {
|
13068 | if (workInProgress._debugNeedsRemount && current !== null) {
|
13069 |
|
13070 | return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.lanes));
|
13071 | }
|
13072 | }
|
13073 |
|
13074 | if (current !== null) {
|
13075 | var oldProps = current.memoizedProps;
|
13076 | var newProps = workInProgress.pendingProps;
|
13077 |
|
13078 | if (oldProps !== newProps || hasContextChanged() || (
|
13079 | workInProgress.type !== current.type )) {
|
13080 |
|
13081 |
|
13082 | didReceiveUpdate = true;
|
13083 | } else {
|
13084 |
|
13085 |
|
13086 | var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(current, renderLanes);
|
13087 |
|
13088 | if (!hasScheduledUpdateOrContext &&
|
13089 |
|
13090 | (workInProgress.flags & DidCapture) === NoFlags) {
|
13091 |
|
13092 | didReceiveUpdate = false;
|
13093 | return attemptEarlyBailoutIfNoScheduledUpdate(current, workInProgress, renderLanes);
|
13094 | }
|
13095 |
|
13096 | if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
|
13097 |
|
13098 |
|
13099 | didReceiveUpdate = true;
|
13100 | } else {
|
13101 |
|
13102 |
|
13103 |
|
13104 |
|
13105 | didReceiveUpdate = false;
|
13106 | }
|
13107 | }
|
13108 | } else {
|
13109 | didReceiveUpdate = false;
|
13110 | }
|
13111 |
|
13112 |
|
13113 |
|
13114 |
|
13115 |
|
13116 |
|
13117 | workInProgress.lanes = NoLanes;
|
13118 |
|
13119 | switch (workInProgress.tag) {
|
13120 | case IndeterminateComponent:
|
13121 | {
|
13122 | return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderLanes);
|
13123 | }
|
13124 |
|
13125 | case LazyComponent:
|
13126 | {
|
13127 | var elementType = workInProgress.elementType;
|
13128 | return mountLazyComponent(current, workInProgress, elementType, renderLanes);
|
13129 | }
|
13130 |
|
13131 | case FunctionComponent:
|
13132 | {
|
13133 | var Component = workInProgress.type;
|
13134 | var unresolvedProps = workInProgress.pendingProps;
|
13135 | var resolvedProps = workInProgress.elementType === Component ? unresolvedProps : resolveDefaultProps(Component, unresolvedProps);
|
13136 | return updateFunctionComponent(current, workInProgress, Component, resolvedProps, renderLanes);
|
13137 | }
|
13138 |
|
13139 | case ClassComponent:
|
13140 | {
|
13141 | var _Component = workInProgress.type;
|
13142 | var _unresolvedProps = workInProgress.pendingProps;
|
13143 |
|
13144 | var _resolvedProps = workInProgress.elementType === _Component ? _unresolvedProps : resolveDefaultProps(_Component, _unresolvedProps);
|
13145 |
|
13146 | return updateClassComponent(current, workInProgress, _Component, _resolvedProps, renderLanes);
|
13147 | }
|
13148 |
|
13149 | case HostRoot:
|
13150 | return updateHostRoot(current, workInProgress, renderLanes);
|
13151 |
|
13152 | case HostComponent:
|
13153 | return updateHostComponent$1(current, workInProgress, renderLanes);
|
13154 |
|
13155 | case HostText:
|
13156 | return updateHostText$1();
|
13157 |
|
13158 | case SuspenseComponent:
|
13159 | return updateSuspenseComponent(current, workInProgress, renderLanes);
|
13160 |
|
13161 | case HostPortal:
|
13162 | return updatePortalComponent(current, workInProgress, renderLanes);
|
13163 |
|
13164 | case ForwardRef:
|
13165 | {
|
13166 | var type = workInProgress.type;
|
13167 | var _unresolvedProps2 = workInProgress.pendingProps;
|
13168 |
|
13169 | var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
13170 |
|
13171 | return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderLanes);
|
13172 | }
|
13173 |
|
13174 | case Fragment:
|
13175 | return updateFragment(current, workInProgress, renderLanes);
|
13176 |
|
13177 | case Mode:
|
13178 | return updateMode(current, workInProgress, renderLanes);
|
13179 |
|
13180 | case Profiler:
|
13181 | return updateProfiler(current, workInProgress, renderLanes);
|
13182 |
|
13183 | case ContextProvider:
|
13184 | return updateContextProvider(current, workInProgress, renderLanes);
|
13185 |
|
13186 | case ContextConsumer:
|
13187 | return updateContextConsumer(current, workInProgress, renderLanes);
|
13188 |
|
13189 | case MemoComponent:
|
13190 | {
|
13191 | var _type2 = workInProgress.type;
|
13192 | var _unresolvedProps3 = workInProgress.pendingProps;
|
13193 |
|
13194 | var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
|
13195 |
|
13196 | {
|
13197 | if (workInProgress.type !== workInProgress.elementType) {
|
13198 | var outerPropTypes = _type2.propTypes;
|
13199 |
|
13200 | if (outerPropTypes) {
|
13201 | checkPropTypes(outerPropTypes, _resolvedProps3,
|
13202 | 'prop', getComponentNameFromType(_type2));
|
13203 | }
|
13204 | }
|
13205 | }
|
13206 |
|
13207 | _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
|
13208 | return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, renderLanes);
|
13209 | }
|
13210 |
|
13211 | case SimpleMemoComponent:
|
13212 | {
|
13213 | return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, renderLanes);
|
13214 | }
|
13215 |
|
13216 | case IncompleteClassComponent:
|
13217 | {
|
13218 | var _Component2 = workInProgress.type;
|
13219 | var _unresolvedProps4 = workInProgress.pendingProps;
|
13220 |
|
13221 | var _resolvedProps4 = workInProgress.elementType === _Component2 ? _unresolvedProps4 : resolveDefaultProps(_Component2, _unresolvedProps4);
|
13222 |
|
13223 | return mountIncompleteClassComponent(current, workInProgress, _Component2, _resolvedProps4, renderLanes);
|
13224 | }
|
13225 |
|
13226 | case SuspenseListComponent:
|
13227 | {
|
13228 | return updateSuspenseListComponent(current, workInProgress, renderLanes);
|
13229 | }
|
13230 |
|
13231 | case ScopeComponent:
|
13232 | {
|
13233 |
|
13234 | break;
|
13235 | }
|
13236 |
|
13237 | case OffscreenComponent:
|
13238 | {
|
13239 | return updateOffscreenComponent(current, workInProgress, renderLanes);
|
13240 | }
|
13241 | }
|
13242 |
|
13243 | throw new Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in " + 'React. Please file an issue.');
|
13244 | }
|
13245 |
|
13246 | function unwindWork(current, workInProgress, renderLanes) {
|
13247 |
|
13248 |
|
13249 |
|
13250 |
|
13251 | popTreeContext(workInProgress);
|
13252 |
|
13253 | switch (workInProgress.tag) {
|
13254 | case ClassComponent:
|
13255 | {
|
13256 | var Component = workInProgress.type;
|
13257 |
|
13258 | if (isContextProvider(Component)) {
|
13259 | popContext(workInProgress);
|
13260 | }
|
13261 |
|
13262 | var flags = workInProgress.flags;
|
13263 |
|
13264 | if (flags & ShouldCapture) {
|
13265 | workInProgress.flags = flags & ~ShouldCapture | DidCapture;
|
13266 |
|
13267 | if ( (workInProgress.mode & ProfileMode) !== NoMode) {
|
13268 | transferActualDuration(workInProgress);
|
13269 | }
|
13270 |
|
13271 | return workInProgress;
|
13272 | }
|
13273 |
|
13274 | return null;
|
13275 | }
|
13276 |
|
13277 | case HostRoot:
|
13278 | {
|
13279 |
|
13280 | popHostContainer(workInProgress);
|
13281 | popTopLevelContextObject(workInProgress);
|
13282 | resetWorkInProgressVersions();
|
13283 | var _flags = workInProgress.flags;
|
13284 |
|
13285 | if ((_flags & ShouldCapture) !== NoFlags && (_flags & DidCapture) === NoFlags) {
|
13286 |
|
13287 |
|
13288 | workInProgress.flags = _flags & ~ShouldCapture | DidCapture;
|
13289 | return workInProgress;
|
13290 | }
|
13291 |
|
13292 |
|
13293 | return null;
|
13294 | }
|
13295 |
|
13296 | case HostComponent:
|
13297 | {
|
13298 |
|
13299 | popHostContext(workInProgress);
|
13300 | return null;
|
13301 | }
|
13302 |
|
13303 | case SuspenseComponent:
|
13304 | {
|
13305 | popSuspenseContext(workInProgress);
|
13306 |
|
13307 | {
|
13308 | var suspenseState = workInProgress.memoizedState;
|
13309 |
|
13310 | if (suspenseState !== null && suspenseState.dehydrated !== null) {
|
13311 | if (workInProgress.alternate === null) {
|
13312 | throw new Error('Threw in newly mounted dehydrated component. This is likely a bug in ' + 'React. Please file an issue.');
|
13313 | }
|
13314 | }
|
13315 | }
|
13316 |
|
13317 | var _flags2 = workInProgress.flags;
|
13318 |
|
13319 | if (_flags2 & ShouldCapture) {
|
13320 | workInProgress.flags = _flags2 & ~ShouldCapture | DidCapture;
|
13321 |
|
13322 | if ( (workInProgress.mode & ProfileMode) !== NoMode) {
|
13323 | transferActualDuration(workInProgress);
|
13324 | }
|
13325 |
|
13326 | return workInProgress;
|
13327 | }
|
13328 |
|
13329 | return null;
|
13330 | }
|
13331 |
|
13332 | case SuspenseListComponent:
|
13333 | {
|
13334 | popSuspenseContext(workInProgress);
|
13335 |
|
13336 |
|
13337 | return null;
|
13338 | }
|
13339 |
|
13340 | case HostPortal:
|
13341 | popHostContainer(workInProgress);
|
13342 | return null;
|
13343 |
|
13344 | case ContextProvider:
|
13345 | var context = workInProgress.type._context;
|
13346 | popProvider(context, workInProgress);
|
13347 | return null;
|
13348 |
|
13349 | case OffscreenComponent:
|
13350 | case LegacyHiddenComponent:
|
13351 | popRenderLanes(workInProgress);
|
13352 |
|
13353 | return null;
|
13354 |
|
13355 | case CacheComponent:
|
13356 |
|
13357 | return null;
|
13358 |
|
13359 | default:
|
13360 | return null;
|
13361 | }
|
13362 | }
|
13363 |
|
13364 | function unwindInterruptedWork(current, interruptedWork, renderLanes) {
|
13365 |
|
13366 |
|
13367 |
|
13368 |
|
13369 | popTreeContext(interruptedWork);
|
13370 |
|
13371 | switch (interruptedWork.tag) {
|
13372 | case ClassComponent:
|
13373 | {
|
13374 | var childContextTypes = interruptedWork.type.childContextTypes;
|
13375 |
|
13376 | if (childContextTypes !== null && childContextTypes !== undefined) {
|
13377 | popContext(interruptedWork);
|
13378 | }
|
13379 |
|
13380 | break;
|
13381 | }
|
13382 |
|
13383 | case HostRoot:
|
13384 | {
|
13385 |
|
13386 | popHostContainer(interruptedWork);
|
13387 | popTopLevelContextObject(interruptedWork);
|
13388 | resetWorkInProgressVersions();
|
13389 | break;
|
13390 | }
|
13391 |
|
13392 | case HostComponent:
|
13393 | {
|
13394 | popHostContext(interruptedWork);
|
13395 | break;
|
13396 | }
|
13397 |
|
13398 | case HostPortal:
|
13399 | popHostContainer(interruptedWork);
|
13400 | break;
|
13401 |
|
13402 | case SuspenseComponent:
|
13403 | popSuspenseContext(interruptedWork);
|
13404 | break;
|
13405 |
|
13406 | case SuspenseListComponent:
|
13407 | popSuspenseContext(interruptedWork);
|
13408 | break;
|
13409 |
|
13410 | case ContextProvider:
|
13411 | var context = interruptedWork.type._context;
|
13412 | popProvider(context, interruptedWork);
|
13413 | break;
|
13414 |
|
13415 | case OffscreenComponent:
|
13416 | case LegacyHiddenComponent:
|
13417 | popRenderLanes(interruptedWork);
|
13418 |
|
13419 | break;
|
13420 | }
|
13421 | }
|
13422 |
|
13423 | function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
|
13424 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
13425 |
|
13426 | try {
|
13427 | func.apply(context, funcArgs);
|
13428 | } catch (error) {
|
13429 | this.onError(error);
|
13430 | }
|
13431 | }
|
13432 |
|
13433 | var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
|
13434 |
|
13435 | {
|
13436 |
|
13437 |
|
13438 |
|
13439 |
|
13440 |
|
13441 |
|
13442 |
|
13443 |
|
13444 |
|
13445 |
|
13446 |
|
13447 |
|
13448 |
|
13449 |
|
13450 |
|
13451 |
|
13452 |
|
13453 |
|
13454 |
|
13455 |
|
13456 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
13457 | var fakeNode = document.createElement('react');
|
13458 |
|
13459 | invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) {
|
13460 |
|
13461 |
|
13462 |
|
13463 |
|
13464 | if (typeof document === 'undefined' || document === null) {
|
13465 | throw new 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.');
|
13466 | }
|
13467 |
|
13468 | var evt = document.createEvent('Event');
|
13469 | var didCall = false;
|
13470 |
|
13471 |
|
13472 |
|
13473 |
|
13474 |
|
13475 |
|
13476 | var didError = true;
|
13477 |
|
13478 |
|
13479 |
|
13480 | var windowEvent = window.event;
|
13481 |
|
13482 |
|
13483 | var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
|
13484 |
|
13485 | function restoreAfterDispatch() {
|
13486 |
|
13487 |
|
13488 |
|
13489 |
|
13490 | fakeNode.removeEventListener(evtType, callCallback, false);
|
13491 |
|
13492 |
|
13493 |
|
13494 |
|
13495 | if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
|
13496 | window.event = windowEvent;
|
13497 | }
|
13498 | }
|
13499 |
|
13500 |
|
13501 |
|
13502 |
|
13503 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
13504 |
|
13505 | function callCallback() {
|
13506 | didCall = true;
|
13507 | restoreAfterDispatch();
|
13508 | func.apply(context, funcArgs);
|
13509 | didError = false;
|
13510 | }
|
13511 |
|
13512 |
|
13513 |
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 |
|
13519 |
|
13520 |
|
13521 |
|
13522 |
|
13523 | var error;
|
13524 |
|
13525 | var didSetError = false;
|
13526 | var isCrossOriginError = false;
|
13527 |
|
13528 | function handleWindowError(event) {
|
13529 | error = event.error;
|
13530 | didSetError = true;
|
13531 |
|
13532 | if (error === null && event.colno === 0 && event.lineno === 0) {
|
13533 | isCrossOriginError = true;
|
13534 | }
|
13535 |
|
13536 | if (event.defaultPrevented) {
|
13537 |
|
13538 |
|
13539 |
|
13540 | if (error != null && typeof error === 'object') {
|
13541 | try {
|
13542 | error._suppressLogging = true;
|
13543 | } catch (inner) {
|
13544 | }
|
13545 | }
|
13546 | }
|
13547 | }
|
13548 |
|
13549 |
|
13550 | var evtType = "react-" + (name ? name : 'invokeguardedcallback');
|
13551 |
|
13552 | window.addEventListener('error', handleWindowError);
|
13553 | fakeNode.addEventListener(evtType, callCallback, false);
|
13554 |
|
13555 |
|
13556 | evt.initEvent(evtType, false, false);
|
13557 | fakeNode.dispatchEvent(evt);
|
13558 |
|
13559 | if (windowEventDescriptor) {
|
13560 | Object.defineProperty(window, 'event', windowEventDescriptor);
|
13561 | }
|
13562 |
|
13563 | if (didCall && didError) {
|
13564 | if (!didSetError) {
|
13565 |
|
13566 |
|
13567 | 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.');
|
13568 | } else if (isCrossOriginError) {
|
13569 |
|
13570 | error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://reactjs.org/link/crossorigin-error for more information.');
|
13571 | }
|
13572 |
|
13573 | this.onError(error);
|
13574 | }
|
13575 |
|
13576 |
|
13577 | window.removeEventListener('error', handleWindowError);
|
13578 |
|
13579 | if (!didCall) {
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 | restoreAfterDispatch();
|
13585 | return invokeGuardedCallbackProd.apply(this, arguments);
|
13586 | }
|
13587 | };
|
13588 | }
|
13589 | }
|
13590 |
|
13591 | var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
|
13592 |
|
13593 | var hasError = false;
|
13594 | var caughtError = null;
|
13595 | var reporter = {
|
13596 | onError: function (error) {
|
13597 | hasError = true;
|
13598 | caughtError = error;
|
13599 | }
|
13600 | };
|
13601 | |
13602 |
|
13603 |
|
13604 |
|
13605 |
|
13606 |
|
13607 |
|
13608 |
|
13609 |
|
13610 |
|
13611 |
|
13612 |
|
13613 |
|
13614 |
|
13615 | function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
|
13616 | hasError = false;
|
13617 | caughtError = null;
|
13618 | invokeGuardedCallbackImpl$1.apply(reporter, arguments);
|
13619 | }
|
13620 | function hasCaughtError() {
|
13621 | return hasError;
|
13622 | }
|
13623 | function clearCaughtError() {
|
13624 | if (hasError) {
|
13625 | var error = caughtError;
|
13626 | hasError = false;
|
13627 | caughtError = null;
|
13628 | return error;
|
13629 | } else {
|
13630 | throw new Error('clearCaughtError was called but no error was captured. This error ' + 'is likely caused by a bug in React. Please file an issue.');
|
13631 | }
|
13632 | }
|
13633 |
|
13634 | var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
|
13635 |
|
13636 | {
|
13637 | didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
|
13638 | }
|
13639 |
|
13640 |
|
13641 |
|
13642 |
|
13643 | var offscreenSubtreeIsHidden = false;
|
13644 | var offscreenSubtreeWasHidden = false;
|
13645 | var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
|
13646 | var nextEffect = null;
|
13647 |
|
13648 | var inProgressLanes = null;
|
13649 | var inProgressRoot = null;
|
13650 |
|
13651 | function reportUncaughtErrorInDEV(error) {
|
13652 |
|
13653 |
|
13654 |
|
13655 |
|
13656 |
|
13657 | {
|
13658 | invokeGuardedCallback(null, function () {
|
13659 | throw error;
|
13660 | });
|
13661 | clearCaughtError();
|
13662 | }
|
13663 | }
|
13664 |
|
13665 | var callComponentWillUnmountWithTimer = function (current, instance) {
|
13666 | instance.props = current.memoizedProps;
|
13667 | instance.state = current.memoizedState;
|
13668 |
|
13669 | if ( current.mode & ProfileMode) {
|
13670 | try {
|
13671 | startLayoutEffectTimer();
|
13672 | instance.componentWillUnmount();
|
13673 | } finally {
|
13674 | recordLayoutEffectDuration(current);
|
13675 | }
|
13676 | } else {
|
13677 | instance.componentWillUnmount();
|
13678 | }
|
13679 | };
|
13680 |
|
13681 |
|
13682 | function safelyCallCommitHookLayoutEffectListMount(current, nearestMountedAncestor) {
|
13683 | try {
|
13684 | commitHookEffectListMount(Layout, current);
|
13685 | } catch (error) {
|
13686 | reportUncaughtErrorInDEV(error);
|
13687 | captureCommitPhaseError(current, nearestMountedAncestor, error);
|
13688 | }
|
13689 | }
|
13690 |
|
13691 |
|
13692 | function safelyCallComponentWillUnmount(current, nearestMountedAncestor, instance) {
|
13693 | try {
|
13694 | callComponentWillUnmountWithTimer(current, instance);
|
13695 | } catch (error) {
|
13696 | reportUncaughtErrorInDEV(error);
|
13697 | captureCommitPhaseError(current, nearestMountedAncestor, error);
|
13698 | }
|
13699 | }
|
13700 |
|
13701 |
|
13702 | function safelyCallComponentDidMount(current, nearestMountedAncestor, instance) {
|
13703 | try {
|
13704 | instance.componentDidMount();
|
13705 | } catch (error) {
|
13706 | reportUncaughtErrorInDEV(error);
|
13707 | captureCommitPhaseError(current, nearestMountedAncestor, error);
|
13708 | }
|
13709 | }
|
13710 |
|
13711 |
|
13712 | function safelyAttachRef(current, nearestMountedAncestor) {
|
13713 | try {
|
13714 | commitAttachRef(current);
|
13715 | } catch (error) {
|
13716 | reportUncaughtErrorInDEV(error);
|
13717 | captureCommitPhaseError(current, nearestMountedAncestor, error);
|
13718 | }
|
13719 | }
|
13720 |
|
13721 | function safelyDetachRef(current, nearestMountedAncestor) {
|
13722 | var ref = current.ref;
|
13723 |
|
13724 | if (ref !== null) {
|
13725 | if (typeof ref === 'function') {
|
13726 | var retVal;
|
13727 |
|
13728 | try {
|
13729 | if (enableProfilerTimer && enableProfilerCommitHooks && current.mode & ProfileMode) {
|
13730 | try {
|
13731 | startLayoutEffectTimer();
|
13732 | retVal = ref(null);
|
13733 | } finally {
|
13734 | recordLayoutEffectDuration(current);
|
13735 | }
|
13736 | } else {
|
13737 | retVal = ref(null);
|
13738 | }
|
13739 | } catch (error) {
|
13740 | reportUncaughtErrorInDEV(error);
|
13741 | captureCommitPhaseError(current, nearestMountedAncestor, error);
|
13742 | }
|
13743 |
|
13744 | {
|
13745 | if (typeof retVal === 'function') {
|
13746 | error('Unexpected return value from a callback ref in %s. ' + 'A callback ref should not return a function.', getComponentNameFromFiber(current));
|
13747 | }
|
13748 | }
|
13749 | } else {
|
13750 | ref.current = null;
|
13751 | }
|
13752 | }
|
13753 | }
|
13754 |
|
13755 | function safelyCallDestroy(current, nearestMountedAncestor, destroy) {
|
13756 | try {
|
13757 | destroy();
|
13758 | } catch (error) {
|
13759 | reportUncaughtErrorInDEV(error);
|
13760 | captureCommitPhaseError(current, nearestMountedAncestor, error);
|
13761 | }
|
13762 | }
|
13763 |
|
13764 | var focusedInstanceHandle = null;
|
13765 | var shouldFireAfterActiveInstanceBlur = false;
|
13766 | function commitBeforeMutationEffects(root, firstChild) {
|
13767 | focusedInstanceHandle = prepareForCommit(root.containerInfo);
|
13768 | nextEffect = firstChild;
|
13769 | commitBeforeMutationEffects_begin();
|
13770 |
|
13771 | var shouldFire = shouldFireAfterActiveInstanceBlur;
|
13772 | shouldFireAfterActiveInstanceBlur = false;
|
13773 | focusedInstanceHandle = null;
|
13774 | return shouldFire;
|
13775 | }
|
13776 |
|
13777 | function commitBeforeMutationEffects_begin() {
|
13778 | while (nextEffect !== null) {
|
13779 | var fiber = nextEffect;
|
13780 |
|
13781 | var child = fiber.child;
|
13782 |
|
13783 | if ((fiber.subtreeFlags & BeforeMutationMask) !== NoFlags && child !== null) {
|
13784 | ensureCorrectReturnPointer(child, fiber);
|
13785 | nextEffect = child;
|
13786 | } else {
|
13787 | commitBeforeMutationEffects_complete();
|
13788 | }
|
13789 | }
|
13790 | }
|
13791 |
|
13792 | function commitBeforeMutationEffects_complete() {
|
13793 | while (nextEffect !== null) {
|
13794 | var fiber = nextEffect;
|
13795 | setCurrentFiber(fiber);
|
13796 |
|
13797 | try {
|
13798 | commitBeforeMutationEffectsOnFiber(fiber);
|
13799 | } catch (error) {
|
13800 | reportUncaughtErrorInDEV(error);
|
13801 | captureCommitPhaseError(fiber, fiber.return, error);
|
13802 | }
|
13803 |
|
13804 | resetCurrentFiber();
|
13805 | var sibling = fiber.sibling;
|
13806 |
|
13807 | if (sibling !== null) {
|
13808 | ensureCorrectReturnPointer(sibling, fiber.return);
|
13809 | nextEffect = sibling;
|
13810 | return;
|
13811 | }
|
13812 |
|
13813 | nextEffect = fiber.return;
|
13814 | }
|
13815 | }
|
13816 |
|
13817 | function commitBeforeMutationEffectsOnFiber(finishedWork) {
|
13818 | var current = finishedWork.alternate;
|
13819 | var flags = finishedWork.flags;
|
13820 |
|
13821 | if ((flags & Snapshot) !== NoFlags) {
|
13822 | setCurrentFiber(finishedWork);
|
13823 |
|
13824 | switch (finishedWork.tag) {
|
13825 | case FunctionComponent:
|
13826 | case ForwardRef:
|
13827 | case SimpleMemoComponent:
|
13828 | {
|
13829 | break;
|
13830 | }
|
13831 |
|
13832 | case ClassComponent:
|
13833 | {
|
13834 | if (current !== null) {
|
13835 | var prevProps = current.memoizedProps;
|
13836 | var prevState = current.memoizedState;
|
13837 | var instance = finishedWork.stateNode;
|
13838 |
|
13839 |
|
13840 |
|
13841 | {
|
13842 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
13843 | if (instance.props !== finishedWork.memoizedProps) {
|
13844 | error('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.', getComponentNameFromFiber(finishedWork) || 'instance');
|
13845 | }
|
13846 |
|
13847 | if (instance.state !== finishedWork.memoizedState) {
|
13848 | error('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.state`. ' + 'Please file an issue.', getComponentNameFromFiber(finishedWork) || 'instance');
|
13849 | }
|
13850 | }
|
13851 | }
|
13852 |
|
13853 | var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
|
13854 |
|
13855 | {
|
13856 | var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
|
13857 |
|
13858 | if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
|
13859 | didWarnSet.add(finishedWork.type);
|
13860 |
|
13861 | error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentNameFromFiber(finishedWork));
|
13862 | }
|
13863 | }
|
13864 |
|
13865 | instance.__reactInternalSnapshotBeforeUpdate = snapshot;
|
13866 | }
|
13867 |
|
13868 | break;
|
13869 | }
|
13870 |
|
13871 | case HostRoot:
|
13872 | {
|
13873 | {
|
13874 | var root = finishedWork.stateNode;
|
13875 | clearContainer(root.containerInfo);
|
13876 | }
|
13877 |
|
13878 | break;
|
13879 | }
|
13880 |
|
13881 | case HostComponent:
|
13882 | case HostText:
|
13883 | case HostPortal:
|
13884 | case IncompleteClassComponent:
|
13885 |
|
13886 | break;
|
13887 |
|
13888 | default:
|
13889 | {
|
13890 | throw new 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.');
|
13891 | }
|
13892 | }
|
13893 |
|
13894 | resetCurrentFiber();
|
13895 | }
|
13896 | }
|
13897 |
|
13898 | function commitHookEffectListUnmount(flags, finishedWork, nearestMountedAncestor) {
|
13899 | var updateQueue = finishedWork.updateQueue;
|
13900 | var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
13901 |
|
13902 | if (lastEffect !== null) {
|
13903 | var firstEffect = lastEffect.next;
|
13904 | var effect = firstEffect;
|
13905 |
|
13906 | do {
|
13907 | if ((effect.tag & flags) === flags) {
|
13908 |
|
13909 | var destroy = effect.destroy;
|
13910 | effect.destroy = undefined;
|
13911 |
|
13912 | if (destroy !== undefined) {
|
13913 | {
|
13914 | if ((flags & Passive$1) !== NoFlags$1) {
|
13915 | markComponentPassiveEffectUnmountStarted(finishedWork);
|
13916 | } else if ((flags & Layout) !== NoFlags$1) {
|
13917 | markComponentLayoutEffectUnmountStarted(finishedWork);
|
13918 | }
|
13919 | }
|
13920 |
|
13921 | safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy);
|
13922 |
|
13923 | {
|
13924 | if ((flags & Passive$1) !== NoFlags$1) {
|
13925 | markComponentPassiveEffectUnmountStopped();
|
13926 | } else if ((flags & Layout) !== NoFlags$1) {
|
13927 | markComponentLayoutEffectUnmountStopped();
|
13928 | }
|
13929 | }
|
13930 | }
|
13931 | }
|
13932 |
|
13933 | effect = effect.next;
|
13934 | } while (effect !== firstEffect);
|
13935 | }
|
13936 | }
|
13937 |
|
13938 | function commitHookEffectListMount(flags, finishedWork) {
|
13939 | var updateQueue = finishedWork.updateQueue;
|
13940 | var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
13941 |
|
13942 | if (lastEffect !== null) {
|
13943 | var firstEffect = lastEffect.next;
|
13944 | var effect = firstEffect;
|
13945 |
|
13946 | do {
|
13947 | if ((effect.tag & flags) === flags) {
|
13948 | {
|
13949 | if ((flags & Passive$1) !== NoFlags$1) {
|
13950 | markComponentPassiveEffectMountStarted(finishedWork);
|
13951 | } else if ((flags & Layout) !== NoFlags$1) {
|
13952 | markComponentLayoutEffectMountStarted(finishedWork);
|
13953 | }
|
13954 | }
|
13955 |
|
13956 |
|
13957 | var create = effect.create;
|
13958 | effect.destroy = create();
|
13959 |
|
13960 | {
|
13961 | if ((flags & Passive$1) !== NoFlags$1) {
|
13962 | markComponentPassiveEffectMountStopped();
|
13963 | } else if ((flags & Layout) !== NoFlags$1) {
|
13964 | markComponentLayoutEffectMountStopped();
|
13965 | }
|
13966 | }
|
13967 |
|
13968 | {
|
13969 | var destroy = effect.destroy;
|
13970 |
|
13971 | if (destroy !== undefined && typeof destroy !== 'function') {
|
13972 | var hookName = void 0;
|
13973 |
|
13974 | if ((effect.tag & Layout) !== NoFlags) {
|
13975 | hookName = 'useLayoutEffect';
|
13976 | } else if ((effect.tag & Insertion) !== NoFlags) {
|
13977 | hookName = 'useInsertionEffect';
|
13978 | } else {
|
13979 | hookName = 'useEffect';
|
13980 | }
|
13981 |
|
13982 | var addendum = void 0;
|
13983 |
|
13984 | if (destroy === null) {
|
13985 | addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
|
13986 | } else if (typeof destroy.then === 'function') {
|
13987 | addendum = '\n\nIt looks like you wrote ' + hookName + '(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + hookName + '(() => {\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://reactjs.org/link/hooks-data-fetching';
|
13988 | } else {
|
13989 | addendum = ' You returned: ' + destroy;
|
13990 | }
|
13991 |
|
13992 | error('%s must not return anything besides a function, ' + 'which is used for clean-up.%s', hookName, addendum);
|
13993 | }
|
13994 | }
|
13995 | }
|
13996 |
|
13997 | effect = effect.next;
|
13998 | } while (effect !== firstEffect);
|
13999 | }
|
14000 | }
|
14001 |
|
14002 | function commitPassiveEffectDurations(finishedRoot, finishedWork) {
|
14003 | {
|
14004 |
|
14005 | if ((finishedWork.flags & Update) !== NoFlags) {
|
14006 | switch (finishedWork.tag) {
|
14007 | case Profiler:
|
14008 | {
|
14009 | var passiveEffectDuration = finishedWork.stateNode.passiveEffectDuration;
|
14010 | var _finishedWork$memoize = finishedWork.memoizedProps,
|
14011 | id = _finishedWork$memoize.id,
|
14012 | onPostCommit = _finishedWork$memoize.onPostCommit;
|
14013 |
|
14014 |
|
14015 | var commitTime = getCommitTime();
|
14016 | var phase = finishedWork.alternate === null ? 'mount' : 'update';
|
14017 |
|
14018 | {
|
14019 | if (isCurrentUpdateNested()) {
|
14020 | phase = 'nested-update';
|
14021 | }
|
14022 | }
|
14023 |
|
14024 | if (typeof onPostCommit === 'function') {
|
14025 | onPostCommit(id, phase, passiveEffectDuration, commitTime);
|
14026 | }
|
14027 |
|
14028 |
|
14029 |
|
14030 | var parentFiber = finishedWork.return;
|
14031 |
|
14032 | outer: while (parentFiber !== null) {
|
14033 | switch (parentFiber.tag) {
|
14034 | case HostRoot:
|
14035 | var root = parentFiber.stateNode;
|
14036 | root.passiveEffectDuration += passiveEffectDuration;
|
14037 | break outer;
|
14038 |
|
14039 | case Profiler:
|
14040 | var parentStateNode = parentFiber.stateNode;
|
14041 | parentStateNode.passiveEffectDuration += passiveEffectDuration;
|
14042 | break outer;
|
14043 | }
|
14044 |
|
14045 | parentFiber = parentFiber.return;
|
14046 | }
|
14047 |
|
14048 | break;
|
14049 | }
|
14050 | }
|
14051 | }
|
14052 | }
|
14053 | }
|
14054 |
|
14055 | function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committedLanes) {
|
14056 | if ((finishedWork.flags & LayoutMask) !== NoFlags) {
|
14057 | switch (finishedWork.tag) {
|
14058 | case FunctionComponent:
|
14059 | case ForwardRef:
|
14060 | case SimpleMemoComponent:
|
14061 | {
|
14062 | if ( !offscreenSubtreeWasHidden) {
|
14063 |
|
14064 |
|
14065 |
|
14066 |
|
14067 | if ( finishedWork.mode & ProfileMode) {
|
14068 | try {
|
14069 | startLayoutEffectTimer();
|
14070 | commitHookEffectListMount(Layout | HasEffect, finishedWork);
|
14071 | } finally {
|
14072 | recordLayoutEffectDuration(finishedWork);
|
14073 | }
|
14074 | } else {
|
14075 | commitHookEffectListMount(Layout | HasEffect, finishedWork);
|
14076 | }
|
14077 | }
|
14078 |
|
14079 | break;
|
14080 | }
|
14081 |
|
14082 | case ClassComponent:
|
14083 | {
|
14084 | var instance = finishedWork.stateNode;
|
14085 |
|
14086 | if (finishedWork.flags & Update) {
|
14087 | if (!offscreenSubtreeWasHidden) {
|
14088 | if (current === null) {
|
14089 |
|
14090 |
|
14091 |
|
14092 | {
|
14093 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
14094 | if (instance.props !== finishedWork.memoizedProps) {
|
14095 | error('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.', getComponentNameFromFiber(finishedWork) || 'instance');
|
14096 | }
|
14097 |
|
14098 | if (instance.state !== finishedWork.memoizedState) {
|
14099 | error('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.state`. ' + 'Please file an issue.', getComponentNameFromFiber(finishedWork) || 'instance');
|
14100 | }
|
14101 | }
|
14102 | }
|
14103 |
|
14104 | if ( finishedWork.mode & ProfileMode) {
|
14105 | try {
|
14106 | startLayoutEffectTimer();
|
14107 | instance.componentDidMount();
|
14108 | } finally {
|
14109 | recordLayoutEffectDuration(finishedWork);
|
14110 | }
|
14111 | } else {
|
14112 | instance.componentDidMount();
|
14113 | }
|
14114 | } else {
|
14115 | var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps);
|
14116 | var prevState = current.memoizedState;
|
14117 |
|
14118 |
|
14119 |
|
14120 | {
|
14121 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
14122 | if (instance.props !== finishedWork.memoizedProps) {
|
14123 | error('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.', getComponentNameFromFiber(finishedWork) || 'instance');
|
14124 | }
|
14125 |
|
14126 | if (instance.state !== finishedWork.memoizedState) {
|
14127 | error('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.state`. ' + 'Please file an issue.', getComponentNameFromFiber(finishedWork) || 'instance');
|
14128 | }
|
14129 | }
|
14130 | }
|
14131 |
|
14132 | if ( finishedWork.mode & ProfileMode) {
|
14133 | try {
|
14134 | startLayoutEffectTimer();
|
14135 | instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
14136 | } finally {
|
14137 | recordLayoutEffectDuration(finishedWork);
|
14138 | }
|
14139 | } else {
|
14140 | instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
14141 | }
|
14142 | }
|
14143 | }
|
14144 | }
|
14145 |
|
14146 |
|
14147 |
|
14148 | var updateQueue = finishedWork.updateQueue;
|
14149 |
|
14150 | if (updateQueue !== null) {
|
14151 | {
|
14152 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
14153 | if (instance.props !== finishedWork.memoizedProps) {
|
14154 | error('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.', getComponentNameFromFiber(finishedWork) || 'instance');
|
14155 | }
|
14156 |
|
14157 | if (instance.state !== finishedWork.memoizedState) {
|
14158 | error('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.state`. ' + 'Please file an issue.', getComponentNameFromFiber(finishedWork) || 'instance');
|
14159 | }
|
14160 | }
|
14161 | }
|
14162 |
|
14163 |
|
14164 |
|
14165 |
|
14166 | commitUpdateQueue(finishedWork, updateQueue, instance);
|
14167 | }
|
14168 |
|
14169 | break;
|
14170 | }
|
14171 |
|
14172 | case HostRoot:
|
14173 | {
|
14174 |
|
14175 |
|
14176 | var _updateQueue = finishedWork.updateQueue;
|
14177 |
|
14178 | if (_updateQueue !== null) {
|
14179 | var _instance = null;
|
14180 |
|
14181 | if (finishedWork.child !== null) {
|
14182 | switch (finishedWork.child.tag) {
|
14183 | case HostComponent:
|
14184 | _instance = getPublicInstance(finishedWork.child.stateNode);
|
14185 | break;
|
14186 |
|
14187 | case ClassComponent:
|
14188 | _instance = finishedWork.child.stateNode;
|
14189 | break;
|
14190 | }
|
14191 | }
|
14192 |
|
14193 | commitUpdateQueue(finishedWork, _updateQueue, _instance);
|
14194 | }
|
14195 |
|
14196 | break;
|
14197 | }
|
14198 |
|
14199 | case HostComponent:
|
14200 | {
|
14201 | var _instance2 = finishedWork.stateNode;
|
14202 |
|
14203 |
|
14204 |
|
14205 |
|
14206 | if (current === null && finishedWork.flags & Update) {
|
14207 | var type = finishedWork.type;
|
14208 | var props = finishedWork.memoizedProps;
|
14209 | }
|
14210 |
|
14211 | break;
|
14212 | }
|
14213 |
|
14214 | case HostText:
|
14215 | {
|
14216 |
|
14217 | break;
|
14218 | }
|
14219 |
|
14220 | case HostPortal:
|
14221 | {
|
14222 |
|
14223 | break;
|
14224 | }
|
14225 |
|
14226 | case Profiler:
|
14227 | {
|
14228 | {
|
14229 | var _finishedWork$memoize2 = finishedWork.memoizedProps,
|
14230 | onCommit = _finishedWork$memoize2.onCommit,
|
14231 | onRender = _finishedWork$memoize2.onRender;
|
14232 | var effectDuration = finishedWork.stateNode.effectDuration;
|
14233 | var commitTime = getCommitTime();
|
14234 | var phase = current === null ? 'mount' : 'update';
|
14235 |
|
14236 | {
|
14237 | if (isCurrentUpdateNested()) {
|
14238 | phase = 'nested-update';
|
14239 | }
|
14240 | }
|
14241 |
|
14242 | if (typeof onRender === 'function') {
|
14243 | onRender(finishedWork.memoizedProps.id, phase, finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, commitTime);
|
14244 | }
|
14245 |
|
14246 | {
|
14247 | if (typeof onCommit === 'function') {
|
14248 | onCommit(finishedWork.memoizedProps.id, phase, effectDuration, commitTime);
|
14249 | }
|
14250 |
|
14251 |
|
14252 |
|
14253 |
|
14254 | enqueuePendingPassiveProfilerEffect(finishedWork);
|
14255 |
|
14256 |
|
14257 | var parentFiber = finishedWork.return;
|
14258 |
|
14259 | outer: while (parentFiber !== null) {
|
14260 | switch (parentFiber.tag) {
|
14261 | case HostRoot:
|
14262 | var root = parentFiber.stateNode;
|
14263 | root.effectDuration += effectDuration;
|
14264 | break outer;
|
14265 |
|
14266 | case Profiler:
|
14267 | var parentStateNode = parentFiber.stateNode;
|
14268 | parentStateNode.effectDuration += effectDuration;
|
14269 | break outer;
|
14270 | }
|
14271 |
|
14272 | parentFiber = parentFiber.return;
|
14273 | }
|
14274 | }
|
14275 | }
|
14276 |
|
14277 | break;
|
14278 | }
|
14279 |
|
14280 | case SuspenseComponent:
|
14281 | {
|
14282 | break;
|
14283 | }
|
14284 |
|
14285 | case SuspenseListComponent:
|
14286 | case IncompleteClassComponent:
|
14287 | case ScopeComponent:
|
14288 | case OffscreenComponent:
|
14289 | case LegacyHiddenComponent:
|
14290 | {
|
14291 | break;
|
14292 | }
|
14293 |
|
14294 | default:
|
14295 | throw new 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.');
|
14296 | }
|
14297 | }
|
14298 |
|
14299 | if ( !offscreenSubtreeWasHidden) {
|
14300 | {
|
14301 | if (finishedWork.flags & Ref) {
|
14302 | commitAttachRef(finishedWork);
|
14303 | }
|
14304 | }
|
14305 | }
|
14306 | }
|
14307 |
|
14308 | function reappearLayoutEffectsOnFiber(node) {
|
14309 |
|
14310 |
|
14311 | switch (node.tag) {
|
14312 | case FunctionComponent:
|
14313 | case ForwardRef:
|
14314 | case SimpleMemoComponent:
|
14315 | {
|
14316 | if ( node.mode & ProfileMode) {
|
14317 | try {
|
14318 | startLayoutEffectTimer();
|
14319 | safelyCallCommitHookLayoutEffectListMount(node, node.return);
|
14320 | } finally {
|
14321 | recordLayoutEffectDuration(node);
|
14322 | }
|
14323 | } else {
|
14324 | safelyCallCommitHookLayoutEffectListMount(node, node.return);
|
14325 | }
|
14326 |
|
14327 | break;
|
14328 | }
|
14329 |
|
14330 | case ClassComponent:
|
14331 | {
|
14332 | var instance = node.stateNode;
|
14333 |
|
14334 | if (typeof instance.componentDidMount === 'function') {
|
14335 | safelyCallComponentDidMount(node, node.return, instance);
|
14336 | }
|
14337 |
|
14338 | safelyAttachRef(node, node.return);
|
14339 | break;
|
14340 | }
|
14341 |
|
14342 | case HostComponent:
|
14343 | {
|
14344 | safelyAttachRef(node, node.return);
|
14345 | break;
|
14346 | }
|
14347 | }
|
14348 | }
|
14349 |
|
14350 | function hideOrUnhideAllChildren(finishedWork, isHidden) {
|
14351 |
|
14352 | var hostSubtreeRoot = null;
|
14353 |
|
14354 | {
|
14355 |
|
14356 |
|
14357 | var node = finishedWork;
|
14358 |
|
14359 | while (true) {
|
14360 | if (node.tag === HostComponent) {
|
14361 | if (hostSubtreeRoot === null) {
|
14362 | hostSubtreeRoot = node;
|
14363 | var instance = node.stateNode;
|
14364 |
|
14365 | if (isHidden) {
|
14366 | hideInstance(instance);
|
14367 | } else {
|
14368 | unhideInstance(node.stateNode, node.memoizedProps);
|
14369 | }
|
14370 | }
|
14371 | } else if (node.tag === HostText) {
|
14372 | if (hostSubtreeRoot === null) {
|
14373 | var _instance3 = node.stateNode;
|
14374 |
|
14375 | if (isHidden) ; else {
|
14376 | unhideTextInstance(_instance3, node.memoizedProps);
|
14377 | }
|
14378 | }
|
14379 | } else if ((node.tag === OffscreenComponent || node.tag === LegacyHiddenComponent) && node.memoizedState !== null && node !== finishedWork) ; else if (node.child !== null) {
|
14380 | node.child.return = node;
|
14381 | node = node.child;
|
14382 | continue;
|
14383 | }
|
14384 |
|
14385 | if (node === finishedWork) {
|
14386 | return;
|
14387 | }
|
14388 |
|
14389 | while (node.sibling === null) {
|
14390 | if (node.return === null || node.return === finishedWork) {
|
14391 | return;
|
14392 | }
|
14393 |
|
14394 | if (hostSubtreeRoot === node) {
|
14395 | hostSubtreeRoot = null;
|
14396 | }
|
14397 |
|
14398 | node = node.return;
|
14399 | }
|
14400 |
|
14401 | if (hostSubtreeRoot === node) {
|
14402 | hostSubtreeRoot = null;
|
14403 | }
|
14404 |
|
14405 | node.sibling.return = node.return;
|
14406 | node = node.sibling;
|
14407 | }
|
14408 | }
|
14409 | }
|
14410 |
|
14411 | function commitAttachRef(finishedWork) {
|
14412 | var ref = finishedWork.ref;
|
14413 |
|
14414 | if (ref !== null) {
|
14415 | var instance = finishedWork.stateNode;
|
14416 | var instanceToUse;
|
14417 |
|
14418 | switch (finishedWork.tag) {
|
14419 | case HostComponent:
|
14420 | instanceToUse = getPublicInstance(instance);
|
14421 | break;
|
14422 |
|
14423 | default:
|
14424 | instanceToUse = instance;
|
14425 | }
|
14426 |
|
14427 | if (typeof ref === 'function') {
|
14428 | var retVal;
|
14429 |
|
14430 | if ( finishedWork.mode & ProfileMode) {
|
14431 | try {
|
14432 | startLayoutEffectTimer();
|
14433 | retVal = ref(instanceToUse);
|
14434 | } finally {
|
14435 | recordLayoutEffectDuration(finishedWork);
|
14436 | }
|
14437 | } else {
|
14438 | retVal = ref(instanceToUse);
|
14439 | }
|
14440 |
|
14441 | {
|
14442 | if (typeof retVal === 'function') {
|
14443 | error('Unexpected return value from a callback ref in %s. ' + 'A callback ref should not return a function.', getComponentNameFromFiber(finishedWork));
|
14444 | }
|
14445 | }
|
14446 | } else {
|
14447 | {
|
14448 | if (!ref.hasOwnProperty('current')) {
|
14449 | error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().', getComponentNameFromFiber(finishedWork));
|
14450 | }
|
14451 | }
|
14452 |
|
14453 | ref.current = instanceToUse;
|
14454 | }
|
14455 | }
|
14456 | }
|
14457 |
|
14458 | function commitDetachRef(current) {
|
14459 | var currentRef = current.ref;
|
14460 |
|
14461 | if (currentRef !== null) {
|
14462 | if (typeof currentRef === 'function') {
|
14463 | if ( current.mode & ProfileMode) {
|
14464 | try {
|
14465 | startLayoutEffectTimer();
|
14466 | currentRef(null);
|
14467 | } finally {
|
14468 | recordLayoutEffectDuration(current);
|
14469 | }
|
14470 | } else {
|
14471 | currentRef(null);
|
14472 | }
|
14473 | } else {
|
14474 | currentRef.current = null;
|
14475 | }
|
14476 | }
|
14477 | }
|
14478 |
|
14479 |
|
14480 |
|
14481 |
|
14482 | function commitUnmount(finishedRoot, current, nearestMountedAncestor) {
|
14483 | onCommitUnmount(current);
|
14484 |
|
14485 | switch (current.tag) {
|
14486 | case FunctionComponent:
|
14487 | case ForwardRef:
|
14488 | case MemoComponent:
|
14489 | case SimpleMemoComponent:
|
14490 | {
|
14491 | var updateQueue = current.updateQueue;
|
14492 |
|
14493 | if (updateQueue !== null) {
|
14494 | var lastEffect = updateQueue.lastEffect;
|
14495 |
|
14496 | if (lastEffect !== null) {
|
14497 | var firstEffect = lastEffect.next;
|
14498 | var effect = firstEffect;
|
14499 |
|
14500 | do {
|
14501 | var _effect = effect,
|
14502 | destroy = _effect.destroy,
|
14503 | tag = _effect.tag;
|
14504 |
|
14505 | if (destroy !== undefined) {
|
14506 | if ((tag & Insertion) !== NoFlags$1) {
|
14507 | safelyCallDestroy(current, nearestMountedAncestor, destroy);
|
14508 | } else if ((tag & Layout) !== NoFlags$1) {
|
14509 | {
|
14510 | markComponentLayoutEffectUnmountStarted(current);
|
14511 | }
|
14512 |
|
14513 | if ( current.mode & ProfileMode) {
|
14514 | startLayoutEffectTimer();
|
14515 | safelyCallDestroy(current, nearestMountedAncestor, destroy);
|
14516 | recordLayoutEffectDuration(current);
|
14517 | } else {
|
14518 | safelyCallDestroy(current, nearestMountedAncestor, destroy);
|
14519 | }
|
14520 |
|
14521 | {
|
14522 | markComponentLayoutEffectUnmountStopped();
|
14523 | }
|
14524 | }
|
14525 | }
|
14526 |
|
14527 | effect = effect.next;
|
14528 | } while (effect !== firstEffect);
|
14529 | }
|
14530 | }
|
14531 |
|
14532 | return;
|
14533 | }
|
14534 |
|
14535 | case ClassComponent:
|
14536 | {
|
14537 | safelyDetachRef(current, nearestMountedAncestor);
|
14538 | var instance = current.stateNode;
|
14539 |
|
14540 | if (typeof instance.componentWillUnmount === 'function') {
|
14541 | safelyCallComponentWillUnmount(current, nearestMountedAncestor, instance);
|
14542 | }
|
14543 |
|
14544 | return;
|
14545 | }
|
14546 |
|
14547 | case HostComponent:
|
14548 | {
|
14549 | safelyDetachRef(current, nearestMountedAncestor);
|
14550 | return;
|
14551 | }
|
14552 |
|
14553 | case HostPortal:
|
14554 | {
|
14555 |
|
14556 |
|
14557 |
|
14558 | {
|
14559 | unmountHostComponents(finishedRoot, current, nearestMountedAncestor);
|
14560 | }
|
14561 |
|
14562 | return;
|
14563 | }
|
14564 |
|
14565 | case DehydratedFragment:
|
14566 | {
|
14567 |
|
14568 | return;
|
14569 | }
|
14570 |
|
14571 | case ScopeComponent:
|
14572 | {
|
14573 |
|
14574 | return;
|
14575 | }
|
14576 | }
|
14577 | }
|
14578 |
|
14579 | function commitNestedUnmounts(finishedRoot, root, nearestMountedAncestor) {
|
14580 |
|
14581 |
|
14582 |
|
14583 |
|
14584 |
|
14585 | var node = root;
|
14586 |
|
14587 | while (true) {
|
14588 | commitUnmount(finishedRoot, node, nearestMountedAncestor);
|
14589 |
|
14590 |
|
14591 | if (node.child !== null && (
|
14592 |
|
14593 | node.tag !== HostPortal)) {
|
14594 | node.child.return = node;
|
14595 | node = node.child;
|
14596 | continue;
|
14597 | }
|
14598 |
|
14599 | if (node === root) {
|
14600 | return;
|
14601 | }
|
14602 |
|
14603 | while (node.sibling === null) {
|
14604 | if (node.return === null || node.return === root) {
|
14605 | return;
|
14606 | }
|
14607 |
|
14608 | node = node.return;
|
14609 | }
|
14610 |
|
14611 | node.sibling.return = node.return;
|
14612 | node = node.sibling;
|
14613 | }
|
14614 | }
|
14615 |
|
14616 | function detachFiberMutation(fiber) {
|
14617 |
|
14618 |
|
14619 |
|
14620 |
|
14621 |
|
14622 |
|
14623 |
|
14624 |
|
14625 |
|
14626 |
|
14627 |
|
14628 |
|
14629 |
|
14630 |
|
14631 |
|
14632 |
|
14633 | var alternate = fiber.alternate;
|
14634 |
|
14635 | if (alternate !== null) {
|
14636 | alternate.return = null;
|
14637 | }
|
14638 |
|
14639 | fiber.return = null;
|
14640 | }
|
14641 |
|
14642 | function detachFiberAfterEffects(fiber) {
|
14643 | var alternate = fiber.alternate;
|
14644 |
|
14645 | if (alternate !== null) {
|
14646 | fiber.alternate = null;
|
14647 | detachFiberAfterEffects(alternate);
|
14648 | }
|
14649 |
|
14650 |
|
14651 |
|
14652 | {
|
14653 |
|
14654 |
|
14655 |
|
14656 |
|
14657 |
|
14658 |
|
14659 | fiber.child = null;
|
14660 | fiber.deletions = null;
|
14661 | fiber.sibling = null;
|
14662 |
|
14663 |
|
14664 |
|
14665 |
|
14666 | if (fiber.tag === HostComponent) {
|
14667 | var hostInstance = fiber.stateNode;
|
14668 | }
|
14669 |
|
14670 | fiber.stateNode = null;
|
14671 |
|
14672 |
|
14673 |
|
14674 |
|
14675 |
|
14676 | {
|
14677 | fiber._debugOwner = null;
|
14678 | }
|
14679 |
|
14680 | {
|
14681 |
|
14682 |
|
14683 |
|
14684 |
|
14685 |
|
14686 |
|
14687 |
|
14688 | fiber.return = null;
|
14689 | fiber.dependencies = null;
|
14690 | fiber.memoizedProps = null;
|
14691 | fiber.memoizedState = null;
|
14692 | fiber.pendingProps = null;
|
14693 | fiber.stateNode = null;
|
14694 |
|
14695 | fiber.updateQueue = null;
|
14696 | }
|
14697 | }
|
14698 | }
|
14699 |
|
14700 | function getHostParentFiber(fiber) {
|
14701 | var parent = fiber.return;
|
14702 |
|
14703 | while (parent !== null) {
|
14704 | if (isHostParent(parent)) {
|
14705 | return parent;
|
14706 | }
|
14707 |
|
14708 | parent = parent.return;
|
14709 | }
|
14710 |
|
14711 | throw new Error('Expected to find a host parent. This error is likely caused by a bug ' + 'in React. Please file an issue.');
|
14712 | }
|
14713 |
|
14714 | function isHostParent(fiber) {
|
14715 | return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
|
14716 | }
|
14717 |
|
14718 | function getHostSibling(fiber) {
|
14719 |
|
14720 |
|
14721 |
|
14722 |
|
14723 | var node = fiber;
|
14724 |
|
14725 | siblings: while (true) {
|
14726 |
|
14727 | while (node.sibling === null) {
|
14728 | if (node.return === null || isHostParent(node.return)) {
|
14729 |
|
14730 |
|
14731 | return null;
|
14732 | }
|
14733 |
|
14734 | node = node.return;
|
14735 | }
|
14736 |
|
14737 | node.sibling.return = node.return;
|
14738 | node = node.sibling;
|
14739 |
|
14740 | while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
|
14741 |
|
14742 |
|
14743 | if (node.flags & Placement) {
|
14744 |
|
14745 | continue siblings;
|
14746 | }
|
14747 |
|
14748 |
|
14749 |
|
14750 | if (node.child === null || node.tag === HostPortal) {
|
14751 | continue siblings;
|
14752 | } else {
|
14753 | node.child.return = node;
|
14754 | node = node.child;
|
14755 | }
|
14756 | }
|
14757 |
|
14758 |
|
14759 | if (!(node.flags & Placement)) {
|
14760 |
|
14761 | return node.stateNode;
|
14762 | }
|
14763 | }
|
14764 | }
|
14765 |
|
14766 | function commitPlacement(finishedWork) {
|
14767 |
|
14768 |
|
14769 | var parentFiber = getHostParentFiber(finishedWork);
|
14770 |
|
14771 | switch (parentFiber.tag) {
|
14772 | case HostComponent:
|
14773 | {
|
14774 | var parent = parentFiber.stateNode;
|
14775 |
|
14776 | if (parentFiber.flags & ContentReset) {
|
14777 |
|
14778 | parentFiber.flags &= ~ContentReset;
|
14779 | }
|
14780 |
|
14781 | var before = getHostSibling(finishedWork);
|
14782 |
|
14783 |
|
14784 | insertOrAppendPlacementNode(finishedWork, before, parent);
|
14785 | break;
|
14786 | }
|
14787 |
|
14788 | case HostRoot:
|
14789 | case HostPortal:
|
14790 | {
|
14791 | var _parent = parentFiber.stateNode.containerInfo;
|
14792 |
|
14793 | var _before = getHostSibling(finishedWork);
|
14794 |
|
14795 | insertOrAppendPlacementNodeIntoContainer(finishedWork, _before, _parent);
|
14796 | break;
|
14797 | }
|
14798 |
|
14799 |
|
14800 | default:
|
14801 | throw new Error('Invalid host parent fiber. This error is likely caused by a bug ' + 'in React. Please file an issue.');
|
14802 | }
|
14803 | }
|
14804 |
|
14805 | function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
|
14806 | var tag = node.tag;
|
14807 | var isHost = tag === HostComponent || tag === HostText;
|
14808 |
|
14809 | if (isHost) {
|
14810 | var stateNode = node.stateNode;
|
14811 |
|
14812 | if (before) {
|
14813 | insertInContainerBefore(parent, stateNode, before);
|
14814 | } else {
|
14815 | appendChildToContainer(parent, stateNode);
|
14816 | }
|
14817 | } else if (tag === HostPortal) ; else {
|
14818 | var child = node.child;
|
14819 |
|
14820 | if (child !== null) {
|
14821 | insertOrAppendPlacementNodeIntoContainer(child, before, parent);
|
14822 | var sibling = child.sibling;
|
14823 |
|
14824 | while (sibling !== null) {
|
14825 | insertOrAppendPlacementNodeIntoContainer(sibling, before, parent);
|
14826 | sibling = sibling.sibling;
|
14827 | }
|
14828 | }
|
14829 | }
|
14830 | }
|
14831 |
|
14832 | function insertOrAppendPlacementNode(node, before, parent) {
|
14833 | var tag = node.tag;
|
14834 | var isHost = tag === HostComponent || tag === HostText;
|
14835 |
|
14836 | if (isHost) {
|
14837 | var stateNode = node.stateNode;
|
14838 |
|
14839 | if (before) {
|
14840 | insertBefore(parent, stateNode, before);
|
14841 | } else {
|
14842 | appendChild(parent, stateNode);
|
14843 | }
|
14844 | } else if (tag === HostPortal) ; else {
|
14845 | var child = node.child;
|
14846 |
|
14847 | if (child !== null) {
|
14848 | insertOrAppendPlacementNode(child, before, parent);
|
14849 | var sibling = child.sibling;
|
14850 |
|
14851 | while (sibling !== null) {
|
14852 | insertOrAppendPlacementNode(sibling, before, parent);
|
14853 | sibling = sibling.sibling;
|
14854 | }
|
14855 | }
|
14856 | }
|
14857 | }
|
14858 |
|
14859 | function unmountHostComponents(finishedRoot, current, nearestMountedAncestor) {
|
14860 |
|
14861 |
|
14862 | var node = current;
|
14863 |
|
14864 |
|
14865 | var currentParentIsValid = false;
|
14866 |
|
14867 | var currentParent;
|
14868 | var currentParentIsContainer;
|
14869 |
|
14870 | while (true) {
|
14871 | if (!currentParentIsValid) {
|
14872 | var parent = node.return;
|
14873 |
|
14874 | findParent: while (true) {
|
14875 | if (parent === null) {
|
14876 | throw new Error('Expected to find a host parent. This error is likely caused by ' + 'a bug in React. Please file an issue.');
|
14877 | }
|
14878 |
|
14879 | var parentStateNode = parent.stateNode;
|
14880 |
|
14881 | switch (parent.tag) {
|
14882 | case HostComponent:
|
14883 | currentParent = parentStateNode;
|
14884 | currentParentIsContainer = false;
|
14885 | break findParent;
|
14886 |
|
14887 | case HostRoot:
|
14888 | currentParent = parentStateNode.containerInfo;
|
14889 | currentParentIsContainer = true;
|
14890 | break findParent;
|
14891 |
|
14892 | case HostPortal:
|
14893 | currentParent = parentStateNode.containerInfo;
|
14894 | currentParentIsContainer = true;
|
14895 | break findParent;
|
14896 | }
|
14897 |
|
14898 | parent = parent.return;
|
14899 | }
|
14900 |
|
14901 | currentParentIsValid = true;
|
14902 | }
|
14903 |
|
14904 | if (node.tag === HostComponent || node.tag === HostText) {
|
14905 | commitNestedUnmounts(finishedRoot, node, nearestMountedAncestor);
|
14906 |
|
14907 |
|
14908 | if (currentParentIsContainer) {
|
14909 | removeChildFromContainer(currentParent, node.stateNode);
|
14910 | } else {
|
14911 | removeChild(currentParent, node.stateNode);
|
14912 | }
|
14913 |
|
14914 | } else if ( node.tag === DehydratedFragment) {
|
14915 |
|
14916 |
|
14917 | if (currentParentIsContainer) {
|
14918 | clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
|
14919 | } else {
|
14920 | clearSuspenseBoundary(currentParent, node.stateNode);
|
14921 | }
|
14922 | } else if (node.tag === HostPortal) {
|
14923 | if (node.child !== null) {
|
14924 |
|
14925 |
|
14926 | currentParent = node.stateNode.containerInfo;
|
14927 | currentParentIsContainer = true;
|
14928 |
|
14929 | node.child.return = node;
|
14930 | node = node.child;
|
14931 | continue;
|
14932 | }
|
14933 | } else {
|
14934 | commitUnmount(finishedRoot, node, nearestMountedAncestor);
|
14935 |
|
14936 | if (node.child !== null) {
|
14937 | node.child.return = node;
|
14938 | node = node.child;
|
14939 | continue;
|
14940 | }
|
14941 | }
|
14942 |
|
14943 | if (node === current) {
|
14944 | return;
|
14945 | }
|
14946 |
|
14947 | while (node.sibling === null) {
|
14948 | if (node.return === null || node.return === current) {
|
14949 | return;
|
14950 | }
|
14951 |
|
14952 | node = node.return;
|
14953 |
|
14954 | if (node.tag === HostPortal) {
|
14955 |
|
14956 |
|
14957 | currentParentIsValid = false;
|
14958 | }
|
14959 | }
|
14960 |
|
14961 | node.sibling.return = node.return;
|
14962 | node = node.sibling;
|
14963 | }
|
14964 | }
|
14965 |
|
14966 | function commitDeletion(finishedRoot, current, nearestMountedAncestor) {
|
14967 | {
|
14968 |
|
14969 |
|
14970 | unmountHostComponents(finishedRoot, current, nearestMountedAncestor);
|
14971 | }
|
14972 |
|
14973 | detachFiberMutation(current);
|
14974 | }
|
14975 |
|
14976 | function commitWork(current, finishedWork) {
|
14977 |
|
14978 | switch (finishedWork.tag) {
|
14979 | case FunctionComponent:
|
14980 | case ForwardRef:
|
14981 | case MemoComponent:
|
14982 | case SimpleMemoComponent:
|
14983 | {
|
14984 | commitHookEffectListUnmount(Insertion | HasEffect, finishedWork, finishedWork.return);
|
14985 | commitHookEffectListMount(Insertion | HasEffect, finishedWork);
|
14986 |
|
14987 |
|
14988 |
|
14989 |
|
14990 |
|
14991 | if ( finishedWork.mode & ProfileMode) {
|
14992 | try {
|
14993 | startLayoutEffectTimer();
|
14994 | commitHookEffectListUnmount(Layout | HasEffect, finishedWork, finishedWork.return);
|
14995 | } finally {
|
14996 | recordLayoutEffectDuration(finishedWork);
|
14997 | }
|
14998 | } else {
|
14999 | commitHookEffectListUnmount(Layout | HasEffect, finishedWork, finishedWork.return);
|
15000 | }
|
15001 |
|
15002 | return;
|
15003 | }
|
15004 |
|
15005 | case ClassComponent:
|
15006 | {
|
15007 | return;
|
15008 | }
|
15009 |
|
15010 | case HostComponent:
|
15011 | {
|
15012 | var instance = finishedWork.stateNode;
|
15013 |
|
15014 | if (instance != null) {
|
15015 |
|
15016 | var newProps = finishedWork.memoizedProps;
|
15017 |
|
15018 |
|
15019 |
|
15020 | var oldProps = current !== null ? current.memoizedProps : newProps;
|
15021 | var type = finishedWork.type;
|
15022 |
|
15023 | var updatePayload = finishedWork.updateQueue;
|
15024 | finishedWork.updateQueue = null;
|
15025 |
|
15026 | if (updatePayload !== null) {
|
15027 | commitUpdate(instance, updatePayload, type, oldProps, newProps);
|
15028 | }
|
15029 | }
|
15030 |
|
15031 | return;
|
15032 | }
|
15033 |
|
15034 | case HostText:
|
15035 | {
|
15036 | if (finishedWork.stateNode === null) {
|
15037 | throw new Error('This should have a text node initialized. This error is likely ' + 'caused by a bug in React. Please file an issue.');
|
15038 | }
|
15039 |
|
15040 | var textInstance = finishedWork.stateNode;
|
15041 | var newText = finishedWork.memoizedProps;
|
15042 |
|
15043 |
|
15044 |
|
15045 | var oldText = current !== null ? current.memoizedProps : newText;
|
15046 | return;
|
15047 | }
|
15048 |
|
15049 | case HostRoot:
|
15050 | {
|
15051 |
|
15052 | return;
|
15053 | }
|
15054 |
|
15055 | case Profiler:
|
15056 | {
|
15057 | return;
|
15058 | }
|
15059 |
|
15060 | case SuspenseComponent:
|
15061 | {
|
15062 | commitSuspenseCallback(finishedWork);
|
15063 | attachSuspenseRetryListeners(finishedWork);
|
15064 | return;
|
15065 | }
|
15066 |
|
15067 | case SuspenseListComponent:
|
15068 | {
|
15069 | attachSuspenseRetryListeners(finishedWork);
|
15070 | return;
|
15071 | }
|
15072 |
|
15073 | case IncompleteClassComponent:
|
15074 | {
|
15075 | return;
|
15076 | }
|
15077 | }
|
15078 |
|
15079 | throw new 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.');
|
15080 | }
|
15081 |
|
15082 | function commitSuspenseCallback(finishedWork) {
|
15083 |
|
15084 | var newState = finishedWork.memoizedState;
|
15085 | }
|
15086 |
|
15087 | function attachSuspenseRetryListeners(finishedWork) {
|
15088 |
|
15089 |
|
15090 |
|
15091 | var wakeables = finishedWork.updateQueue;
|
15092 |
|
15093 | if (wakeables !== null) {
|
15094 | finishedWork.updateQueue = null;
|
15095 | var retryCache = finishedWork.stateNode;
|
15096 |
|
15097 | if (retryCache === null) {
|
15098 | retryCache = finishedWork.stateNode = new PossiblyWeakSet();
|
15099 | }
|
15100 |
|
15101 | wakeables.forEach(function (wakeable) {
|
15102 |
|
15103 | var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
|
15104 |
|
15105 | if (!retryCache.has(wakeable)) {
|
15106 | retryCache.add(wakeable);
|
15107 |
|
15108 | {
|
15109 | if (isDevToolsPresent) {
|
15110 | if (inProgressLanes !== null && inProgressRoot !== null) {
|
15111 |
|
15112 | restorePendingUpdaters(inProgressRoot, inProgressLanes);
|
15113 | } else {
|
15114 | throw Error('Expected finished root and lanes to be set. This is a bug in React.');
|
15115 | }
|
15116 | }
|
15117 | }
|
15118 |
|
15119 | wakeable.then(retry, retry);
|
15120 | }
|
15121 | });
|
15122 | }
|
15123 | }
|
15124 |
|
15125 | function commitResetTextContent(current) {
|
15126 |
|
15127 | resetTextContent(current.stateNode);
|
15128 | }
|
15129 |
|
15130 | function commitMutationEffects(root, firstChild, committedLanes) {
|
15131 | inProgressLanes = committedLanes;
|
15132 | inProgressRoot = root;
|
15133 | nextEffect = firstChild;
|
15134 | commitMutationEffects_begin(root, committedLanes);
|
15135 | inProgressLanes = null;
|
15136 | inProgressRoot = null;
|
15137 | }
|
15138 |
|
15139 | function commitMutationEffects_begin(root, lanes) {
|
15140 | while (nextEffect !== null) {
|
15141 | var fiber = nextEffect;
|
15142 |
|
15143 | var deletions = fiber.deletions;
|
15144 |
|
15145 | if (deletions !== null) {
|
15146 | for (var i = 0; i < deletions.length; i++) {
|
15147 | var childToDelete = deletions[i];
|
15148 |
|
15149 | try {
|
15150 | commitDeletion(root, childToDelete, fiber);
|
15151 | } catch (error) {
|
15152 | reportUncaughtErrorInDEV(error);
|
15153 | captureCommitPhaseError(childToDelete, fiber, error);
|
15154 | }
|
15155 | }
|
15156 | }
|
15157 |
|
15158 | var child = fiber.child;
|
15159 |
|
15160 | if ((fiber.subtreeFlags & MutationMask) !== NoFlags && child !== null) {
|
15161 | ensureCorrectReturnPointer(child, fiber);
|
15162 | nextEffect = child;
|
15163 | } else {
|
15164 | commitMutationEffects_complete(root, lanes);
|
15165 | }
|
15166 | }
|
15167 | }
|
15168 |
|
15169 | function commitMutationEffects_complete(root, lanes) {
|
15170 | while (nextEffect !== null) {
|
15171 | var fiber = nextEffect;
|
15172 | setCurrentFiber(fiber);
|
15173 |
|
15174 | try {
|
15175 | commitMutationEffectsOnFiber(fiber, root, lanes);
|
15176 | } catch (error) {
|
15177 | reportUncaughtErrorInDEV(error);
|
15178 | captureCommitPhaseError(fiber, fiber.return, error);
|
15179 | }
|
15180 |
|
15181 | resetCurrentFiber();
|
15182 | var sibling = fiber.sibling;
|
15183 |
|
15184 | if (sibling !== null) {
|
15185 | ensureCorrectReturnPointer(sibling, fiber.return);
|
15186 | nextEffect = sibling;
|
15187 | return;
|
15188 | }
|
15189 |
|
15190 | nextEffect = fiber.return;
|
15191 | }
|
15192 | }
|
15193 |
|
15194 | function commitMutationEffectsOnFiber(finishedWork, root, lanes) {
|
15195 |
|
15196 |
|
15197 |
|
15198 |
|
15199 | var flags = finishedWork.flags;
|
15200 |
|
15201 | if (flags & ContentReset) {
|
15202 | commitResetTextContent(finishedWork);
|
15203 | }
|
15204 |
|
15205 | if (flags & Ref) {
|
15206 | var current = finishedWork.alternate;
|
15207 |
|
15208 | if (current !== null) {
|
15209 | commitDetachRef(current);
|
15210 | }
|
15211 | }
|
15212 |
|
15213 | if (flags & Visibility) {
|
15214 | switch (finishedWork.tag) {
|
15215 | case SuspenseComponent:
|
15216 | {
|
15217 | var newState = finishedWork.memoizedState;
|
15218 | var isHidden = newState !== null;
|
15219 |
|
15220 | if (isHidden) {
|
15221 | var _current = finishedWork.alternate;
|
15222 | var wasHidden = _current !== null && _current.memoizedState !== null;
|
15223 |
|
15224 | if (!wasHidden) {
|
15225 |
|
15226 | markCommitTimeOfFallback();
|
15227 | }
|
15228 | }
|
15229 |
|
15230 | break;
|
15231 | }
|
15232 |
|
15233 | case OffscreenComponent:
|
15234 | {
|
15235 | var _newState = finishedWork.memoizedState;
|
15236 |
|
15237 | var _isHidden = _newState !== null;
|
15238 |
|
15239 | var _current2 = finishedWork.alternate;
|
15240 |
|
15241 | var _wasHidden = _current2 !== null && _current2.memoizedState !== null;
|
15242 |
|
15243 | var offscreenBoundary = finishedWork;
|
15244 |
|
15245 | {
|
15246 |
|
15247 |
|
15248 | hideOrUnhideAllChildren(offscreenBoundary, _isHidden);
|
15249 | }
|
15250 |
|
15251 | {
|
15252 | if (_isHidden) {
|
15253 | if (!_wasHidden) {
|
15254 | if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
|
15255 | nextEffect = offscreenBoundary;
|
15256 | var offscreenChild = offscreenBoundary.child;
|
15257 |
|
15258 | while (offscreenChild !== null) {
|
15259 | nextEffect = offscreenChild;
|
15260 | disappearLayoutEffects_begin(offscreenChild);
|
15261 | offscreenChild = offscreenChild.sibling;
|
15262 | }
|
15263 | }
|
15264 | }
|
15265 | }
|
15266 |
|
15267 | break;
|
15268 | }
|
15269 | }
|
15270 | }
|
15271 | }
|
15272 |
|
15273 |
|
15274 |
|
15275 |
|
15276 |
|
15277 | var primaryFlags = flags & (Placement | Update | Hydrating);
|
15278 |
|
15279 | switch (primaryFlags) {
|
15280 | case Placement:
|
15281 | {
|
15282 | commitPlacement(finishedWork);
|
15283 |
|
15284 |
|
15285 |
|
15286 |
|
15287 | finishedWork.flags &= ~Placement;
|
15288 | break;
|
15289 | }
|
15290 |
|
15291 | case PlacementAndUpdate:
|
15292 | {
|
15293 |
|
15294 | commitPlacement(finishedWork);
|
15295 |
|
15296 |
|
15297 | finishedWork.flags &= ~Placement;
|
15298 |
|
15299 | var _current3 = finishedWork.alternate;
|
15300 | commitWork(_current3, finishedWork);
|
15301 | break;
|
15302 | }
|
15303 |
|
15304 | case Hydrating:
|
15305 | {
|
15306 | finishedWork.flags &= ~Hydrating;
|
15307 | break;
|
15308 | }
|
15309 |
|
15310 | case HydratingAndUpdate:
|
15311 | {
|
15312 | finishedWork.flags &= ~Hydrating;
|
15313 |
|
15314 | var _current4 = finishedWork.alternate;
|
15315 | commitWork(_current4, finishedWork);
|
15316 | break;
|
15317 | }
|
15318 |
|
15319 | case Update:
|
15320 | {
|
15321 | var _current5 = finishedWork.alternate;
|
15322 | commitWork(_current5, finishedWork);
|
15323 | break;
|
15324 | }
|
15325 | }
|
15326 | }
|
15327 |
|
15328 | function commitLayoutEffects(finishedWork, root, committedLanes) {
|
15329 | inProgressLanes = committedLanes;
|
15330 | inProgressRoot = root;
|
15331 | nextEffect = finishedWork;
|
15332 | commitLayoutEffects_begin(finishedWork, root, committedLanes);
|
15333 | inProgressLanes = null;
|
15334 | inProgressRoot = null;
|
15335 | }
|
15336 |
|
15337 | function commitLayoutEffects_begin(subtreeRoot, root, committedLanes) {
|
15338 |
|
15339 | var isModernRoot = (subtreeRoot.mode & ConcurrentMode) !== NoMode;
|
15340 |
|
15341 | while (nextEffect !== null) {
|
15342 | var fiber = nextEffect;
|
15343 | var firstChild = fiber.child;
|
15344 |
|
15345 | if ( fiber.tag === OffscreenComponent && isModernRoot) {
|
15346 |
|
15347 | var isHidden = fiber.memoizedState !== null;
|
15348 | var newOffscreenSubtreeIsHidden = isHidden || offscreenSubtreeIsHidden;
|
15349 |
|
15350 | if (newOffscreenSubtreeIsHidden) {
|
15351 |
|
15352 | commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes);
|
15353 | continue;
|
15354 | } else {
|
15355 |
|
15356 | var current = fiber.alternate;
|
15357 | var wasHidden = current !== null && current.memoizedState !== null;
|
15358 | var newOffscreenSubtreeWasHidden = wasHidden || offscreenSubtreeWasHidden;
|
15359 | var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden;
|
15360 | var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden;
|
15361 |
|
15362 | offscreenSubtreeIsHidden = newOffscreenSubtreeIsHidden;
|
15363 | offscreenSubtreeWasHidden = newOffscreenSubtreeWasHidden;
|
15364 |
|
15365 | if (offscreenSubtreeWasHidden && !prevOffscreenSubtreeWasHidden) {
|
15366 |
|
15367 |
|
15368 | nextEffect = fiber;
|
15369 | reappearLayoutEffects_begin(fiber);
|
15370 | }
|
15371 |
|
15372 | var child = firstChild;
|
15373 |
|
15374 | while (child !== null) {
|
15375 | nextEffect = child;
|
15376 | commitLayoutEffects_begin(child,
|
15377 | root, committedLanes);
|
15378 | child = child.sibling;
|
15379 | }
|
15380 |
|
15381 |
|
15382 | nextEffect = fiber;
|
15383 | offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden;
|
15384 | offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden;
|
15385 | commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes);
|
15386 | continue;
|
15387 | }
|
15388 | }
|
15389 |
|
15390 | if ((fiber.subtreeFlags & LayoutMask) !== NoFlags && firstChild !== null) {
|
15391 | ensureCorrectReturnPointer(firstChild, fiber);
|
15392 | nextEffect = firstChild;
|
15393 | } else {
|
15394 | commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes);
|
15395 | }
|
15396 | }
|
15397 | }
|
15398 |
|
15399 | function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) {
|
15400 | while (nextEffect !== null) {
|
15401 | var fiber = nextEffect;
|
15402 |
|
15403 | if ((fiber.flags & LayoutMask) !== NoFlags) {
|
15404 | var current = fiber.alternate;
|
15405 | setCurrentFiber(fiber);
|
15406 |
|
15407 | try {
|
15408 | commitLayoutEffectOnFiber(root, current, fiber, committedLanes);
|
15409 | } catch (error) {
|
15410 | reportUncaughtErrorInDEV(error);
|
15411 | captureCommitPhaseError(fiber, fiber.return, error);
|
15412 | }
|
15413 |
|
15414 | resetCurrentFiber();
|
15415 | }
|
15416 |
|
15417 | if (fiber === subtreeRoot) {
|
15418 | nextEffect = null;
|
15419 | return;
|
15420 | }
|
15421 |
|
15422 | var sibling = fiber.sibling;
|
15423 |
|
15424 | if (sibling !== null) {
|
15425 | ensureCorrectReturnPointer(sibling, fiber.return);
|
15426 | nextEffect = sibling;
|
15427 | return;
|
15428 | }
|
15429 |
|
15430 | nextEffect = fiber.return;
|
15431 | }
|
15432 | }
|
15433 |
|
15434 | function disappearLayoutEffects_begin(subtreeRoot) {
|
15435 | while (nextEffect !== null) {
|
15436 | var fiber = nextEffect;
|
15437 | var firstChild = fiber.child;
|
15438 |
|
15439 | switch (fiber.tag) {
|
15440 | case FunctionComponent:
|
15441 | case ForwardRef:
|
15442 | case MemoComponent:
|
15443 | case SimpleMemoComponent:
|
15444 | {
|
15445 | if ( fiber.mode & ProfileMode) {
|
15446 | try {
|
15447 | startLayoutEffectTimer();
|
15448 | commitHookEffectListUnmount(Layout, fiber, fiber.return);
|
15449 | } finally {
|
15450 | recordLayoutEffectDuration(fiber);
|
15451 | }
|
15452 | } else {
|
15453 | commitHookEffectListUnmount(Layout, fiber, fiber.return);
|
15454 | }
|
15455 |
|
15456 | break;
|
15457 | }
|
15458 |
|
15459 | case ClassComponent:
|
15460 | {
|
15461 |
|
15462 | safelyDetachRef(fiber, fiber.return);
|
15463 | var instance = fiber.stateNode;
|
15464 |
|
15465 | if (typeof instance.componentWillUnmount === 'function') {
|
15466 | safelyCallComponentWillUnmount(fiber, fiber.return, instance);
|
15467 | }
|
15468 |
|
15469 | break;
|
15470 | }
|
15471 |
|
15472 | case HostComponent:
|
15473 | {
|
15474 | safelyDetachRef(fiber, fiber.return);
|
15475 | break;
|
15476 | }
|
15477 |
|
15478 | case OffscreenComponent:
|
15479 | {
|
15480 |
|
15481 | var isHidden = fiber.memoizedState !== null;
|
15482 |
|
15483 | if (isHidden) {
|
15484 |
|
15485 |
|
15486 | disappearLayoutEffects_complete(subtreeRoot);
|
15487 | continue;
|
15488 | }
|
15489 |
|
15490 | break;
|
15491 | }
|
15492 | }
|
15493 |
|
15494 |
|
15495 | if (firstChild !== null) {
|
15496 | firstChild.return = fiber;
|
15497 | nextEffect = firstChild;
|
15498 | } else {
|
15499 | disappearLayoutEffects_complete(subtreeRoot);
|
15500 | }
|
15501 | }
|
15502 | }
|
15503 |
|
15504 | function disappearLayoutEffects_complete(subtreeRoot) {
|
15505 | while (nextEffect !== null) {
|
15506 | var fiber = nextEffect;
|
15507 |
|
15508 | if (fiber === subtreeRoot) {
|
15509 | nextEffect = null;
|
15510 | return;
|
15511 | }
|
15512 |
|
15513 | var sibling = fiber.sibling;
|
15514 |
|
15515 | if (sibling !== null) {
|
15516 | sibling.return = fiber.return;
|
15517 | nextEffect = sibling;
|
15518 | return;
|
15519 | }
|
15520 |
|
15521 | nextEffect = fiber.return;
|
15522 | }
|
15523 | }
|
15524 |
|
15525 | function reappearLayoutEffects_begin(subtreeRoot) {
|
15526 | while (nextEffect !== null) {
|
15527 | var fiber = nextEffect;
|
15528 | var firstChild = fiber.child;
|
15529 |
|
15530 | if (fiber.tag === OffscreenComponent) {
|
15531 | var isHidden = fiber.memoizedState !== null;
|
15532 |
|
15533 | if (isHidden) {
|
15534 |
|
15535 | reappearLayoutEffects_complete(subtreeRoot);
|
15536 | continue;
|
15537 | }
|
15538 | }
|
15539 |
|
15540 |
|
15541 | if (firstChild !== null) {
|
15542 |
|
15543 |
|
15544 | firstChild.return = fiber;
|
15545 | nextEffect = firstChild;
|
15546 | } else {
|
15547 | reappearLayoutEffects_complete(subtreeRoot);
|
15548 | }
|
15549 | }
|
15550 | }
|
15551 |
|
15552 | function reappearLayoutEffects_complete(subtreeRoot) {
|
15553 | while (nextEffect !== null) {
|
15554 | var fiber = nextEffect;
|
15555 |
|
15556 | setCurrentFiber(fiber);
|
15557 |
|
15558 | try {
|
15559 | reappearLayoutEffectsOnFiber(fiber);
|
15560 | } catch (error) {
|
15561 | reportUncaughtErrorInDEV(error);
|
15562 | captureCommitPhaseError(fiber, fiber.return, error);
|
15563 | }
|
15564 |
|
15565 | resetCurrentFiber();
|
15566 |
|
15567 | if (fiber === subtreeRoot) {
|
15568 | nextEffect = null;
|
15569 | return;
|
15570 | }
|
15571 |
|
15572 | var sibling = fiber.sibling;
|
15573 |
|
15574 | if (sibling !== null) {
|
15575 |
|
15576 |
|
15577 | sibling.return = fiber.return;
|
15578 | nextEffect = sibling;
|
15579 | return;
|
15580 | }
|
15581 |
|
15582 | nextEffect = fiber.return;
|
15583 | }
|
15584 | }
|
15585 |
|
15586 | function commitPassiveMountEffects(root, finishedWork) {
|
15587 | nextEffect = finishedWork;
|
15588 | commitPassiveMountEffects_begin(finishedWork, root);
|
15589 | }
|
15590 |
|
15591 | function commitPassiveMountEffects_begin(subtreeRoot, root) {
|
15592 | while (nextEffect !== null) {
|
15593 | var fiber = nextEffect;
|
15594 | var firstChild = fiber.child;
|
15595 |
|
15596 | if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && firstChild !== null) {
|
15597 | ensureCorrectReturnPointer(firstChild, fiber);
|
15598 | nextEffect = firstChild;
|
15599 | } else {
|
15600 | commitPassiveMountEffects_complete(subtreeRoot, root);
|
15601 | }
|
15602 | }
|
15603 | }
|
15604 |
|
15605 | function commitPassiveMountEffects_complete(subtreeRoot, root) {
|
15606 | while (nextEffect !== null) {
|
15607 | var fiber = nextEffect;
|
15608 |
|
15609 | if ((fiber.flags & Passive) !== NoFlags) {
|
15610 | setCurrentFiber(fiber);
|
15611 |
|
15612 | try {
|
15613 | commitPassiveMountOnFiber(root, fiber);
|
15614 | } catch (error) {
|
15615 | reportUncaughtErrorInDEV(error);
|
15616 | captureCommitPhaseError(fiber, fiber.return, error);
|
15617 | }
|
15618 |
|
15619 | resetCurrentFiber();
|
15620 | }
|
15621 |
|
15622 | if (fiber === subtreeRoot) {
|
15623 | nextEffect = null;
|
15624 | return;
|
15625 | }
|
15626 |
|
15627 | var sibling = fiber.sibling;
|
15628 |
|
15629 | if (sibling !== null) {
|
15630 | ensureCorrectReturnPointer(sibling, fiber.return);
|
15631 | nextEffect = sibling;
|
15632 | return;
|
15633 | }
|
15634 |
|
15635 | nextEffect = fiber.return;
|
15636 | }
|
15637 | }
|
15638 |
|
15639 | function commitPassiveMountOnFiber(finishedRoot, finishedWork) {
|
15640 | switch (finishedWork.tag) {
|
15641 | case FunctionComponent:
|
15642 | case ForwardRef:
|
15643 | case SimpleMemoComponent:
|
15644 | {
|
15645 | if ( finishedWork.mode & ProfileMode) {
|
15646 | startPassiveEffectTimer();
|
15647 |
|
15648 | try {
|
15649 | commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
|
15650 | } finally {
|
15651 | recordPassiveEffectDuration(finishedWork);
|
15652 | }
|
15653 | } else {
|
15654 | commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
|
15655 | }
|
15656 |
|
15657 | break;
|
15658 | }
|
15659 | }
|
15660 | }
|
15661 |
|
15662 | function commitPassiveUnmountEffects(firstChild) {
|
15663 | nextEffect = firstChild;
|
15664 | commitPassiveUnmountEffects_begin();
|
15665 | }
|
15666 |
|
15667 | function commitPassiveUnmountEffects_begin() {
|
15668 | while (nextEffect !== null) {
|
15669 | var fiber = nextEffect;
|
15670 | var child = fiber.child;
|
15671 |
|
15672 | if ((nextEffect.flags & ChildDeletion) !== NoFlags) {
|
15673 | var deletions = fiber.deletions;
|
15674 |
|
15675 | if (deletions !== null) {
|
15676 | for (var i = 0; i < deletions.length; i++) {
|
15677 | var fiberToDelete = deletions[i];
|
15678 | nextEffect = fiberToDelete;
|
15679 | commitPassiveUnmountEffectsInsideOfDeletedTree_begin(fiberToDelete, fiber);
|
15680 | }
|
15681 |
|
15682 | {
|
15683 |
|
15684 |
|
15685 |
|
15686 |
|
15687 |
|
15688 |
|
15689 |
|
15690 |
|
15691 |
|
15692 |
|
15693 |
|
15694 | var previousFiber = fiber.alternate;
|
15695 |
|
15696 | if (previousFiber !== null) {
|
15697 | var detachedChild = previousFiber.child;
|
15698 |
|
15699 | if (detachedChild !== null) {
|
15700 | previousFiber.child = null;
|
15701 |
|
15702 | do {
|
15703 | var detachedSibling = detachedChild.sibling;
|
15704 | detachedChild.sibling = null;
|
15705 | detachedChild = detachedSibling;
|
15706 | } while (detachedChild !== null);
|
15707 | }
|
15708 | }
|
15709 | }
|
15710 |
|
15711 | nextEffect = fiber;
|
15712 | }
|
15713 | }
|
15714 |
|
15715 | if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && child !== null) {
|
15716 | ensureCorrectReturnPointer(child, fiber);
|
15717 | nextEffect = child;
|
15718 | } else {
|
15719 | commitPassiveUnmountEffects_complete();
|
15720 | }
|
15721 | }
|
15722 | }
|
15723 |
|
15724 | function commitPassiveUnmountEffects_complete() {
|
15725 | while (nextEffect !== null) {
|
15726 | var fiber = nextEffect;
|
15727 |
|
15728 | if ((fiber.flags & Passive) !== NoFlags) {
|
15729 | setCurrentFiber(fiber);
|
15730 | commitPassiveUnmountOnFiber(fiber);
|
15731 | resetCurrentFiber();
|
15732 | }
|
15733 |
|
15734 | var sibling = fiber.sibling;
|
15735 |
|
15736 | if (sibling !== null) {
|
15737 | ensureCorrectReturnPointer(sibling, fiber.return);
|
15738 | nextEffect = sibling;
|
15739 | return;
|
15740 | }
|
15741 |
|
15742 | nextEffect = fiber.return;
|
15743 | }
|
15744 | }
|
15745 |
|
15746 | function commitPassiveUnmountOnFiber(finishedWork) {
|
15747 | switch (finishedWork.tag) {
|
15748 | case FunctionComponent:
|
15749 | case ForwardRef:
|
15750 | case SimpleMemoComponent:
|
15751 | {
|
15752 | if ( finishedWork.mode & ProfileMode) {
|
15753 | startPassiveEffectTimer();
|
15754 | commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork, finishedWork.return);
|
15755 | recordPassiveEffectDuration(finishedWork);
|
15756 | } else {
|
15757 | commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork, finishedWork.return);
|
15758 | }
|
15759 |
|
15760 | break;
|
15761 | }
|
15762 | }
|
15763 | }
|
15764 |
|
15765 | function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot, nearestMountedAncestor) {
|
15766 | while (nextEffect !== null) {
|
15767 | var fiber = nextEffect;
|
15768 |
|
15769 |
|
15770 | setCurrentFiber(fiber);
|
15771 | commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor);
|
15772 | resetCurrentFiber();
|
15773 | var child = fiber.child;
|
15774 |
|
15775 |
|
15776 | if (child !== null) {
|
15777 | ensureCorrectReturnPointer(child, fiber);
|
15778 | nextEffect = child;
|
15779 | } else {
|
15780 | commitPassiveUnmountEffectsInsideOfDeletedTree_complete(deletedSubtreeRoot);
|
15781 | }
|
15782 | }
|
15783 | }
|
15784 |
|
15785 | function commitPassiveUnmountEffectsInsideOfDeletedTree_complete(deletedSubtreeRoot) {
|
15786 | while (nextEffect !== null) {
|
15787 | var fiber = nextEffect;
|
15788 | var sibling = fiber.sibling;
|
15789 | var returnFiber = fiber.return;
|
15790 |
|
15791 | {
|
15792 |
|
15793 |
|
15794 |
|
15795 | detachFiberAfterEffects(fiber);
|
15796 |
|
15797 | if (fiber === deletedSubtreeRoot) {
|
15798 | nextEffect = null;
|
15799 | return;
|
15800 | }
|
15801 | }
|
15802 |
|
15803 | if (sibling !== null) {
|
15804 | ensureCorrectReturnPointer(sibling, returnFiber);
|
15805 | nextEffect = sibling;
|
15806 | return;
|
15807 | }
|
15808 |
|
15809 | nextEffect = returnFiber;
|
15810 | }
|
15811 | }
|
15812 |
|
15813 | function commitPassiveUnmountInsideDeletedTreeOnFiber(current, nearestMountedAncestor) {
|
15814 | switch (current.tag) {
|
15815 | case FunctionComponent:
|
15816 | case ForwardRef:
|
15817 | case SimpleMemoComponent:
|
15818 | {
|
15819 | if ( current.mode & ProfileMode) {
|
15820 | startPassiveEffectTimer();
|
15821 | commitHookEffectListUnmount(Passive$1, current, nearestMountedAncestor);
|
15822 | recordPassiveEffectDuration(current);
|
15823 | } else {
|
15824 | commitHookEffectListUnmount(Passive$1, current, nearestMountedAncestor);
|
15825 | }
|
15826 |
|
15827 | break;
|
15828 | }
|
15829 | }
|
15830 | }
|
15831 |
|
15832 | var didWarnWrongReturnPointer = false;
|
15833 |
|
15834 | function ensureCorrectReturnPointer(fiber, expectedReturnFiber) {
|
15835 | {
|
15836 | if (!didWarnWrongReturnPointer && fiber.return !== expectedReturnFiber) {
|
15837 | didWarnWrongReturnPointer = true;
|
15838 |
|
15839 | error('Internal React error: Return pointer is inconsistent ' + 'with parent.');
|
15840 | }
|
15841 | }
|
15842 |
|
15843 |
|
15844 |
|
15845 | fiber.return = expectedReturnFiber;
|
15846 | }
|
15847 |
|
15848 |
|
15849 | function invokeLayoutEffectMountInDEV(fiber) {
|
15850 | {
|
15851 |
|
15852 |
|
15853 | switch (fiber.tag) {
|
15854 | case FunctionComponent:
|
15855 | case ForwardRef:
|
15856 | case SimpleMemoComponent:
|
15857 | {
|
15858 | try {
|
15859 | commitHookEffectListMount(Layout | HasEffect, fiber);
|
15860 | } catch (error) {
|
15861 | reportUncaughtErrorInDEV(error);
|
15862 | captureCommitPhaseError(fiber, fiber.return, error);
|
15863 | }
|
15864 |
|
15865 | break;
|
15866 | }
|
15867 |
|
15868 | case ClassComponent:
|
15869 | {
|
15870 | var instance = fiber.stateNode;
|
15871 |
|
15872 | try {
|
15873 | instance.componentDidMount();
|
15874 | } catch (error) {
|
15875 | reportUncaughtErrorInDEV(error);
|
15876 | captureCommitPhaseError(fiber, fiber.return, error);
|
15877 | }
|
15878 |
|
15879 | break;
|
15880 | }
|
15881 | }
|
15882 | }
|
15883 | }
|
15884 |
|
15885 | function invokePassiveEffectMountInDEV(fiber) {
|
15886 | {
|
15887 |
|
15888 |
|
15889 | switch (fiber.tag) {
|
15890 | case FunctionComponent:
|
15891 | case ForwardRef:
|
15892 | case SimpleMemoComponent:
|
15893 | {
|
15894 | try {
|
15895 | commitHookEffectListMount(Passive$1 | HasEffect, fiber);
|
15896 | } catch (error) {
|
15897 | reportUncaughtErrorInDEV(error);
|
15898 | captureCommitPhaseError(fiber, fiber.return, error);
|
15899 | }
|
15900 |
|
15901 | break;
|
15902 | }
|
15903 | }
|
15904 | }
|
15905 | }
|
15906 |
|
15907 | function invokeLayoutEffectUnmountInDEV(fiber) {
|
15908 | {
|
15909 |
|
15910 |
|
15911 | switch (fiber.tag) {
|
15912 | case FunctionComponent:
|
15913 | case ForwardRef:
|
15914 | case SimpleMemoComponent:
|
15915 | {
|
15916 | try {
|
15917 | commitHookEffectListUnmount(Layout | HasEffect, fiber, fiber.return);
|
15918 | } catch (error) {
|
15919 | reportUncaughtErrorInDEV(error);
|
15920 | captureCommitPhaseError(fiber, fiber.return, error);
|
15921 | }
|
15922 |
|
15923 | break;
|
15924 | }
|
15925 |
|
15926 | case ClassComponent:
|
15927 | {
|
15928 | var instance = fiber.stateNode;
|
15929 |
|
15930 | if (typeof instance.componentWillUnmount === 'function') {
|
15931 | safelyCallComponentWillUnmount(fiber, fiber.return, instance);
|
15932 | }
|
15933 |
|
15934 | break;
|
15935 | }
|
15936 | }
|
15937 | }
|
15938 | }
|
15939 |
|
15940 | function invokePassiveEffectUnmountInDEV(fiber) {
|
15941 | {
|
15942 |
|
15943 |
|
15944 | switch (fiber.tag) {
|
15945 | case FunctionComponent:
|
15946 | case ForwardRef:
|
15947 | case SimpleMemoComponent:
|
15948 | {
|
15949 | try {
|
15950 | commitHookEffectListUnmount(Passive$1 | HasEffect, fiber, fiber.return);
|
15951 | } catch (error) {
|
15952 | reportUncaughtErrorInDEV(error);
|
15953 | captureCommitPhaseError(fiber, fiber.return, error);
|
15954 | }
|
15955 | }
|
15956 | }
|
15957 | }
|
15958 | }
|
15959 |
|
15960 | var COMPONENT_TYPE = 0;
|
15961 | var HAS_PSEUDO_CLASS_TYPE = 1;
|
15962 | var ROLE_TYPE = 2;
|
15963 | var TEST_NAME_TYPE = 3;
|
15964 | var TEXT_TYPE = 4;
|
15965 |
|
15966 | if (typeof Symbol === 'function' && Symbol.for) {
|
15967 | var symbolFor = Symbol.for;
|
15968 | COMPONENT_TYPE = symbolFor('selector.component');
|
15969 | HAS_PSEUDO_CLASS_TYPE = symbolFor('selector.has_pseudo_class');
|
15970 | ROLE_TYPE = symbolFor('selector.role');
|
15971 | TEST_NAME_TYPE = symbolFor('selector.test_id');
|
15972 | TEXT_TYPE = symbolFor('selector.text');
|
15973 | }
|
15974 |
|
15975 | var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue;
|
15976 | function isLegacyActEnvironment(fiber) {
|
15977 | {
|
15978 |
|
15979 |
|
15980 |
|
15981 |
|
15982 | var isReactActEnvironmentGlobal =
|
15983 | typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined' ? IS_REACT_ACT_ENVIRONMENT : undefined;
|
15984 | return warnsIfNotActing ;
|
15985 | }
|
15986 | }
|
15987 | function isConcurrentActEnvironment() {
|
15988 | {
|
15989 | var isReactActEnvironmentGlobal =
|
15990 | typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined' ? IS_REACT_ACT_ENVIRONMENT : undefined;
|
15991 |
|
15992 | if (!isReactActEnvironmentGlobal && ReactCurrentActQueue.current !== null) {
|
15993 |
|
15994 | error('The current testing environment is not configured to support ' + 'act(...)');
|
15995 | }
|
15996 |
|
15997 | return isReactActEnvironmentGlobal;
|
15998 | }
|
15999 | }
|
16000 |
|
16001 | var ceil = Math.ceil;
|
16002 | var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
|
16003 | ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
|
16004 | ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig,
|
16005 | ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue;
|
16006 | var NoContext =
|
16007 |
|
16008 | 0;
|
16009 | var BatchedContext =
|
16010 |
|
16011 | 1;
|
16012 | var RenderContext =
|
16013 |
|
16014 | 2;
|
16015 | var CommitContext =
|
16016 |
|
16017 | 4;
|
16018 | var RootInProgress = 0;
|
16019 | var RootFatalErrored = 1;
|
16020 | var RootErrored = 2;
|
16021 | var RootSuspended = 3;
|
16022 | var RootSuspendedWithDelay = 4;
|
16023 | var RootCompleted = 5;
|
16024 | var RootDidNotComplete = 6;
|
16025 |
|
16026 | var executionContext = NoContext;
|
16027 |
|
16028 | var workInProgressRoot = null;
|
16029 |
|
16030 | var workInProgress = null;
|
16031 |
|
16032 | var workInProgressRootRenderLanes = NoLanes;
|
16033 |
|
16034 |
|
16035 |
|
16036 |
|
16037 |
|
16038 |
|
16039 |
|
16040 |
|
16041 | var subtreeRenderLanes = NoLanes;
|
16042 | var subtreeRenderLanesCursor = createCursor(NoLanes);
|
16043 |
|
16044 | var workInProgressRootExitStatus = RootInProgress;
|
16045 |
|
16046 | var workInProgressRootFatalError = null;
|
16047 |
|
16048 |
|
16049 |
|
16050 |
|
16051 | var workInProgressRootIncludedLanes = NoLanes;
|
16052 |
|
16053 |
|
16054 | var workInProgressRootSkippedLanes = NoLanes;
|
16055 |
|
16056 | var workInProgressRootInterleavedUpdatedLanes = NoLanes;
|
16057 |
|
16058 | var workInProgressRootPingedLanes = NoLanes;
|
16059 |
|
16060 | var workInProgressRootConcurrentErrors = null;
|
16061 |
|
16062 |
|
16063 | var workInProgressRootRecoverableErrors = null;
|
16064 |
|
16065 |
|
16066 | var globalMostRecentFallbackTime = 0;
|
16067 | var FALLBACK_THROTTLE_MS = 500;
|
16068 |
|
16069 |
|
16070 | var workInProgressRootRenderTargetTime = Infinity;
|
16071 |
|
16072 |
|
16073 | var RENDER_TIMEOUT_MS = 500;
|
16074 |
|
16075 | function resetRenderTimer() {
|
16076 | workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS;
|
16077 | }
|
16078 |
|
16079 | function getRenderTargetTime() {
|
16080 | return workInProgressRootRenderTargetTime;
|
16081 | }
|
16082 | var hasUncaughtError = false;
|
16083 | var firstUncaughtError = null;
|
16084 | var legacyErrorBoundariesThatAlreadyFailed = null;
|
16085 | var rootDoesHavePassiveEffects = false;
|
16086 | var rootWithPendingPassiveEffects = null;
|
16087 | var pendingPassiveEffectsLanes = NoLanes;
|
16088 | var pendingPassiveProfilerEffects = [];
|
16089 |
|
16090 | var NESTED_UPDATE_LIMIT = 50;
|
16091 | var nestedUpdateCount = 0;
|
16092 | var rootWithNestedUpdates = null;
|
16093 | var NESTED_PASSIVE_UPDATE_LIMIT = 50;
|
16094 | var nestedPassiveUpdateCount = 0;
|
16095 |
|
16096 |
|
16097 |
|
16098 | var currentEventTime = NoTimestamp;
|
16099 | var currentEventTransitionLane = NoLanes;
|
16100 | function getWorkInProgressRoot() {
|
16101 | return workInProgressRoot;
|
16102 | }
|
16103 | function requestEventTime() {
|
16104 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
16105 |
|
16106 | return now();
|
16107 | }
|
16108 |
|
16109 |
|
16110 | if (currentEventTime !== NoTimestamp) {
|
16111 |
|
16112 | return currentEventTime;
|
16113 | }
|
16114 |
|
16115 |
|
16116 | currentEventTime = now();
|
16117 | return currentEventTime;
|
16118 | }
|
16119 | function requestUpdateLane(fiber) {
|
16120 |
|
16121 | var mode = fiber.mode;
|
16122 |
|
16123 | if ((mode & ConcurrentMode) === NoMode) {
|
16124 | return SyncLane;
|
16125 | } else if ( (executionContext & RenderContext) !== NoContext && workInProgressRootRenderLanes !== NoLanes) {
|
16126 |
|
16127 |
|
16128 |
|
16129 |
|
16130 |
|
16131 |
|
16132 |
|
16133 |
|
16134 |
|
16135 | return pickArbitraryLane(workInProgressRootRenderLanes);
|
16136 | }
|
16137 |
|
16138 | var isTransition = requestCurrentTransition() !== NoTransition;
|
16139 |
|
16140 | if (isTransition) {
|
16141 | if ( ReactCurrentBatchConfig$2.transition !== null) {
|
16142 | var transition = ReactCurrentBatchConfig$2.transition;
|
16143 |
|
16144 | if (!transition._updatedFibers) {
|
16145 | transition._updatedFibers = new Set();
|
16146 | }
|
16147 |
|
16148 | transition._updatedFibers.add(fiber);
|
16149 | }
|
16150 |
|
16151 |
|
16152 |
|
16153 |
|
16154 |
|
16155 |
|
16156 |
|
16157 |
|
16158 | if (currentEventTransitionLane === NoLane) {
|
16159 |
|
16160 | currentEventTransitionLane = claimNextTransitionLane();
|
16161 | }
|
16162 |
|
16163 | return currentEventTransitionLane;
|
16164 | }
|
16165 |
|
16166 |
|
16167 |
|
16168 |
|
16169 |
|
16170 |
|
16171 |
|
16172 | var updateLane = getCurrentUpdatePriority();
|
16173 |
|
16174 | if (updateLane !== NoLane) {
|
16175 | return updateLane;
|
16176 | }
|
16177 |
|
16178 |
|
16179 |
|
16180 |
|
16181 |
|
16182 |
|
16183 |
|
16184 | var eventLane = getCurrentEventPriority();
|
16185 | return eventLane;
|
16186 | }
|
16187 |
|
16188 | function requestRetryLane(fiber) {
|
16189 |
|
16190 |
|
16191 |
|
16192 |
|
16193 | var mode = fiber.mode;
|
16194 |
|
16195 | if ((mode & ConcurrentMode) === NoMode) {
|
16196 | return SyncLane;
|
16197 | }
|
16198 |
|
16199 | return claimNextRetryLane();
|
16200 | }
|
16201 |
|
16202 | function scheduleUpdateOnFiber(fiber, lane, eventTime) {
|
16203 | checkForNestedUpdates();
|
16204 | var root = markUpdateLaneFromFiberToRoot(fiber, lane);
|
16205 |
|
16206 | if (root === null) {
|
16207 | return null;
|
16208 | }
|
16209 |
|
16210 |
|
16211 | markRootUpdated(root, lane, eventTime);
|
16212 |
|
16213 | if ((executionContext & RenderContext) !== NoLanes && root === workInProgressRoot) {
|
16214 |
|
16215 |
|
16216 |
|
16217 |
|
16218 |
|
16219 | warnAboutRenderPhaseUpdatesInDEV(fiber);
|
16220 | } else {
|
16221 |
|
16222 |
|
16223 | {
|
16224 | if (isDevToolsPresent) {
|
16225 | addFiberToLanesMap(root, fiber, lane);
|
16226 | }
|
16227 | }
|
16228 |
|
16229 | warnIfUpdatesNotWrappedWithActDEV(fiber);
|
16230 |
|
16231 | if (root === workInProgressRoot) {
|
16232 |
|
16233 |
|
16234 |
|
16235 |
|
16236 |
|
16237 |
|
16238 | if ( (executionContext & RenderContext) === NoContext) {
|
16239 | workInProgressRootInterleavedUpdatedLanes = mergeLanes(workInProgressRootInterleavedUpdatedLanes, lane);
|
16240 | }
|
16241 |
|
16242 | if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
|
16243 |
|
16244 |
|
16245 |
|
16246 |
|
16247 |
|
16248 |
|
16249 | markRootSuspended$1(root, workInProgressRootRenderLanes);
|
16250 | }
|
16251 | }
|
16252 |
|
16253 | ensureRootIsScheduled(root, eventTime);
|
16254 |
|
16255 | if (lane === SyncLane && executionContext === NoContext && (fiber.mode & ConcurrentMode) === NoMode &&
|
16256 | !( ReactCurrentActQueue$1.isBatchingLegacy)) {
|
16257 |
|
16258 |
|
16259 |
|
16260 |
|
16261 |
|
16262 | resetRenderTimer();
|
16263 | flushSyncCallbacksOnlyInLegacyMode();
|
16264 | }
|
16265 | }
|
16266 |
|
16267 | return root;
|
16268 | }
|
16269 |
|
16270 |
|
16271 |
|
16272 |
|
16273 | function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
|
16274 |
|
16275 | sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane);
|
16276 | var alternate = sourceFiber.alternate;
|
16277 |
|
16278 | if (alternate !== null) {
|
16279 | alternate.lanes = mergeLanes(alternate.lanes, lane);
|
16280 | }
|
16281 |
|
16282 | {
|
16283 | if (alternate === null && (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags) {
|
16284 | warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
|
16285 | }
|
16286 | }
|
16287 |
|
16288 |
|
16289 | var node = sourceFiber;
|
16290 | var parent = sourceFiber.return;
|
16291 |
|
16292 | while (parent !== null) {
|
16293 | parent.childLanes = mergeLanes(parent.childLanes, lane);
|
16294 | alternate = parent.alternate;
|
16295 |
|
16296 | if (alternate !== null) {
|
16297 | alternate.childLanes = mergeLanes(alternate.childLanes, lane);
|
16298 | } else {
|
16299 | {
|
16300 | if ((parent.flags & (Placement | Hydrating)) !== NoFlags) {
|
16301 | warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
|
16302 | }
|
16303 | }
|
16304 | }
|
16305 |
|
16306 | node = parent;
|
16307 | parent = parent.return;
|
16308 | }
|
16309 |
|
16310 | if (node.tag === HostRoot) {
|
16311 | var root = node.stateNode;
|
16312 | return root;
|
16313 | } else {
|
16314 | return null;
|
16315 | }
|
16316 | }
|
16317 |
|
16318 | function isInterleavedUpdate(fiber, lane) {
|
16319 | return (
|
16320 |
|
16321 |
|
16322 | workInProgressRoot !== null && (fiber.mode & ConcurrentMode) !== NoMode && (
|
16323 |
|
16324 |
|
16325 |
|
16326 | (executionContext & RenderContext) === NoContext)
|
16327 | );
|
16328 | }
|
16329 |
|
16330 |
|
16331 |
|
16332 |
|
16333 |
|
16334 | function ensureRootIsScheduled(root, currentTime) {
|
16335 | var existingCallbackNode = root.callbackNode;
|
16336 |
|
16337 |
|
16338 | markStarvedLanesAsExpired(root, currentTime);
|
16339 |
|
16340 | var nextLanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes);
|
16341 |
|
16342 | if (nextLanes === NoLanes) {
|
16343 |
|
16344 | if (existingCallbackNode !== null) {
|
16345 | cancelCallback$1(existingCallbackNode);
|
16346 | }
|
16347 |
|
16348 | root.callbackNode = null;
|
16349 | root.callbackPriority = NoLane;
|
16350 | return;
|
16351 | }
|
16352 |
|
16353 |
|
16354 | var newCallbackPriority = getHighestPriorityLane(nextLanes);
|
16355 |
|
16356 | var existingCallbackPriority = root.callbackPriority;
|
16357 |
|
16358 | if (existingCallbackPriority === newCallbackPriority &&
|
16359 |
|
16360 |
|
16361 | !( ReactCurrentActQueue$1.current !== null && existingCallbackNode !== fakeActCallbackNode)) {
|
16362 | {
|
16363 |
|
16364 |
|
16365 |
|
16366 | if (existingCallbackNode == null && existingCallbackPriority !== SyncLane) {
|
16367 | error('Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.');
|
16368 | }
|
16369 | }
|
16370 |
|
16371 |
|
16372 | return;
|
16373 | }
|
16374 |
|
16375 | if (existingCallbackNode != null) {
|
16376 |
|
16377 | cancelCallback$1(existingCallbackNode);
|
16378 | }
|
16379 |
|
16380 |
|
16381 | var newCallbackNode;
|
16382 |
|
16383 | if (newCallbackPriority === SyncLane) {
|
16384 |
|
16385 |
|
16386 | if (root.tag === LegacyRoot) {
|
16387 | if ( ReactCurrentActQueue$1.isBatchingLegacy !== null) {
|
16388 | ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
16389 | }
|
16390 |
|
16391 | scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root));
|
16392 | } else {
|
16393 | scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
|
16394 | }
|
16395 |
|
16396 | {
|
16397 |
|
16398 | scheduleCallback$1(ImmediatePriority, flushSyncCallbacks);
|
16399 | }
|
16400 |
|
16401 | newCallbackNode = null;
|
16402 | } else {
|
16403 | var schedulerPriorityLevel;
|
16404 |
|
16405 | switch (lanesToEventPriority(nextLanes)) {
|
16406 | case DiscreteEventPriority:
|
16407 | schedulerPriorityLevel = ImmediatePriority;
|
16408 | break;
|
16409 |
|
16410 | case ContinuousEventPriority:
|
16411 | schedulerPriorityLevel = UserBlockingPriority;
|
16412 | break;
|
16413 |
|
16414 | case DefaultEventPriority:
|
16415 | schedulerPriorityLevel = NormalPriority;
|
16416 | break;
|
16417 |
|
16418 | case IdleEventPriority:
|
16419 | schedulerPriorityLevel = IdlePriority;
|
16420 | break;
|
16421 |
|
16422 | default:
|
16423 | schedulerPriorityLevel = NormalPriority;
|
16424 | break;
|
16425 | }
|
16426 |
|
16427 | newCallbackNode = scheduleCallback$1(schedulerPriorityLevel, performConcurrentWorkOnRoot.bind(null, root));
|
16428 | }
|
16429 |
|
16430 | root.callbackPriority = newCallbackPriority;
|
16431 | root.callbackNode = newCallbackNode;
|
16432 | }
|
16433 |
|
16434 |
|
16435 |
|
16436 | function performConcurrentWorkOnRoot(root, didTimeout) {
|
16437 | {
|
16438 | resetNestedUpdateFlag();
|
16439 | }
|
16440 |
|
16441 |
|
16442 |
|
16443 | currentEventTime = NoTimestamp;
|
16444 | currentEventTransitionLane = NoLanes;
|
16445 |
|
16446 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
16447 | throw new Error('Should not already be working.');
|
16448 | }
|
16449 |
|
16450 |
|
16451 |
|
16452 | var originalCallbackNode = root.callbackNode;
|
16453 | var didFlushPassiveEffects = flushPassiveEffects();
|
16454 |
|
16455 | if (didFlushPassiveEffects) {
|
16456 |
|
16457 |
|
16458 | if (root.callbackNode !== originalCallbackNode) {
|
16459 |
|
16460 |
|
16461 |
|
16462 | return null;
|
16463 | }
|
16464 | }
|
16465 |
|
16466 |
|
16467 |
|
16468 | var lanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes);
|
16469 |
|
16470 | if (lanes === NoLanes) {
|
16471 |
|
16472 | return null;
|
16473 | }
|
16474 |
|
16475 |
|
16476 |
|
16477 |
|
16478 |
|
16479 |
|
16480 |
|
16481 | var shouldTimeSlice = !includesBlockingLane(root, lanes) && !includesExpiredLane(root, lanes) && ( !didTimeout);
|
16482 | var exitStatus = shouldTimeSlice ? renderRootConcurrent(root, lanes) : renderRootSync(root, lanes);
|
16483 |
|
16484 | if (exitStatus !== RootInProgress) {
|
16485 | if (exitStatus === RootErrored) {
|
16486 |
|
16487 |
|
16488 |
|
16489 |
|
16490 | var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
|
16491 |
|
16492 | if (errorRetryLanes !== NoLanes) {
|
16493 | lanes = errorRetryLanes;
|
16494 | exitStatus = recoverFromConcurrentError(root, errorRetryLanes);
|
16495 | }
|
16496 | }
|
16497 |
|
16498 | if (exitStatus === RootFatalErrored) {
|
16499 | var fatalError = workInProgressRootFatalError;
|
16500 | prepareFreshStack(root, NoLanes);
|
16501 | markRootSuspended$1(root, lanes);
|
16502 | ensureRootIsScheduled(root, now());
|
16503 | throw fatalError;
|
16504 | }
|
16505 |
|
16506 | if (exitStatus === RootDidNotComplete) {
|
16507 |
|
16508 |
|
16509 |
|
16510 |
|
16511 |
|
16512 |
|
16513 |
|
16514 | markRootSuspended$1(root, lanes);
|
16515 | } else {
|
16516 |
|
16517 |
|
16518 |
|
16519 |
|
16520 |
|
16521 |
|
16522 | var renderWasConcurrent = !includesBlockingLane(root, lanes);
|
16523 | var finishedWork = root.current.alternate;
|
16524 |
|
16525 | if (renderWasConcurrent && !isRenderConsistentWithExternalStores(finishedWork)) {
|
16526 |
|
16527 |
|
16528 | exitStatus = renderRootSync(root, lanes);
|
16529 |
|
16530 | if (exitStatus === RootErrored) {
|
16531 | var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
|
16532 |
|
16533 | if (_errorRetryLanes !== NoLanes) {
|
16534 | lanes = _errorRetryLanes;
|
16535 | exitStatus = recoverFromConcurrentError(root, _errorRetryLanes);
|
16536 |
|
16537 | }
|
16538 | }
|
16539 |
|
16540 | if (exitStatus === RootFatalErrored) {
|
16541 | var _fatalError = workInProgressRootFatalError;
|
16542 | prepareFreshStack(root, NoLanes);
|
16543 | markRootSuspended$1(root, lanes);
|
16544 | ensureRootIsScheduled(root, now());
|
16545 | throw _fatalError;
|
16546 | }
|
16547 | }
|
16548 |
|
16549 |
|
16550 |
|
16551 | root.finishedWork = finishedWork;
|
16552 | root.finishedLanes = lanes;
|
16553 | finishConcurrentRender(root, exitStatus, lanes);
|
16554 | }
|
16555 | }
|
16556 |
|
16557 | ensureRootIsScheduled(root, now());
|
16558 |
|
16559 | if (root.callbackNode === originalCallbackNode) {
|
16560 |
|
16561 |
|
16562 | return performConcurrentWorkOnRoot.bind(null, root);
|
16563 | }
|
16564 |
|
16565 | return null;
|
16566 | }
|
16567 |
|
16568 | function recoverFromConcurrentError(root, errorRetryLanes) {
|
16569 |
|
16570 |
|
16571 |
|
16572 | var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
|
16573 |
|
16574 | if (isRootDehydrated(root)) {
|
16575 |
|
16576 |
|
16577 |
|
16578 |
|
16579 |
|
16580 |
|
16581 |
|
16582 |
|
16583 |
|
16584 |
|
16585 |
|
16586 | var rootWorkInProgress = prepareFreshStack(root, errorRetryLanes);
|
16587 | rootWorkInProgress.flags |= ForceClientRender;
|
16588 |
|
16589 | {
|
16590 | errorHydratingContainer(root.containerInfo);
|
16591 | }
|
16592 | }
|
16593 |
|
16594 | var exitStatus = renderRootSync(root, errorRetryLanes);
|
16595 |
|
16596 | if (exitStatus !== RootErrored) {
|
16597 |
|
16598 |
|
16599 |
|
16600 |
|
16601 | var errorsFromSecondAttempt = workInProgressRootRecoverableErrors;
|
16602 | workInProgressRootRecoverableErrors = errorsFromFirstAttempt;
|
16603 |
|
16604 |
|
16605 | if (errorsFromSecondAttempt !== null) {
|
16606 | queueRecoverableErrors(errorsFromSecondAttempt);
|
16607 | }
|
16608 | }
|
16609 |
|
16610 | return exitStatus;
|
16611 | }
|
16612 |
|
16613 | function queueRecoverableErrors(errors) {
|
16614 | if (workInProgressRootRecoverableErrors === null) {
|
16615 | workInProgressRootRecoverableErrors = errors;
|
16616 | } else {
|
16617 | workInProgressRootRecoverableErrors.push.apply(workInProgressRootRecoverableErrors, errors);
|
16618 | }
|
16619 | }
|
16620 |
|
16621 | function finishConcurrentRender(root, exitStatus, lanes) {
|
16622 | switch (exitStatus) {
|
16623 | case RootInProgress:
|
16624 | case RootFatalErrored:
|
16625 | {
|
16626 | throw new Error('Root did not complete. This is a bug in React.');
|
16627 | }
|
16628 |
|
16629 |
|
16630 |
|
16631 |
|
16632 | case RootErrored:
|
16633 | {
|
16634 |
|
16635 |
|
16636 | commitRoot(root, workInProgressRootRecoverableErrors);
|
16637 | break;
|
16638 | }
|
16639 |
|
16640 | case RootSuspended:
|
16641 | {
|
16642 | markRootSuspended$1(root, lanes);
|
16643 |
|
16644 |
|
16645 | if (includesOnlyRetries(lanes) &&
|
16646 | !shouldForceFlushFallbacksInDEV()) {
|
16647 |
|
16648 |
|
16649 | var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now();
|
16650 |
|
16651 | if (msUntilTimeout > 10) {
|
16652 | var nextLanes = getNextLanes(root, NoLanes);
|
16653 |
|
16654 | if (nextLanes !== NoLanes) {
|
16655 |
|
16656 | break;
|
16657 | }
|
16658 |
|
16659 | var suspendedLanes = root.suspendedLanes;
|
16660 |
|
16661 | if (!isSubsetOfLanes(suspendedLanes, lanes)) {
|
16662 |
|
16663 |
|
16664 |
|
16665 |
|
16666 | var eventTime = requestEventTime();
|
16667 | markRootPinged(root, suspendedLanes);
|
16668 | break;
|
16669 | }
|
16670 |
|
16671 |
|
16672 |
|
16673 |
|
16674 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root, workInProgressRootRecoverableErrors), msUntilTimeout);
|
16675 | break;
|
16676 | }
|
16677 | }
|
16678 |
|
16679 |
|
16680 | commitRoot(root, workInProgressRootRecoverableErrors);
|
16681 | break;
|
16682 | }
|
16683 |
|
16684 | case RootSuspendedWithDelay:
|
16685 | {
|
16686 | markRootSuspended$1(root, lanes);
|
16687 |
|
16688 | if (includesOnlyTransitions(lanes)) {
|
16689 |
|
16690 |
|
16691 |
|
16692 | break;
|
16693 | }
|
16694 |
|
16695 | if (!shouldForceFlushFallbacksInDEV()) {
|
16696 |
|
16697 |
|
16698 |
|
16699 |
|
16700 |
|
16701 |
|
16702 | var mostRecentEventTime = getMostRecentEventTime(root, lanes);
|
16703 | var eventTimeMs = mostRecentEventTime;
|
16704 | var timeElapsedMs = now() - eventTimeMs;
|
16705 |
|
16706 | var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs;
|
16707 |
|
16708 |
|
16709 | if (_msUntilTimeout > 10) {
|
16710 |
|
16711 |
|
16712 | root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root, workInProgressRootRecoverableErrors), _msUntilTimeout);
|
16713 | break;
|
16714 | }
|
16715 | }
|
16716 |
|
16717 |
|
16718 | commitRoot(root, workInProgressRootRecoverableErrors);
|
16719 | break;
|
16720 | }
|
16721 |
|
16722 | case RootCompleted:
|
16723 | {
|
16724 |
|
16725 | commitRoot(root, workInProgressRootRecoverableErrors);
|
16726 | break;
|
16727 | }
|
16728 |
|
16729 | default:
|
16730 | {
|
16731 | throw new Error('Unknown root exit status.');
|
16732 | }
|
16733 | }
|
16734 | }
|
16735 |
|
16736 | function isRenderConsistentWithExternalStores(finishedWork) {
|
16737 |
|
16738 |
|
16739 |
|
16740 | var node = finishedWork;
|
16741 |
|
16742 | while (true) {
|
16743 | if (node.flags & StoreConsistency) {
|
16744 | var updateQueue = node.updateQueue;
|
16745 |
|
16746 | if (updateQueue !== null) {
|
16747 | var checks = updateQueue.stores;
|
16748 |
|
16749 | if (checks !== null) {
|
16750 | for (var i = 0; i < checks.length; i++) {
|
16751 | var check = checks[i];
|
16752 | var getSnapshot = check.getSnapshot;
|
16753 | var renderedValue = check.value;
|
16754 |
|
16755 | try {
|
16756 | if (!objectIs(getSnapshot(), renderedValue)) {
|
16757 |
|
16758 | return false;
|
16759 | }
|
16760 | } catch (error) {
|
16761 |
|
16762 |
|
16763 | return false;
|
16764 | }
|
16765 | }
|
16766 | }
|
16767 | }
|
16768 | }
|
16769 |
|
16770 | var child = node.child;
|
16771 |
|
16772 | if (node.subtreeFlags & StoreConsistency && child !== null) {
|
16773 | child.return = node;
|
16774 | node = child;
|
16775 | continue;
|
16776 | }
|
16777 |
|
16778 | if (node === finishedWork) {
|
16779 | return true;
|
16780 | }
|
16781 |
|
16782 | while (node.sibling === null) {
|
16783 | if (node.return === null || node.return === finishedWork) {
|
16784 | return true;
|
16785 | }
|
16786 |
|
16787 | node = node.return;
|
16788 | }
|
16789 |
|
16790 | node.sibling.return = node.return;
|
16791 | node = node.sibling;
|
16792 | }
|
16793 |
|
16794 |
|
16795 |
|
16796 | return true;
|
16797 | }
|
16798 |
|
16799 | function markRootSuspended$1(root, suspendedLanes) {
|
16800 |
|
16801 |
|
16802 |
|
16803 |
|
16804 | suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes);
|
16805 | suspendedLanes = removeLanes(suspendedLanes, workInProgressRootInterleavedUpdatedLanes);
|
16806 | markRootSuspended(root, suspendedLanes);
|
16807 | }
|
16808 |
|
16809 |
|
16810 |
|
16811 | function performSyncWorkOnRoot(root) {
|
16812 | {
|
16813 | syncNestedUpdateFlag();
|
16814 | }
|
16815 |
|
16816 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
16817 | throw new Error('Should not already be working.');
|
16818 | }
|
16819 |
|
16820 | flushPassiveEffects();
|
16821 | var lanes = getNextLanes(root, NoLanes);
|
16822 |
|
16823 | if (!includesSomeLane(lanes, SyncLane)) {
|
16824 |
|
16825 | ensureRootIsScheduled(root, now());
|
16826 | return null;
|
16827 | }
|
16828 |
|
16829 | var exitStatus = renderRootSync(root, lanes);
|
16830 |
|
16831 | if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
|
16832 |
|
16833 |
|
16834 |
|
16835 |
|
16836 | var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
|
16837 |
|
16838 | if (errorRetryLanes !== NoLanes) {
|
16839 | lanes = errorRetryLanes;
|
16840 | exitStatus = recoverFromConcurrentError(root, errorRetryLanes);
|
16841 | }
|
16842 | }
|
16843 |
|
16844 | if (exitStatus === RootFatalErrored) {
|
16845 | var fatalError = workInProgressRootFatalError;
|
16846 | prepareFreshStack(root, NoLanes);
|
16847 | markRootSuspended$1(root, lanes);
|
16848 | ensureRootIsScheduled(root, now());
|
16849 | throw fatalError;
|
16850 | }
|
16851 |
|
16852 | if (exitStatus === RootDidNotComplete) {
|
16853 | throw new Error('Root did not complete. This is a bug in React.');
|
16854 | }
|
16855 |
|
16856 |
|
16857 |
|
16858 | var finishedWork = root.current.alternate;
|
16859 | root.finishedWork = finishedWork;
|
16860 | root.finishedLanes = lanes;
|
16861 | commitRoot(root, workInProgressRootRecoverableErrors);
|
16862 |
|
16863 |
|
16864 | ensureRootIsScheduled(root, now());
|
16865 | return null;
|
16866 | }
|
16867 |
|
16868 |
|
16869 |
|
16870 | function flushSync(fn) {
|
16871 |
|
16872 |
|
16873 | if (rootWithPendingPassiveEffects !== null && rootWithPendingPassiveEffects.tag === LegacyRoot && (executionContext & (RenderContext | CommitContext)) === NoContext) {
|
16874 | flushPassiveEffects();
|
16875 | }
|
16876 |
|
16877 | var prevExecutionContext = executionContext;
|
16878 | executionContext |= BatchedContext;
|
16879 | var prevTransition = ReactCurrentBatchConfig$2.transition;
|
16880 | var previousPriority = getCurrentUpdatePriority();
|
16881 |
|
16882 | try {
|
16883 | ReactCurrentBatchConfig$2.transition = null;
|
16884 | setCurrentUpdatePriority(DiscreteEventPriority);
|
16885 |
|
16886 | if (fn) {
|
16887 | return fn();
|
16888 | } else {
|
16889 | return undefined;
|
16890 | }
|
16891 | } finally {
|
16892 | setCurrentUpdatePriority(previousPriority);
|
16893 | ReactCurrentBatchConfig$2.transition = prevTransition;
|
16894 | executionContext = prevExecutionContext;
|
16895 |
|
16896 |
|
16897 |
|
16898 | if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
|
16899 | flushSyncCallbacks();
|
16900 | }
|
16901 | }
|
16902 | }
|
16903 | function pushRenderLanes(fiber, lanes) {
|
16904 | push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber);
|
16905 | subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes);
|
16906 | workInProgressRootIncludedLanes = mergeLanes(workInProgressRootIncludedLanes, lanes);
|
16907 | }
|
16908 | function popRenderLanes(fiber) {
|
16909 | subtreeRenderLanes = subtreeRenderLanesCursor.current;
|
16910 | pop(subtreeRenderLanesCursor, fiber);
|
16911 | }
|
16912 |
|
16913 | function prepareFreshStack(root, lanes) {
|
16914 | root.finishedWork = null;
|
16915 | root.finishedLanes = NoLanes;
|
16916 | var timeoutHandle = root.timeoutHandle;
|
16917 |
|
16918 | if (timeoutHandle !== noTimeout) {
|
16919 |
|
16920 |
|
16921 | root.timeoutHandle = noTimeout;
|
16922 |
|
16923 | cancelTimeout(timeoutHandle);
|
16924 | }
|
16925 |
|
16926 | if (workInProgress !== null) {
|
16927 | var interruptedWork = workInProgress.return;
|
16928 |
|
16929 | while (interruptedWork !== null) {
|
16930 | var current = interruptedWork.alternate;
|
16931 | unwindInterruptedWork(current, interruptedWork);
|
16932 | interruptedWork = interruptedWork.return;
|
16933 | }
|
16934 | }
|
16935 |
|
16936 | workInProgressRoot = root;
|
16937 | var rootWorkInProgress = createWorkInProgress(root.current, null);
|
16938 | workInProgress = rootWorkInProgress;
|
16939 | workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
|
16940 | workInProgressRootExitStatus = RootInProgress;
|
16941 | workInProgressRootFatalError = null;
|
16942 | workInProgressRootSkippedLanes = NoLanes;
|
16943 | workInProgressRootInterleavedUpdatedLanes = NoLanes;
|
16944 | workInProgressRootPingedLanes = NoLanes;
|
16945 | workInProgressRootConcurrentErrors = null;
|
16946 | workInProgressRootRecoverableErrors = null;
|
16947 | enqueueInterleavedUpdates();
|
16948 |
|
16949 | {
|
16950 | ReactStrictModeWarnings.discardPendingWarnings();
|
16951 | }
|
16952 |
|
16953 | return rootWorkInProgress;
|
16954 | }
|
16955 |
|
16956 | function handleError(root, thrownValue) {
|
16957 | do {
|
16958 | var erroredWork = workInProgress;
|
16959 |
|
16960 | try {
|
16961 |
|
16962 | resetContextDependencies();
|
16963 | resetHooksAfterThrow();
|
16964 | resetCurrentFiber();
|
16965 |
|
16966 |
|
16967 | ReactCurrentOwner$2.current = null;
|
16968 |
|
16969 | if (erroredWork === null || erroredWork.return === null) {
|
16970 |
|
16971 |
|
16972 |
|
16973 |
|
16974 | workInProgressRootExitStatus = RootFatalErrored;
|
16975 | workInProgressRootFatalError = thrownValue;
|
16976 |
|
16977 |
|
16978 |
|
16979 |
|
16980 |
|
16981 |
|
16982 | workInProgress = null;
|
16983 | return;
|
16984 | }
|
16985 |
|
16986 | if (enableProfilerTimer && erroredWork.mode & ProfileMode) {
|
16987 |
|
16988 |
|
16989 |
|
16990 | stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
|
16991 | }
|
16992 |
|
16993 | if (enableSchedulingProfiler) {
|
16994 | markComponentRenderStopped();
|
16995 |
|
16996 | if (thrownValue !== null && typeof thrownValue === 'object' && typeof thrownValue.then === 'function') {
|
16997 | var wakeable = thrownValue;
|
16998 | markComponentSuspended(erroredWork, wakeable, workInProgressRootRenderLanes);
|
16999 | } else {
|
17000 | markComponentErrored(erroredWork, thrownValue, workInProgressRootRenderLanes);
|
17001 | }
|
17002 | }
|
17003 |
|
17004 | throwException(root, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes);
|
17005 | completeUnitOfWork(erroredWork);
|
17006 | } catch (yetAnotherThrownValue) {
|
17007 |
|
17008 | thrownValue = yetAnotherThrownValue;
|
17009 |
|
17010 | if (workInProgress === erroredWork && erroredWork !== null) {
|
17011 |
|
17012 |
|
17013 | erroredWork = erroredWork.return;
|
17014 | workInProgress = erroredWork;
|
17015 | } else {
|
17016 | erroredWork = workInProgress;
|
17017 | }
|
17018 |
|
17019 | continue;
|
17020 | }
|
17021 |
|
17022 |
|
17023 | return;
|
17024 | } while (true);
|
17025 | }
|
17026 |
|
17027 | function pushDispatcher() {
|
17028 | var prevDispatcher = ReactCurrentDispatcher$2.current;
|
17029 | ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
|
17030 |
|
17031 | if (prevDispatcher === null) {
|
17032 |
|
17033 |
|
17034 |
|
17035 | return ContextOnlyDispatcher;
|
17036 | } else {
|
17037 | return prevDispatcher;
|
17038 | }
|
17039 | }
|
17040 |
|
17041 | function popDispatcher(prevDispatcher) {
|
17042 | ReactCurrentDispatcher$2.current = prevDispatcher;
|
17043 | }
|
17044 |
|
17045 | function markCommitTimeOfFallback() {
|
17046 | globalMostRecentFallbackTime = now();
|
17047 | }
|
17048 | function markSkippedUpdateLanes(lane) {
|
17049 | workInProgressRootSkippedLanes = mergeLanes(lane, workInProgressRootSkippedLanes);
|
17050 | }
|
17051 | function renderDidSuspend() {
|
17052 | if (workInProgressRootExitStatus === RootInProgress) {
|
17053 | workInProgressRootExitStatus = RootSuspended;
|
17054 | }
|
17055 | }
|
17056 | function renderDidSuspendDelayIfPossible() {
|
17057 | if (workInProgressRootExitStatus === RootInProgress || workInProgressRootExitStatus === RootSuspended || workInProgressRootExitStatus === RootErrored) {
|
17058 | workInProgressRootExitStatus = RootSuspendedWithDelay;
|
17059 | }
|
17060 |
|
17061 |
|
17062 |
|
17063 | if (workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || includesNonIdleWork(workInProgressRootInterleavedUpdatedLanes))) {
|
17064 |
|
17065 |
|
17066 |
|
17067 |
|
17068 |
|
17069 |
|
17070 |
|
17071 | markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
|
17072 | }
|
17073 | }
|
17074 | function renderDidError(error) {
|
17075 | if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
|
17076 | workInProgressRootExitStatus = RootErrored;
|
17077 | }
|
17078 |
|
17079 | if (workInProgressRootConcurrentErrors === null) {
|
17080 | workInProgressRootConcurrentErrors = [error];
|
17081 | } else {
|
17082 | workInProgressRootConcurrentErrors.push(error);
|
17083 | }
|
17084 | }
|
17085 |
|
17086 |
|
17087 | function renderHasNotSuspendedYet() {
|
17088 |
|
17089 |
|
17090 | return workInProgressRootExitStatus === RootInProgress;
|
17091 | }
|
17092 |
|
17093 | function renderRootSync(root, lanes) {
|
17094 | var prevExecutionContext = executionContext;
|
17095 | executionContext |= RenderContext;
|
17096 | var prevDispatcher = pushDispatcher();
|
17097 |
|
17098 |
|
17099 | if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
|
17100 | {
|
17101 | if (isDevToolsPresent) {
|
17102 | var memoizedUpdaters = root.memoizedUpdaters;
|
17103 |
|
17104 | if (memoizedUpdaters.size > 0) {
|
17105 | restorePendingUpdaters(root, workInProgressRootRenderLanes);
|
17106 | memoizedUpdaters.clear();
|
17107 | }
|
17108 |
|
17109 |
|
17110 |
|
17111 |
|
17112 |
|
17113 | movePendingFibersToMemoized(root, lanes);
|
17114 | }
|
17115 | }
|
17116 | prepareFreshStack(root, lanes);
|
17117 | }
|
17118 |
|
17119 | {
|
17120 | markRenderStarted(lanes);
|
17121 | }
|
17122 |
|
17123 | do {
|
17124 | try {
|
17125 | workLoopSync();
|
17126 | break;
|
17127 | } catch (thrownValue) {
|
17128 | handleError(root, thrownValue);
|
17129 | }
|
17130 | } while (true);
|
17131 |
|
17132 | resetContextDependencies();
|
17133 | executionContext = prevExecutionContext;
|
17134 | popDispatcher(prevDispatcher);
|
17135 |
|
17136 | if (workInProgress !== null) {
|
17137 |
|
17138 | throw new Error('Cannot commit an incomplete root. This error is likely caused by a ' + 'bug in React. Please file an issue.');
|
17139 | }
|
17140 |
|
17141 | {
|
17142 | markRenderStopped();
|
17143 | }
|
17144 |
|
17145 |
|
17146 | workInProgressRoot = null;
|
17147 | workInProgressRootRenderLanes = NoLanes;
|
17148 | return workInProgressRootExitStatus;
|
17149 | }
|
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 | function workLoopSync() {
|
17155 |
|
17156 | while (workInProgress !== null) {
|
17157 | performUnitOfWork(workInProgress);
|
17158 | }
|
17159 | }
|
17160 |
|
17161 | function renderRootConcurrent(root, lanes) {
|
17162 | var prevExecutionContext = executionContext;
|
17163 | executionContext |= RenderContext;
|
17164 | var prevDispatcher = pushDispatcher();
|
17165 |
|
17166 |
|
17167 | if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
|
17168 | {
|
17169 | if (isDevToolsPresent) {
|
17170 | var memoizedUpdaters = root.memoizedUpdaters;
|
17171 |
|
17172 | if (memoizedUpdaters.size > 0) {
|
17173 | restorePendingUpdaters(root, workInProgressRootRenderLanes);
|
17174 | memoizedUpdaters.clear();
|
17175 | }
|
17176 |
|
17177 |
|
17178 |
|
17179 |
|
17180 |
|
17181 | movePendingFibersToMemoized(root, lanes);
|
17182 | }
|
17183 | }
|
17184 | resetRenderTimer();
|
17185 | prepareFreshStack(root, lanes);
|
17186 | }
|
17187 |
|
17188 | {
|
17189 | markRenderStarted(lanes);
|
17190 | }
|
17191 |
|
17192 | do {
|
17193 | try {
|
17194 | workLoopConcurrent();
|
17195 | break;
|
17196 | } catch (thrownValue) {
|
17197 | handleError(root, thrownValue);
|
17198 | }
|
17199 | } while (true);
|
17200 |
|
17201 | resetContextDependencies();
|
17202 | popDispatcher(prevDispatcher);
|
17203 | executionContext = prevExecutionContext;
|
17204 |
|
17205 |
|
17206 | if (workInProgress !== null) {
|
17207 |
|
17208 | {
|
17209 | markRenderYielded();
|
17210 | }
|
17211 |
|
17212 | return RootInProgress;
|
17213 | } else {
|
17214 |
|
17215 | {
|
17216 | markRenderStopped();
|
17217 | }
|
17218 |
|
17219 |
|
17220 | workInProgressRoot = null;
|
17221 | workInProgressRootRenderLanes = NoLanes;
|
17222 |
|
17223 | return workInProgressRootExitStatus;
|
17224 | }
|
17225 | }
|
17226 |
|
17227 |
|
17228 |
|
17229 | function workLoopConcurrent() {
|
17230 |
|
17231 | while (workInProgress !== null && !shouldYield()) {
|
17232 | performUnitOfWork(workInProgress);
|
17233 | }
|
17234 | }
|
17235 |
|
17236 | function performUnitOfWork(unitOfWork) {
|
17237 |
|
17238 |
|
17239 |
|
17240 | var current = unitOfWork.alternate;
|
17241 | setCurrentFiber(unitOfWork);
|
17242 | var next;
|
17243 |
|
17244 | if ( (unitOfWork.mode & ProfileMode) !== NoMode) {
|
17245 | startProfilerTimer(unitOfWork);
|
17246 | next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
|
17247 | stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
|
17248 | } else {
|
17249 | next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
|
17250 | }
|
17251 |
|
17252 | resetCurrentFiber();
|
17253 | unitOfWork.memoizedProps = unitOfWork.pendingProps;
|
17254 |
|
17255 | if (next === null) {
|
17256 |
|
17257 | completeUnitOfWork(unitOfWork);
|
17258 | } else {
|
17259 | workInProgress = next;
|
17260 | }
|
17261 |
|
17262 | ReactCurrentOwner$2.current = null;
|
17263 | }
|
17264 |
|
17265 | function completeUnitOfWork(unitOfWork) {
|
17266 |
|
17267 |
|
17268 | var completedWork = unitOfWork;
|
17269 |
|
17270 | do {
|
17271 |
|
17272 |
|
17273 |
|
17274 | var current = completedWork.alternate;
|
17275 | var returnFiber = completedWork.return;
|
17276 |
|
17277 | if ((completedWork.flags & Incomplete) === NoFlags) {
|
17278 | setCurrentFiber(completedWork);
|
17279 | var next = void 0;
|
17280 |
|
17281 | if ( (completedWork.mode & ProfileMode) === NoMode) {
|
17282 | next = completeWork(current, completedWork, subtreeRenderLanes);
|
17283 | } else {
|
17284 | startProfilerTimer(completedWork);
|
17285 | next = completeWork(current, completedWork, subtreeRenderLanes);
|
17286 |
|
17287 | stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
|
17288 | }
|
17289 |
|
17290 | resetCurrentFiber();
|
17291 |
|
17292 | if (next !== null) {
|
17293 |
|
17294 | workInProgress = next;
|
17295 | return;
|
17296 | }
|
17297 | } else {
|
17298 |
|
17299 |
|
17300 |
|
17301 | var _next = unwindWork(current, completedWork);
|
17302 |
|
17303 |
|
17304 | if (_next !== null) {
|
17305 |
|
17306 |
|
17307 |
|
17308 |
|
17309 | _next.flags &= HostEffectMask;
|
17310 | workInProgress = _next;
|
17311 | return;
|
17312 | }
|
17313 |
|
17314 | if ( (completedWork.mode & ProfileMode) !== NoMode) {
|
17315 |
|
17316 | stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
|
17317 |
|
17318 | var actualDuration = completedWork.actualDuration;
|
17319 | var child = completedWork.child;
|
17320 |
|
17321 | while (child !== null) {
|
17322 | actualDuration += child.actualDuration;
|
17323 | child = child.sibling;
|
17324 | }
|
17325 |
|
17326 | completedWork.actualDuration = actualDuration;
|
17327 | }
|
17328 |
|
17329 | if (returnFiber !== null) {
|
17330 |
|
17331 | returnFiber.flags |= Incomplete;
|
17332 | returnFiber.subtreeFlags = NoFlags;
|
17333 | returnFiber.deletions = null;
|
17334 | } else {
|
17335 |
|
17336 | workInProgressRootExitStatus = RootDidNotComplete;
|
17337 | workInProgress = null;
|
17338 | return;
|
17339 | }
|
17340 | }
|
17341 |
|
17342 | var siblingFiber = completedWork.sibling;
|
17343 |
|
17344 | if (siblingFiber !== null) {
|
17345 |
|
17346 | workInProgress = siblingFiber;
|
17347 | return;
|
17348 | }
|
17349 |
|
17350 |
|
17351 | completedWork = returnFiber;
|
17352 |
|
17353 | workInProgress = completedWork;
|
17354 | } while (completedWork !== null);
|
17355 |
|
17356 |
|
17357 | if (workInProgressRootExitStatus === RootInProgress) {
|
17358 | workInProgressRootExitStatus = RootCompleted;
|
17359 | }
|
17360 | }
|
17361 |
|
17362 | function commitRoot(root, recoverableErrors) {
|
17363 |
|
17364 |
|
17365 | var previousUpdateLanePriority = getCurrentUpdatePriority();
|
17366 | var prevTransition = ReactCurrentBatchConfig$2.transition;
|
17367 |
|
17368 | try {
|
17369 | ReactCurrentBatchConfig$2.transition = null;
|
17370 | setCurrentUpdatePriority(DiscreteEventPriority);
|
17371 | commitRootImpl(root, recoverableErrors, previousUpdateLanePriority);
|
17372 | } finally {
|
17373 | ReactCurrentBatchConfig$2.transition = prevTransition;
|
17374 | setCurrentUpdatePriority(previousUpdateLanePriority);
|
17375 | }
|
17376 |
|
17377 | return null;
|
17378 | }
|
17379 |
|
17380 | function commitRootImpl(root, recoverableErrors, renderPriorityLevel) {
|
17381 | do {
|
17382 |
|
17383 |
|
17384 |
|
17385 |
|
17386 |
|
17387 |
|
17388 | flushPassiveEffects();
|
17389 | } while (rootWithPendingPassiveEffects !== null);
|
17390 |
|
17391 | flushRenderPhaseStrictModeWarningsInDEV();
|
17392 |
|
17393 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
17394 | throw new Error('Should not already be working.');
|
17395 | }
|
17396 |
|
17397 | var finishedWork = root.finishedWork;
|
17398 | var lanes = root.finishedLanes;
|
17399 |
|
17400 | {
|
17401 | markCommitStarted(lanes);
|
17402 | }
|
17403 |
|
17404 | if (finishedWork === null) {
|
17405 |
|
17406 | {
|
17407 | markCommitStopped();
|
17408 | }
|
17409 |
|
17410 | return null;
|
17411 | } else {
|
17412 | {
|
17413 | if (lanes === NoLanes) {
|
17414 | error('root.finishedLanes should not be empty during a commit. This is a ' + 'bug in React.');
|
17415 | }
|
17416 | }
|
17417 | }
|
17418 |
|
17419 | root.finishedWork = null;
|
17420 | root.finishedLanes = NoLanes;
|
17421 |
|
17422 | if (finishedWork === root.current) {
|
17423 | throw new Error('Cannot commit the same tree as before. This error is likely caused by ' + 'a bug in React. Please file an issue.');
|
17424 | }
|
17425 |
|
17426 |
|
17427 |
|
17428 | root.callbackNode = null;
|
17429 | root.callbackPriority = NoLane;
|
17430 |
|
17431 |
|
17432 | var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes);
|
17433 | markRootFinished(root, remainingLanes);
|
17434 |
|
17435 | if (root === workInProgressRoot) {
|
17436 |
|
17437 | workInProgressRoot = null;
|
17438 | workInProgress = null;
|
17439 | workInProgressRootRenderLanes = NoLanes;
|
17440 | }
|
17441 |
|
17442 |
|
17443 |
|
17444 |
|
17445 |
|
17446 |
|
17447 | if ((finishedWork.subtreeFlags & PassiveMask) !== NoFlags || (finishedWork.flags & PassiveMask) !== NoFlags) {
|
17448 | if (!rootDoesHavePassiveEffects) {
|
17449 | rootDoesHavePassiveEffects = true;
|
17450 | scheduleCallback$1(NormalPriority, function () {
|
17451 | flushPassiveEffects();
|
17452 |
|
17453 |
|
17454 |
|
17455 | return null;
|
17456 | });
|
17457 | }
|
17458 | }
|
17459 |
|
17460 |
|
17461 |
|
17462 |
|
17463 |
|
17464 |
|
17465 | var subtreeHasEffects = (finishedWork.subtreeFlags & (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== NoFlags;
|
17466 | var rootHasEffect = (finishedWork.flags & (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== NoFlags;
|
17467 |
|
17468 | if (subtreeHasEffects || rootHasEffect) {
|
17469 | var prevTransition = ReactCurrentBatchConfig$2.transition;
|
17470 | ReactCurrentBatchConfig$2.transition = null;
|
17471 | var previousPriority = getCurrentUpdatePriority();
|
17472 | setCurrentUpdatePriority(DiscreteEventPriority);
|
17473 | var prevExecutionContext = executionContext;
|
17474 | executionContext |= CommitContext;
|
17475 |
|
17476 | ReactCurrentOwner$2.current = null;
|
17477 |
|
17478 |
|
17479 |
|
17480 |
|
17481 |
|
17482 |
|
17483 | var shouldFireAfterActiveInstanceBlur = commitBeforeMutationEffects(root, finishedWork);
|
17484 |
|
17485 | {
|
17486 |
|
17487 |
|
17488 | recordCommitTime();
|
17489 | }
|
17490 |
|
17491 |
|
17492 | commitMutationEffects(root, finishedWork, lanes);
|
17493 |
|
17494 | resetAfterCommit(root.containerInfo);
|
17495 |
|
17496 |
|
17497 |
|
17498 |
|
17499 | root.current = finishedWork;
|
17500 |
|
17501 | {
|
17502 | markLayoutEffectsStarted(lanes);
|
17503 | }
|
17504 |
|
17505 | commitLayoutEffects(finishedWork, root, lanes);
|
17506 |
|
17507 | {
|
17508 | markLayoutEffectsStopped();
|
17509 | }
|
17510 |
|
17511 |
|
17512 |
|
17513 | requestPaint();
|
17514 | executionContext = prevExecutionContext;
|
17515 |
|
17516 | setCurrentUpdatePriority(previousPriority);
|
17517 | ReactCurrentBatchConfig$2.transition = prevTransition;
|
17518 | } else {
|
17519 |
|
17520 | root.current = finishedWork;
|
17521 |
|
17522 |
|
17523 |
|
17524 | {
|
17525 | recordCommitTime();
|
17526 | }
|
17527 | }
|
17528 |
|
17529 | var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
|
17530 |
|
17531 | if (rootDoesHavePassiveEffects) {
|
17532 |
|
17533 |
|
17534 | rootDoesHavePassiveEffects = false;
|
17535 | rootWithPendingPassiveEffects = root;
|
17536 | pendingPassiveEffectsLanes = lanes;
|
17537 | }
|
17538 |
|
17539 |
|
17540 | remainingLanes = root.pendingLanes;
|
17541 |
|
17542 |
|
17543 |
|
17544 |
|
17545 |
|
17546 |
|
17547 |
|
17548 |
|
17549 |
|
17550 |
|
17551 | if (remainingLanes === NoLanes) {
|
17552 |
|
17553 |
|
17554 | legacyErrorBoundariesThatAlreadyFailed = null;
|
17555 | }
|
17556 |
|
17557 | {
|
17558 | if (!rootDidHavePassiveEffects) {
|
17559 | commitDoubleInvokeEffectsInDEV(root.current, false);
|
17560 | }
|
17561 | }
|
17562 |
|
17563 | onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
|
17564 |
|
17565 | {
|
17566 | if (isDevToolsPresent) {
|
17567 | root.memoizedUpdaters.clear();
|
17568 | }
|
17569 | }
|
17570 |
|
17571 |
|
17572 |
|
17573 | ensureRootIsScheduled(root, now());
|
17574 |
|
17575 | if (recoverableErrors !== null) {
|
17576 |
|
17577 |
|
17578 | var onRecoverableError = root.onRecoverableError;
|
17579 |
|
17580 | for (var i = 0; i < recoverableErrors.length; i++) {
|
17581 | var recoverableError = recoverableErrors[i];
|
17582 | onRecoverableError(recoverableError);
|
17583 | }
|
17584 | }
|
17585 |
|
17586 | if (hasUncaughtError) {
|
17587 | hasUncaughtError = false;
|
17588 | var error$1 = firstUncaughtError;
|
17589 | firstUncaughtError = null;
|
17590 | throw error$1;
|
17591 | }
|
17592 |
|
17593 |
|
17594 |
|
17595 |
|
17596 |
|
17597 |
|
17598 |
|
17599 |
|
17600 |
|
17601 | if (includesSomeLane(pendingPassiveEffectsLanes, SyncLane) && root.tag !== LegacyRoot) {
|
17602 | flushPassiveEffects();
|
17603 | }
|
17604 |
|
17605 |
|
17606 | remainingLanes = root.pendingLanes;
|
17607 |
|
17608 | if (includesSomeLane(remainingLanes, SyncLane)) {
|
17609 | {
|
17610 | markNestedUpdateScheduled();
|
17611 | }
|
17612 |
|
17613 |
|
17614 |
|
17615 | if (root === rootWithNestedUpdates) {
|
17616 | nestedUpdateCount++;
|
17617 | } else {
|
17618 | nestedUpdateCount = 0;
|
17619 | rootWithNestedUpdates = root;
|
17620 | }
|
17621 | } else {
|
17622 | nestedUpdateCount = 0;
|
17623 | }
|
17624 |
|
17625 |
|
17626 | flushSyncCallbacks();
|
17627 |
|
17628 | {
|
17629 | markCommitStopped();
|
17630 | }
|
17631 |
|
17632 | return null;
|
17633 | }
|
17634 |
|
17635 | function flushPassiveEffects() {
|
17636 |
|
17637 |
|
17638 |
|
17639 |
|
17640 |
|
17641 |
|
17642 | if (rootWithPendingPassiveEffects !== null) {
|
17643 | var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes);
|
17644 | var priority = lowerEventPriority(DefaultEventPriority, renderPriority);
|
17645 | var prevTransition = ReactCurrentBatchConfig$2.transition;
|
17646 | var previousPriority = getCurrentUpdatePriority();
|
17647 |
|
17648 | try {
|
17649 | ReactCurrentBatchConfig$2.transition = null;
|
17650 | setCurrentUpdatePriority(priority);
|
17651 | return flushPassiveEffectsImpl();
|
17652 | } finally {
|
17653 | setCurrentUpdatePriority(previousPriority);
|
17654 | ReactCurrentBatchConfig$2.transition = prevTransition;
|
17655 | }
|
17656 | }
|
17657 |
|
17658 | return false;
|
17659 | }
|
17660 | function enqueuePendingPassiveProfilerEffect(fiber) {
|
17661 | {
|
17662 | pendingPassiveProfilerEffects.push(fiber);
|
17663 |
|
17664 | if (!rootDoesHavePassiveEffects) {
|
17665 | rootDoesHavePassiveEffects = true;
|
17666 | scheduleCallback$1(NormalPriority, function () {
|
17667 | flushPassiveEffects();
|
17668 | return null;
|
17669 | });
|
17670 | }
|
17671 | }
|
17672 | }
|
17673 |
|
17674 | function flushPassiveEffectsImpl() {
|
17675 | if (rootWithPendingPassiveEffects === null) {
|
17676 | return false;
|
17677 | }
|
17678 |
|
17679 | var root = rootWithPendingPassiveEffects;
|
17680 | var lanes = pendingPassiveEffectsLanes;
|
17681 | rootWithPendingPassiveEffects = null;
|
17682 |
|
17683 |
|
17684 |
|
17685 | pendingPassiveEffectsLanes = NoLanes;
|
17686 |
|
17687 | if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
17688 | throw new Error('Cannot flush passive effects while already rendering.');
|
17689 | }
|
17690 |
|
17691 | {
|
17692 | markPassiveEffectsStarted(lanes);
|
17693 | }
|
17694 |
|
17695 | var prevExecutionContext = executionContext;
|
17696 | executionContext |= CommitContext;
|
17697 | commitPassiveUnmountEffects(root.current);
|
17698 | commitPassiveMountEffects(root, root.current);
|
17699 |
|
17700 | {
|
17701 | var profilerEffects = pendingPassiveProfilerEffects;
|
17702 | pendingPassiveProfilerEffects = [];
|
17703 |
|
17704 | for (var i = 0; i < profilerEffects.length; i++) {
|
17705 | var _fiber = profilerEffects[i];
|
17706 | commitPassiveEffectDurations(root, _fiber);
|
17707 | }
|
17708 | }
|
17709 |
|
17710 | {
|
17711 | markPassiveEffectsStopped();
|
17712 | }
|
17713 |
|
17714 | {
|
17715 | commitDoubleInvokeEffectsInDEV(root.current, true);
|
17716 | }
|
17717 |
|
17718 | executionContext = prevExecutionContext;
|
17719 | flushSyncCallbacks();
|
17720 |
|
17721 |
|
17722 | nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
|
17723 |
|
17724 | onPostCommitRoot(root);
|
17725 |
|
17726 | {
|
17727 | var stateNode = root.current.stateNode;
|
17728 | stateNode.effectDuration = 0;
|
17729 | stateNode.passiveEffectDuration = 0;
|
17730 | }
|
17731 |
|
17732 | return true;
|
17733 | }
|
17734 |
|
17735 | function isAlreadyFailedLegacyErrorBoundary(instance) {
|
17736 | return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
|
17737 | }
|
17738 | function markLegacyErrorBoundaryAsFailed(instance) {
|
17739 | if (legacyErrorBoundariesThatAlreadyFailed === null) {
|
17740 | legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
|
17741 | } else {
|
17742 | legacyErrorBoundariesThatAlreadyFailed.add(instance);
|
17743 | }
|
17744 | }
|
17745 |
|
17746 | function prepareToThrowUncaughtError(error) {
|
17747 | if (!hasUncaughtError) {
|
17748 | hasUncaughtError = true;
|
17749 | firstUncaughtError = error;
|
17750 | }
|
17751 | }
|
17752 |
|
17753 | var onUncaughtError = prepareToThrowUncaughtError;
|
17754 |
|
17755 | function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
|
17756 | var errorInfo = createCapturedValue(error, sourceFiber);
|
17757 | var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane);
|
17758 | enqueueUpdate(rootFiber, update);
|
17759 | var eventTime = requestEventTime();
|
17760 | var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane);
|
17761 |
|
17762 | if (root !== null) {
|
17763 | markRootUpdated(root, SyncLane, eventTime);
|
17764 | ensureRootIsScheduled(root, eventTime);
|
17765 | }
|
17766 | }
|
17767 |
|
17768 | function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) {
|
17769 | if (sourceFiber.tag === HostRoot) {
|
17770 |
|
17771 |
|
17772 | captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error$1);
|
17773 | return;
|
17774 | }
|
17775 |
|
17776 | var fiber = null;
|
17777 |
|
17778 | {
|
17779 | fiber = nearestMountedAncestor;
|
17780 | }
|
17781 |
|
17782 | while (fiber !== null) {
|
17783 | if (fiber.tag === HostRoot) {
|
17784 | captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$1);
|
17785 | return;
|
17786 | } else if (fiber.tag === ClassComponent) {
|
17787 | var ctor = fiber.type;
|
17788 | var instance = fiber.stateNode;
|
17789 |
|
17790 | if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
|
17791 | var errorInfo = createCapturedValue(error$1, sourceFiber);
|
17792 | var update = createClassErrorUpdate(fiber, errorInfo, SyncLane);
|
17793 | enqueueUpdate(fiber, update);
|
17794 | var eventTime = requestEventTime();
|
17795 | var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane);
|
17796 |
|
17797 | if (root !== null) {
|
17798 | markRootUpdated(root, SyncLane, eventTime);
|
17799 | ensureRootIsScheduled(root, eventTime);
|
17800 | }
|
17801 |
|
17802 | return;
|
17803 | }
|
17804 | }
|
17805 |
|
17806 | fiber = fiber.return;
|
17807 | }
|
17808 |
|
17809 | {
|
17810 |
|
17811 |
|
17812 |
|
17813 |
|
17814 |
|
17815 | error('Internal React error: Attempted to capture a commit phase error ' + 'inside a detached tree. This indicates a bug in React. Likely ' + 'causes include deleting the same fiber more than once, committing an ' + 'already-finished tree, or an inconsistent return pointer.\n\n' + 'Error message:\n\n%s', error$1);
|
17816 | }
|
17817 | }
|
17818 | function pingSuspendedRoot(root, wakeable, pingedLanes) {
|
17819 | var pingCache = root.pingCache;
|
17820 |
|
17821 | if (pingCache !== null) {
|
17822 |
|
17823 |
|
17824 | pingCache.delete(wakeable);
|
17825 | }
|
17826 |
|
17827 | var eventTime = requestEventTime();
|
17828 | markRootPinged(root, pingedLanes);
|
17829 | warnIfSuspenseResolutionNotWrappedWithActDEV(root);
|
17830 |
|
17831 | if (workInProgressRoot === root && isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)) {
|
17832 |
|
17833 |
|
17834 |
|
17835 |
|
17836 |
|
17837 |
|
17838 |
|
17839 | if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && includesOnlyRetries(workInProgressRootRenderLanes) && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
|
17840 |
|
17841 | prepareFreshStack(root, NoLanes);
|
17842 | } else {
|
17843 |
|
17844 |
|
17845 | workInProgressRootPingedLanes = mergeLanes(workInProgressRootPingedLanes, pingedLanes);
|
17846 | }
|
17847 | }
|
17848 |
|
17849 | ensureRootIsScheduled(root, eventTime);
|
17850 | }
|
17851 |
|
17852 | function retryTimedOutBoundary(boundaryFiber, retryLane) {
|
17853 |
|
17854 |
|
17855 |
|
17856 |
|
17857 | if (retryLane === NoLane) {
|
17858 |
|
17859 |
|
17860 | retryLane = requestRetryLane(boundaryFiber);
|
17861 | }
|
17862 |
|
17863 |
|
17864 | var eventTime = requestEventTime();
|
17865 | var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane);
|
17866 |
|
17867 | if (root !== null) {
|
17868 | markRootUpdated(root, retryLane, eventTime);
|
17869 | ensureRootIsScheduled(root, eventTime);
|
17870 | }
|
17871 | }
|
17872 |
|
17873 | function retryDehydratedSuspenseBoundary(boundaryFiber) {
|
17874 | var suspenseState = boundaryFiber.memoizedState;
|
17875 | var retryLane = NoLane;
|
17876 |
|
17877 | if (suspenseState !== null) {
|
17878 | retryLane = suspenseState.retryLane;
|
17879 | }
|
17880 |
|
17881 | retryTimedOutBoundary(boundaryFiber, retryLane);
|
17882 | }
|
17883 | function resolveRetryWakeable(boundaryFiber, wakeable) {
|
17884 | var retryLane = NoLane;
|
17885 |
|
17886 | var retryCache;
|
17887 |
|
17888 | {
|
17889 | switch (boundaryFiber.tag) {
|
17890 | case SuspenseComponent:
|
17891 | retryCache = boundaryFiber.stateNode;
|
17892 | var suspenseState = boundaryFiber.memoizedState;
|
17893 |
|
17894 | if (suspenseState !== null) {
|
17895 | retryLane = suspenseState.retryLane;
|
17896 | }
|
17897 |
|
17898 | break;
|
17899 |
|
17900 | case SuspenseListComponent:
|
17901 | retryCache = boundaryFiber.stateNode;
|
17902 | break;
|
17903 |
|
17904 | default:
|
17905 | throw new Error('Pinged unknown suspense boundary type. ' + 'This is probably a bug in React.');
|
17906 | }
|
17907 | }
|
17908 |
|
17909 | if (retryCache !== null) {
|
17910 |
|
17911 |
|
17912 | retryCache.delete(wakeable);
|
17913 | }
|
17914 |
|
17915 | retryTimedOutBoundary(boundaryFiber, retryLane);
|
17916 | }
|
17917 |
|
17918 |
|
17919 |
|
17920 |
|
17921 |
|
17922 |
|
17923 |
|
17924 |
|
17925 |
|
17926 | function jnd(timeElapsed) {
|
17927 | return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
|
17928 | }
|
17929 |
|
17930 | function checkForNestedUpdates() {
|
17931 | if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
|
17932 | nestedUpdateCount = 0;
|
17933 | rootWithNestedUpdates = null;
|
17934 | throw new 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.');
|
17935 | }
|
17936 |
|
17937 | {
|
17938 | if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
|
17939 | nestedPassiveUpdateCount = 0;
|
17940 |
|
17941 | error('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.');
|
17942 | }
|
17943 | }
|
17944 | }
|
17945 |
|
17946 | function flushRenderPhaseStrictModeWarningsInDEV() {
|
17947 | {
|
17948 | ReactStrictModeWarnings.flushLegacyContextWarning();
|
17949 |
|
17950 | {
|
17951 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
|
17952 | }
|
17953 | }
|
17954 | }
|
17955 |
|
17956 | function commitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) {
|
17957 | {
|
17958 |
|
17959 |
|
17960 |
|
17961 | setCurrentFiber(fiber);
|
17962 | invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV);
|
17963 |
|
17964 | if (hasPassiveEffects) {
|
17965 | invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectUnmountInDEV);
|
17966 | }
|
17967 |
|
17968 | invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectMountInDEV);
|
17969 |
|
17970 | if (hasPassiveEffects) {
|
17971 | invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV);
|
17972 | }
|
17973 |
|
17974 | resetCurrentFiber();
|
17975 | }
|
17976 | }
|
17977 |
|
17978 | function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) {
|
17979 | {
|
17980 |
|
17981 |
|
17982 | var current = firstChild;
|
17983 | var subtreeRoot = null;
|
17984 |
|
17985 | while (current !== null) {
|
17986 | var primarySubtreeFlag = current.subtreeFlags & fiberFlags;
|
17987 |
|
17988 | if (current !== subtreeRoot && current.child !== null && primarySubtreeFlag !== NoFlags) {
|
17989 | current = current.child;
|
17990 | } else {
|
17991 | if ((current.flags & fiberFlags) !== NoFlags) {
|
17992 | invokeEffectFn(current);
|
17993 | }
|
17994 |
|
17995 | if (current.sibling !== null) {
|
17996 | current = current.sibling;
|
17997 | } else {
|
17998 | current = subtreeRoot = current.return;
|
17999 | }
|
18000 | }
|
18001 | }
|
18002 | }
|
18003 | }
|
18004 |
|
18005 | var didWarnStateUpdateForNotYetMountedComponent = null;
|
18006 |
|
18007 | function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
|
18008 | {
|
18009 | if ((executionContext & RenderContext) !== NoContext) {
|
18010 |
|
18011 | return;
|
18012 | }
|
18013 |
|
18014 | if (!(fiber.mode & ConcurrentMode)) {
|
18015 | return;
|
18016 | }
|
18017 |
|
18018 | var tag = fiber.tag;
|
18019 |
|
18020 | if (tag !== IndeterminateComponent && tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
|
18021 |
|
18022 | return;
|
18023 | }
|
18024 |
|
18025 |
|
18026 |
|
18027 | var componentName = getComponentNameFromFiber(fiber) || 'ReactComponent';
|
18028 |
|
18029 | if (didWarnStateUpdateForNotYetMountedComponent !== null) {
|
18030 | if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
|
18031 | return;
|
18032 | }
|
18033 |
|
18034 | didWarnStateUpdateForNotYetMountedComponent.add(componentName);
|
18035 | } else {
|
18036 | didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
|
18037 | }
|
18038 |
|
18039 | var previousFiber = current$1;
|
18040 |
|
18041 | try {
|
18042 | setCurrentFiber(fiber);
|
18043 |
|
18044 | error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.');
|
18045 | } finally {
|
18046 | if (previousFiber) {
|
18047 | setCurrentFiber(fiber);
|
18048 | } else {
|
18049 | resetCurrentFiber();
|
18050 | }
|
18051 | }
|
18052 | }
|
18053 | }
|
18054 |
|
18055 | var beginWork$1;
|
18056 |
|
18057 | {
|
18058 | var dummyFiber = null;
|
18059 |
|
18060 | beginWork$1 = function (current, unitOfWork, lanes) {
|
18061 |
|
18062 |
|
18063 |
|
18064 |
|
18065 |
|
18066 | var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
|
18067 |
|
18068 | try {
|
18069 | return beginWork(current, unitOfWork, lanes);
|
18070 | } catch (originalError) {
|
18071 | if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
|
18072 |
|
18073 | throw originalError;
|
18074 | }
|
18075 |
|
18076 |
|
18077 |
|
18078 | resetContextDependencies();
|
18079 | resetHooksAfterThrow();
|
18080 |
|
18081 |
|
18082 |
|
18083 | unwindInterruptedWork(current, unitOfWork);
|
18084 |
|
18085 | assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
|
18086 |
|
18087 | if ( unitOfWork.mode & ProfileMode) {
|
18088 |
|
18089 | startProfilerTimer(unitOfWork);
|
18090 | }
|
18091 |
|
18092 |
|
18093 | invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes);
|
18094 |
|
18095 | if (hasCaughtError()) {
|
18096 | var replayError = clearCaughtError();
|
18097 |
|
18098 | if (typeof replayError === 'object' && replayError !== null && replayError._suppressLogging && typeof originalError === 'object' && originalError !== null && !originalError._suppressLogging) {
|
18099 |
|
18100 | originalError._suppressLogging = true;
|
18101 | }
|
18102 | }
|
18103 |
|
18104 |
|
18105 |
|
18106 | throw originalError;
|
18107 | }
|
18108 | };
|
18109 | }
|
18110 |
|
18111 | var didWarnAboutUpdateInRender = false;
|
18112 | var didWarnAboutUpdateInRenderForAnotherComponent;
|
18113 |
|
18114 | {
|
18115 | didWarnAboutUpdateInRenderForAnotherComponent = new Set();
|
18116 | }
|
18117 |
|
18118 | function warnAboutRenderPhaseUpdatesInDEV(fiber) {
|
18119 | {
|
18120 | if (isRendering && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) {
|
18121 | switch (fiber.tag) {
|
18122 | case FunctionComponent:
|
18123 | case ForwardRef:
|
18124 | case SimpleMemoComponent:
|
18125 | {
|
18126 | var renderingComponentName = workInProgress && getComponentNameFromFiber(workInProgress) || 'Unknown';
|
18127 |
|
18128 | var dedupeKey = renderingComponentName;
|
18129 |
|
18130 | if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
|
18131 | didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
|
18132 | var setStateComponentName = getComponentNameFromFiber(fiber) || 'Unknown';
|
18133 |
|
18134 | error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://reactjs.org/link/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName);
|
18135 | }
|
18136 |
|
18137 | break;
|
18138 | }
|
18139 |
|
18140 | case ClassComponent:
|
18141 | {
|
18142 | if (!didWarnAboutUpdateInRender) {
|
18143 | error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.');
|
18144 |
|
18145 | didWarnAboutUpdateInRender = true;
|
18146 | }
|
18147 |
|
18148 | break;
|
18149 | }
|
18150 | }
|
18151 | }
|
18152 | }
|
18153 | }
|
18154 |
|
18155 | function restorePendingUpdaters(root, lanes) {
|
18156 | {
|
18157 | if (isDevToolsPresent) {
|
18158 | var memoizedUpdaters = root.memoizedUpdaters;
|
18159 | memoizedUpdaters.forEach(function (schedulingFiber) {
|
18160 | addFiberToLanesMap(root, schedulingFiber, lanes);
|
18161 | });
|
18162 |
|
18163 |
|
18164 | }
|
18165 | }
|
18166 | }
|
18167 | var fakeActCallbackNode = {};
|
18168 |
|
18169 | function scheduleCallback$1(priorityLevel, callback) {
|
18170 | {
|
18171 |
|
18172 |
|
18173 | var actQueue = ReactCurrentActQueue$1.current;
|
18174 |
|
18175 | if (actQueue !== null) {
|
18176 | actQueue.push(callback);
|
18177 | return fakeActCallbackNode;
|
18178 | } else {
|
18179 | return scheduleCallback(priorityLevel, callback);
|
18180 | }
|
18181 | }
|
18182 | }
|
18183 |
|
18184 | function cancelCallback$1(callbackNode) {
|
18185 | if ( callbackNode === fakeActCallbackNode) {
|
18186 | return;
|
18187 | }
|
18188 |
|
18189 |
|
18190 | return cancelCallback(callbackNode);
|
18191 | }
|
18192 |
|
18193 | function shouldForceFlushFallbacksInDEV() {
|
18194 |
|
18195 | return ReactCurrentActQueue$1.current !== null;
|
18196 | }
|
18197 |
|
18198 | function warnIfUpdatesNotWrappedWithActDEV(fiber) {
|
18199 | {
|
18200 | if (fiber.mode & ConcurrentMode) {
|
18201 | if (!isConcurrentActEnvironment()) {
|
18202 |
|
18203 | return;
|
18204 | }
|
18205 | } else {
|
18206 |
|
18207 | if (!isLegacyActEnvironment()) {
|
18208 |
|
18209 | return;
|
18210 | }
|
18211 |
|
18212 | if (executionContext !== NoContext) {
|
18213 |
|
18214 |
|
18215 | return;
|
18216 | }
|
18217 |
|
18218 | if (fiber.tag !== FunctionComponent && fiber.tag !== ForwardRef && fiber.tag !== SimpleMemoComponent) {
|
18219 |
|
18220 |
|
18221 | return;
|
18222 | }
|
18223 | }
|
18224 |
|
18225 | if (ReactCurrentActQueue$1.current === null) {
|
18226 | var previousFiber = current$1;
|
18227 |
|
18228 | try {
|
18229 | setCurrentFiber(fiber);
|
18230 |
|
18231 | error('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://reactjs.org/link/wrap-tests-with-act', getComponentNameFromFiber(fiber));
|
18232 | } finally {
|
18233 | if (previousFiber) {
|
18234 | setCurrentFiber(fiber);
|
18235 | } else {
|
18236 | resetCurrentFiber();
|
18237 | }
|
18238 | }
|
18239 | }
|
18240 | }
|
18241 | }
|
18242 |
|
18243 | function warnIfSuspenseResolutionNotWrappedWithActDEV(root) {
|
18244 | {
|
18245 | if (root.tag !== LegacyRoot && isConcurrentActEnvironment() && ReactCurrentActQueue$1.current === null) {
|
18246 | error('A suspended resource finished loading inside a test, but the event ' + 'was not wrapped in act(...).\n\n' + 'When testing, code that resolves suspended data should be wrapped ' + 'into act(...):\n\n' + 'act(() => {\n' + ' /* finish loading suspended data */\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://reactjs.org/link/wrap-tests-with-act');
|
18247 | }
|
18248 | }
|
18249 | }
|
18250 |
|
18251 |
|
18252 | var resolveFamily = null;
|
18253 |
|
18254 | var failedBoundaries = null;
|
18255 | var setRefreshHandler = function (handler) {
|
18256 | {
|
18257 | resolveFamily = handler;
|
18258 | }
|
18259 | };
|
18260 | function resolveFunctionForHotReloading(type) {
|
18261 | {
|
18262 | if (resolveFamily === null) {
|
18263 |
|
18264 | return type;
|
18265 | }
|
18266 |
|
18267 | var family = resolveFamily(type);
|
18268 |
|
18269 | if (family === undefined) {
|
18270 | return type;
|
18271 | }
|
18272 |
|
18273 |
|
18274 | return family.current;
|
18275 | }
|
18276 | }
|
18277 | function resolveClassForHotReloading(type) {
|
18278 |
|
18279 | return resolveFunctionForHotReloading(type);
|
18280 | }
|
18281 | function resolveForwardRefForHotReloading(type) {
|
18282 | {
|
18283 | if (resolveFamily === null) {
|
18284 |
|
18285 | return type;
|
18286 | }
|
18287 |
|
18288 | var family = resolveFamily(type);
|
18289 |
|
18290 | if (family === undefined) {
|
18291 |
|
18292 | if (type !== null && type !== undefined && typeof type.render === 'function') {
|
18293 |
|
18294 |
|
18295 |
|
18296 | var currentRender = resolveFunctionForHotReloading(type.render);
|
18297 |
|
18298 | if (type.render !== currentRender) {
|
18299 | var syntheticType = {
|
18300 | $$typeof: REACT_FORWARD_REF_TYPE,
|
18301 | render: currentRender
|
18302 | };
|
18303 |
|
18304 | if (type.displayName !== undefined) {
|
18305 | syntheticType.displayName = type.displayName;
|
18306 | }
|
18307 |
|
18308 | return syntheticType;
|
18309 | }
|
18310 | }
|
18311 |
|
18312 | return type;
|
18313 | }
|
18314 |
|
18315 |
|
18316 | return family.current;
|
18317 | }
|
18318 | }
|
18319 | function isCompatibleFamilyForHotReloading(fiber, element) {
|
18320 | {
|
18321 | if (resolveFamily === null) {
|
18322 |
|
18323 | return false;
|
18324 | }
|
18325 |
|
18326 | var prevType = fiber.elementType;
|
18327 | var nextType = element.type;
|
18328 |
|
18329 | var needsCompareFamilies = false;
|
18330 | var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
|
18331 |
|
18332 | switch (fiber.tag) {
|
18333 | case ClassComponent:
|
18334 | {
|
18335 | if (typeof nextType === 'function') {
|
18336 | needsCompareFamilies = true;
|
18337 | }
|
18338 |
|
18339 | break;
|
18340 | }
|
18341 |
|
18342 | case FunctionComponent:
|
18343 | {
|
18344 | if (typeof nextType === 'function') {
|
18345 | needsCompareFamilies = true;
|
18346 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
18347 |
|
18348 |
|
18349 |
|
18350 |
|
18351 | needsCompareFamilies = true;
|
18352 | }
|
18353 |
|
18354 | break;
|
18355 | }
|
18356 |
|
18357 | case ForwardRef:
|
18358 | {
|
18359 | if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
|
18360 | needsCompareFamilies = true;
|
18361 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
18362 | needsCompareFamilies = true;
|
18363 | }
|
18364 |
|
18365 | break;
|
18366 | }
|
18367 |
|
18368 | case MemoComponent:
|
18369 | case SimpleMemoComponent:
|
18370 | {
|
18371 | if ($$typeofNextType === REACT_MEMO_TYPE) {
|
18372 |
|
18373 |
|
18374 | needsCompareFamilies = true;
|
18375 | } else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
18376 | needsCompareFamilies = true;
|
18377 | }
|
18378 |
|
18379 | break;
|
18380 | }
|
18381 |
|
18382 | default:
|
18383 | return false;
|
18384 | }
|
18385 |
|
18386 |
|
18387 | if (needsCompareFamilies) {
|
18388 |
|
18389 |
|
18390 |
|
18391 |
|
18392 |
|
18393 | var prevFamily = resolveFamily(prevType);
|
18394 |
|
18395 | if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
|
18396 | return true;
|
18397 | }
|
18398 | }
|
18399 |
|
18400 | return false;
|
18401 | }
|
18402 | }
|
18403 | function markFailedErrorBoundaryForHotReloading(fiber) {
|
18404 | {
|
18405 | if (resolveFamily === null) {
|
18406 |
|
18407 | return;
|
18408 | }
|
18409 |
|
18410 | if (typeof WeakSet !== 'function') {
|
18411 | return;
|
18412 | }
|
18413 |
|
18414 | if (failedBoundaries === null) {
|
18415 | failedBoundaries = new WeakSet();
|
18416 | }
|
18417 |
|
18418 | failedBoundaries.add(fiber);
|
18419 | }
|
18420 | }
|
18421 | var scheduleRefresh = function (root, update) {
|
18422 | {
|
18423 | if (resolveFamily === null) {
|
18424 |
|
18425 | return;
|
18426 | }
|
18427 |
|
18428 | var staleFamilies = update.staleFamilies,
|
18429 | updatedFamilies = update.updatedFamilies;
|
18430 | flushPassiveEffects();
|
18431 | flushSync(function () {
|
18432 | scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
|
18433 | });
|
18434 | }
|
18435 | };
|
18436 | var scheduleRoot = function (root, element) {
|
18437 | {
|
18438 | if (root.context !== emptyContextObject) {
|
18439 |
|
18440 |
|
18441 |
|
18442 | return;
|
18443 | }
|
18444 |
|
18445 | flushPassiveEffects();
|
18446 | flushSync(function () {
|
18447 | updateContainer(element, root, null, null);
|
18448 | });
|
18449 | }
|
18450 | };
|
18451 |
|
18452 | function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
|
18453 | {
|
18454 | var alternate = fiber.alternate,
|
18455 | child = fiber.child,
|
18456 | sibling = fiber.sibling,
|
18457 | tag = fiber.tag,
|
18458 | type = fiber.type;
|
18459 | var candidateType = null;
|
18460 |
|
18461 | switch (tag) {
|
18462 | case FunctionComponent:
|
18463 | case SimpleMemoComponent:
|
18464 | case ClassComponent:
|
18465 | candidateType = type;
|
18466 | break;
|
18467 |
|
18468 | case ForwardRef:
|
18469 | candidateType = type.render;
|
18470 | break;
|
18471 | }
|
18472 |
|
18473 | if (resolveFamily === null) {
|
18474 | throw new Error('Expected resolveFamily to be set during hot reload.');
|
18475 | }
|
18476 |
|
18477 | var needsRender = false;
|
18478 | var needsRemount = false;
|
18479 |
|
18480 | if (candidateType !== null) {
|
18481 | var family = resolveFamily(candidateType);
|
18482 |
|
18483 | if (family !== undefined) {
|
18484 | if (staleFamilies.has(family)) {
|
18485 | needsRemount = true;
|
18486 | } else if (updatedFamilies.has(family)) {
|
18487 | if (tag === ClassComponent) {
|
18488 | needsRemount = true;
|
18489 | } else {
|
18490 | needsRender = true;
|
18491 | }
|
18492 | }
|
18493 | }
|
18494 | }
|
18495 |
|
18496 | if (failedBoundaries !== null) {
|
18497 | if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
|
18498 | needsRemount = true;
|
18499 | }
|
18500 | }
|
18501 |
|
18502 | if (needsRemount) {
|
18503 | fiber._debugNeedsRemount = true;
|
18504 | }
|
18505 |
|
18506 | if (needsRemount || needsRender) {
|
18507 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
18508 | }
|
18509 |
|
18510 | if (child !== null && !needsRemount) {
|
18511 | scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
|
18512 | }
|
18513 |
|
18514 | if (sibling !== null) {
|
18515 | scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
|
18516 | }
|
18517 | }
|
18518 | }
|
18519 |
|
18520 | var findHostInstancesForRefresh = function (root, families) {
|
18521 | {
|
18522 | var hostInstances = new Set();
|
18523 | var types = new Set(families.map(function (family) {
|
18524 | return family.current;
|
18525 | }));
|
18526 | findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
|
18527 | return hostInstances;
|
18528 | }
|
18529 | };
|
18530 |
|
18531 | function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
|
18532 | {
|
18533 | var child = fiber.child,
|
18534 | sibling = fiber.sibling,
|
18535 | tag = fiber.tag,
|
18536 | type = fiber.type;
|
18537 | var candidateType = null;
|
18538 |
|
18539 | switch (tag) {
|
18540 | case FunctionComponent:
|
18541 | case SimpleMemoComponent:
|
18542 | case ClassComponent:
|
18543 | candidateType = type;
|
18544 | break;
|
18545 |
|
18546 | case ForwardRef:
|
18547 | candidateType = type.render;
|
18548 | break;
|
18549 | }
|
18550 |
|
18551 | var didMatch = false;
|
18552 |
|
18553 | if (candidateType !== null) {
|
18554 | if (types.has(candidateType)) {
|
18555 | didMatch = true;
|
18556 | }
|
18557 | }
|
18558 |
|
18559 | if (didMatch) {
|
18560 |
|
18561 |
|
18562 |
|
18563 | findHostInstancesForFiberShallowly(fiber, hostInstances);
|
18564 | } else {
|
18565 |
|
18566 | if (child !== null) {
|
18567 | findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
|
18568 | }
|
18569 | }
|
18570 |
|
18571 | if (sibling !== null) {
|
18572 | findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
|
18573 | }
|
18574 | }
|
18575 | }
|
18576 |
|
18577 | function findHostInstancesForFiberShallowly(fiber, hostInstances) {
|
18578 | {
|
18579 | var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
|
18580 |
|
18581 | if (foundHostInstances) {
|
18582 | return;
|
18583 | }
|
18584 |
|
18585 |
|
18586 | var node = fiber;
|
18587 |
|
18588 | while (true) {
|
18589 | switch (node.tag) {
|
18590 | case HostComponent:
|
18591 | hostInstances.add(node.stateNode);
|
18592 | return;
|
18593 |
|
18594 | case HostPortal:
|
18595 | hostInstances.add(node.stateNode.containerInfo);
|
18596 | return;
|
18597 |
|
18598 | case HostRoot:
|
18599 | hostInstances.add(node.stateNode.containerInfo);
|
18600 | return;
|
18601 | }
|
18602 |
|
18603 | if (node.return === null) {
|
18604 | throw new Error('Expected to reach root first.');
|
18605 | }
|
18606 |
|
18607 | node = node.return;
|
18608 | }
|
18609 | }
|
18610 | }
|
18611 |
|
18612 | function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
|
18613 | {
|
18614 | var node = fiber;
|
18615 | var foundHostInstances = false;
|
18616 |
|
18617 | while (true) {
|
18618 | if (node.tag === HostComponent) {
|
18619 |
|
18620 | foundHostInstances = true;
|
18621 | hostInstances.add(node.stateNode);
|
18622 | } else if (node.child !== null) {
|
18623 | node.child.return = node;
|
18624 | node = node.child;
|
18625 | continue;
|
18626 | }
|
18627 |
|
18628 | if (node === fiber) {
|
18629 | return foundHostInstances;
|
18630 | }
|
18631 |
|
18632 | while (node.sibling === null) {
|
18633 | if (node.return === null || node.return === fiber) {
|
18634 | return foundHostInstances;
|
18635 | }
|
18636 |
|
18637 | node = node.return;
|
18638 | }
|
18639 |
|
18640 | node.sibling.return = node.return;
|
18641 | node = node.sibling;
|
18642 | }
|
18643 | }
|
18644 |
|
18645 | return false;
|
18646 | }
|
18647 |
|
18648 | var hasBadMapPolyfill;
|
18649 |
|
18650 | {
|
18651 | hasBadMapPolyfill = false;
|
18652 |
|
18653 | try {
|
18654 | var nonExtensibleObject = Object.preventExtensions({});
|
18655 |
|
18656 |
|
18657 | new Map([[nonExtensibleObject, null]]);
|
18658 | new Set([nonExtensibleObject]);
|
18659 |
|
18660 | } catch (e) {
|
18661 |
|
18662 | hasBadMapPolyfill = true;
|
18663 | }
|
18664 | }
|
18665 |
|
18666 | function FiberNode(tag, pendingProps, key, mode) {
|
18667 |
|
18668 | this.tag = tag;
|
18669 | this.key = key;
|
18670 | this.elementType = null;
|
18671 | this.type = null;
|
18672 | this.stateNode = null;
|
18673 |
|
18674 | this.return = null;
|
18675 | this.child = null;
|
18676 | this.sibling = null;
|
18677 | this.index = 0;
|
18678 | this.ref = null;
|
18679 | this.pendingProps = pendingProps;
|
18680 | this.memoizedProps = null;
|
18681 | this.updateQueue = null;
|
18682 | this.memoizedState = null;
|
18683 | this.dependencies = null;
|
18684 | this.mode = mode;
|
18685 |
|
18686 | this.flags = NoFlags;
|
18687 | this.subtreeFlags = NoFlags;
|
18688 | this.deletions = null;
|
18689 | this.lanes = NoLanes;
|
18690 | this.childLanes = NoLanes;
|
18691 | this.alternate = null;
|
18692 |
|
18693 | {
|
18694 |
|
18695 |
|
18696 |
|
18697 |
|
18698 |
|
18699 |
|
18700 |
|
18701 |
|
18702 |
|
18703 |
|
18704 |
|
18705 |
|
18706 | this.actualDuration = Number.NaN;
|
18707 | this.actualStartTime = Number.NaN;
|
18708 | this.selfBaseDuration = Number.NaN;
|
18709 | this.treeBaseDuration = Number.NaN;
|
18710 |
|
18711 |
|
18712 |
|
18713 | this.actualDuration = 0;
|
18714 | this.actualStartTime = -1;
|
18715 | this.selfBaseDuration = 0;
|
18716 | this.treeBaseDuration = 0;
|
18717 | }
|
18718 |
|
18719 | {
|
18720 |
|
18721 | this._debugSource = null;
|
18722 | this._debugOwner = null;
|
18723 | this._debugNeedsRemount = false;
|
18724 | this._debugHookTypes = null;
|
18725 |
|
18726 | if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
|
18727 | Object.preventExtensions(this);
|
18728 | }
|
18729 | }
|
18730 | }
|
18731 |
|
18732 |
|
18733 |
|
18734 |
|
18735 |
|
18736 |
|
18737 |
|
18738 |
|
18739 |
|
18740 |
|
18741 |
|
18742 |
|
18743 |
|
18744 |
|
18745 | var createFiber = function (tag, pendingProps, key, mode) {
|
18746 |
|
18747 | return new FiberNode(tag, pendingProps, key, mode);
|
18748 | };
|
18749 |
|
18750 | function shouldConstruct$1(Component) {
|
18751 | var prototype = Component.prototype;
|
18752 | return !!(prototype && prototype.isReactComponent);
|
18753 | }
|
18754 |
|
18755 | function isSimpleFunctionComponent(type) {
|
18756 | return typeof type === 'function' && !shouldConstruct$1(type) && type.defaultProps === undefined;
|
18757 | }
|
18758 | function resolveLazyComponentTag(Component) {
|
18759 | if (typeof Component === 'function') {
|
18760 | return shouldConstruct$1(Component) ? ClassComponent : FunctionComponent;
|
18761 | } else if (Component !== undefined && Component !== null) {
|
18762 | var $$typeof = Component.$$typeof;
|
18763 |
|
18764 | if ($$typeof === REACT_FORWARD_REF_TYPE) {
|
18765 | return ForwardRef;
|
18766 | }
|
18767 |
|
18768 | if ($$typeof === REACT_MEMO_TYPE) {
|
18769 | return MemoComponent;
|
18770 | }
|
18771 | }
|
18772 |
|
18773 | return IndeterminateComponent;
|
18774 | }
|
18775 |
|
18776 | function createWorkInProgress(current, pendingProps) {
|
18777 | var workInProgress = current.alternate;
|
18778 |
|
18779 | if (workInProgress === null) {
|
18780 |
|
18781 |
|
18782 |
|
18783 |
|
18784 |
|
18785 | workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
|
18786 | workInProgress.elementType = current.elementType;
|
18787 | workInProgress.type = current.type;
|
18788 | workInProgress.stateNode = current.stateNode;
|
18789 |
|
18790 | {
|
18791 |
|
18792 | workInProgress._debugSource = current._debugSource;
|
18793 | workInProgress._debugOwner = current._debugOwner;
|
18794 | workInProgress._debugHookTypes = current._debugHookTypes;
|
18795 | }
|
18796 |
|
18797 | workInProgress.alternate = current;
|
18798 | current.alternate = workInProgress;
|
18799 | } else {
|
18800 | workInProgress.pendingProps = pendingProps;
|
18801 |
|
18802 | workInProgress.type = current.type;
|
18803 |
|
18804 |
|
18805 | workInProgress.flags = NoFlags;
|
18806 |
|
18807 | workInProgress.subtreeFlags = NoFlags;
|
18808 | workInProgress.deletions = null;
|
18809 |
|
18810 | {
|
18811 |
|
18812 |
|
18813 |
|
18814 |
|
18815 | workInProgress.actualDuration = 0;
|
18816 | workInProgress.actualStartTime = -1;
|
18817 | }
|
18818 | }
|
18819 |
|
18820 |
|
18821 |
|
18822 | workInProgress.flags = current.flags & StaticMask;
|
18823 | workInProgress.childLanes = current.childLanes;
|
18824 | workInProgress.lanes = current.lanes;
|
18825 | workInProgress.child = current.child;
|
18826 | workInProgress.memoizedProps = current.memoizedProps;
|
18827 | workInProgress.memoizedState = current.memoizedState;
|
18828 | workInProgress.updateQueue = current.updateQueue;
|
18829 |
|
18830 |
|
18831 | var currentDependencies = current.dependencies;
|
18832 | workInProgress.dependencies = currentDependencies === null ? null : {
|
18833 | lanes: currentDependencies.lanes,
|
18834 | firstContext: currentDependencies.firstContext
|
18835 | };
|
18836 |
|
18837 | workInProgress.sibling = current.sibling;
|
18838 | workInProgress.index = current.index;
|
18839 | workInProgress.ref = current.ref;
|
18840 |
|
18841 | {
|
18842 | workInProgress.selfBaseDuration = current.selfBaseDuration;
|
18843 | workInProgress.treeBaseDuration = current.treeBaseDuration;
|
18844 | }
|
18845 |
|
18846 | {
|
18847 | workInProgress._debugNeedsRemount = current._debugNeedsRemount;
|
18848 |
|
18849 | switch (workInProgress.tag) {
|
18850 | case IndeterminateComponent:
|
18851 | case FunctionComponent:
|
18852 | case SimpleMemoComponent:
|
18853 | workInProgress.type = resolveFunctionForHotReloading(current.type);
|
18854 | break;
|
18855 |
|
18856 | case ClassComponent:
|
18857 | workInProgress.type = resolveClassForHotReloading(current.type);
|
18858 | break;
|
18859 |
|
18860 | case ForwardRef:
|
18861 | workInProgress.type = resolveForwardRefForHotReloading(current.type);
|
18862 | break;
|
18863 | }
|
18864 | }
|
18865 |
|
18866 | return workInProgress;
|
18867 | }
|
18868 |
|
18869 | function resetWorkInProgress(workInProgress, renderLanes) {
|
18870 |
|
18871 |
|
18872 |
|
18873 |
|
18874 |
|
18875 |
|
18876 |
|
18877 |
|
18878 | workInProgress.flags &= StaticMask | Placement;
|
18879 |
|
18880 | var current = workInProgress.alternate;
|
18881 |
|
18882 | if (current === null) {
|
18883 |
|
18884 | workInProgress.childLanes = NoLanes;
|
18885 | workInProgress.lanes = renderLanes;
|
18886 | workInProgress.child = null;
|
18887 | workInProgress.subtreeFlags = NoFlags;
|
18888 | workInProgress.memoizedProps = null;
|
18889 | workInProgress.memoizedState = null;
|
18890 | workInProgress.updateQueue = null;
|
18891 | workInProgress.dependencies = null;
|
18892 | workInProgress.stateNode = null;
|
18893 |
|
18894 | {
|
18895 |
|
18896 |
|
18897 | workInProgress.selfBaseDuration = 0;
|
18898 | workInProgress.treeBaseDuration = 0;
|
18899 | }
|
18900 | } else {
|
18901 |
|
18902 | workInProgress.childLanes = current.childLanes;
|
18903 | workInProgress.lanes = current.lanes;
|
18904 | workInProgress.child = current.child;
|
18905 | workInProgress.subtreeFlags = NoFlags;
|
18906 | workInProgress.deletions = null;
|
18907 | workInProgress.memoizedProps = current.memoizedProps;
|
18908 | workInProgress.memoizedState = current.memoizedState;
|
18909 | workInProgress.updateQueue = current.updateQueue;
|
18910 |
|
18911 | workInProgress.type = current.type;
|
18912 |
|
18913 |
|
18914 | var currentDependencies = current.dependencies;
|
18915 | workInProgress.dependencies = currentDependencies === null ? null : {
|
18916 | lanes: currentDependencies.lanes,
|
18917 | firstContext: currentDependencies.firstContext
|
18918 | };
|
18919 |
|
18920 | {
|
18921 |
|
18922 |
|
18923 | workInProgress.selfBaseDuration = current.selfBaseDuration;
|
18924 | workInProgress.treeBaseDuration = current.treeBaseDuration;
|
18925 | }
|
18926 | }
|
18927 |
|
18928 | return workInProgress;
|
18929 | }
|
18930 | function createHostRootFiber(tag, isStrictMode, concurrentUpdatesByDefaultOverride) {
|
18931 | var mode;
|
18932 |
|
18933 | if (tag === ConcurrentRoot) {
|
18934 | mode = ConcurrentMode;
|
18935 |
|
18936 | if (isStrictMode === true) {
|
18937 | mode |= StrictLegacyMode;
|
18938 |
|
18939 | {
|
18940 | mode |= StrictEffectsMode;
|
18941 | }
|
18942 | }
|
18943 | } else {
|
18944 | mode = NoMode;
|
18945 | }
|
18946 |
|
18947 | if ( isDevToolsPresent) {
|
18948 |
|
18949 |
|
18950 |
|
18951 | mode |= ProfileMode;
|
18952 | }
|
18953 |
|
18954 | return createFiber(HostRoot, null, null, mode);
|
18955 | }
|
18956 | function createFiberFromTypeAndProps(type, // React$ElementType
|
18957 | key, pendingProps, owner, mode, lanes) {
|
18958 | var fiberTag = IndeterminateComponent;
|
18959 |
|
18960 | var resolvedType = type;
|
18961 |
|
18962 | if (typeof type === 'function') {
|
18963 | if (shouldConstruct$1(type)) {
|
18964 | fiberTag = ClassComponent;
|
18965 |
|
18966 | {
|
18967 | resolvedType = resolveClassForHotReloading(resolvedType);
|
18968 | }
|
18969 | } else {
|
18970 | {
|
18971 | resolvedType = resolveFunctionForHotReloading(resolvedType);
|
18972 | }
|
18973 | }
|
18974 | } else if (typeof type === 'string') {
|
18975 | fiberTag = HostComponent;
|
18976 | } else {
|
18977 | getTag: switch (type) {
|
18978 | case REACT_FRAGMENT_TYPE:
|
18979 | return createFiberFromFragment(pendingProps.children, mode, lanes, key);
|
18980 |
|
18981 | case REACT_STRICT_MODE_TYPE:
|
18982 | fiberTag = Mode;
|
18983 | mode |= StrictLegacyMode;
|
18984 |
|
18985 | if ( (mode & ConcurrentMode) !== NoMode) {
|
18986 |
|
18987 | mode |= StrictEffectsMode;
|
18988 | }
|
18989 |
|
18990 | break;
|
18991 |
|
18992 | case REACT_PROFILER_TYPE:
|
18993 | return createFiberFromProfiler(pendingProps, mode, lanes, key);
|
18994 |
|
18995 | case REACT_SUSPENSE_TYPE:
|
18996 | return createFiberFromSuspense(pendingProps, mode, lanes, key);
|
18997 |
|
18998 | case REACT_SUSPENSE_LIST_TYPE:
|
18999 | return createFiberFromSuspenseList(pendingProps, mode, lanes, key);
|
19000 |
|
19001 | case REACT_OFFSCREEN_TYPE:
|
19002 | return createFiberFromOffscreen(pendingProps, mode, lanes, key);
|
19003 |
|
19004 | case REACT_LEGACY_HIDDEN_TYPE:
|
19005 |
|
19006 |
|
19007 |
|
19008 | case REACT_SCOPE_TYPE:
|
19009 |
|
19010 |
|
19011 |
|
19012 | case REACT_CACHE_TYPE:
|
19013 |
|
19014 |
|
19015 |
|
19016 | case REACT_TRACING_MARKER_TYPE:
|
19017 |
|
19018 |
|
19019 |
|
19020 | case REACT_DEBUG_TRACING_MODE_TYPE:
|
19021 |
|
19022 |
|
19023 |
|
19024 | default:
|
19025 | {
|
19026 | if (typeof type === 'object' && type !== null) {
|
19027 | switch (type.$$typeof) {
|
19028 | case REACT_PROVIDER_TYPE:
|
19029 | fiberTag = ContextProvider;
|
19030 | break getTag;
|
19031 |
|
19032 | case REACT_CONTEXT_TYPE:
|
19033 |
|
19034 | fiberTag = ContextConsumer;
|
19035 | break getTag;
|
19036 |
|
19037 | case REACT_FORWARD_REF_TYPE:
|
19038 | fiberTag = ForwardRef;
|
19039 |
|
19040 | {
|
19041 | resolvedType = resolveForwardRefForHotReloading(resolvedType);
|
19042 | }
|
19043 |
|
19044 | break getTag;
|
19045 |
|
19046 | case REACT_MEMO_TYPE:
|
19047 | fiberTag = MemoComponent;
|
19048 | break getTag;
|
19049 |
|
19050 | case REACT_LAZY_TYPE:
|
19051 | fiberTag = LazyComponent;
|
19052 | resolvedType = null;
|
19053 | break getTag;
|
19054 | }
|
19055 | }
|
19056 |
|
19057 | var info = '';
|
19058 |
|
19059 | {
|
19060 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
19061 | 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.';
|
19062 | }
|
19063 |
|
19064 | var ownerName = owner ? getComponentNameFromFiber(owner) : null;
|
19065 |
|
19066 | if (ownerName) {
|
19067 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
19068 | }
|
19069 | }
|
19070 |
|
19071 | throw new 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));
|
19072 | }
|
19073 | }
|
19074 | }
|
19075 |
|
19076 | var fiber = createFiber(fiberTag, pendingProps, key, mode);
|
19077 | fiber.elementType = type;
|
19078 | fiber.type = resolvedType;
|
19079 | fiber.lanes = lanes;
|
19080 |
|
19081 | {
|
19082 | fiber._debugOwner = owner;
|
19083 | }
|
19084 |
|
19085 | return fiber;
|
19086 | }
|
19087 | function createFiberFromElement(element, mode, lanes) {
|
19088 | var owner = null;
|
19089 |
|
19090 | {
|
19091 | owner = element._owner;
|
19092 | }
|
19093 |
|
19094 | var type = element.type;
|
19095 | var key = element.key;
|
19096 | var pendingProps = element.props;
|
19097 | var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes);
|
19098 |
|
19099 | {
|
19100 | fiber._debugSource = element._source;
|
19101 | fiber._debugOwner = element._owner;
|
19102 | }
|
19103 |
|
19104 | return fiber;
|
19105 | }
|
19106 | function createFiberFromFragment(elements, mode, lanes, key) {
|
19107 | var fiber = createFiber(Fragment, elements, key, mode);
|
19108 | fiber.lanes = lanes;
|
19109 | return fiber;
|
19110 | }
|
19111 |
|
19112 | function createFiberFromProfiler(pendingProps, mode, lanes, key) {
|
19113 | {
|
19114 | if (typeof pendingProps.id !== 'string') {
|
19115 | error('Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.', typeof pendingProps.id);
|
19116 | }
|
19117 | }
|
19118 |
|
19119 | var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
19120 | fiber.elementType = REACT_PROFILER_TYPE;
|
19121 | fiber.lanes = lanes;
|
19122 |
|
19123 | {
|
19124 | fiber.stateNode = {
|
19125 | effectDuration: 0,
|
19126 | passiveEffectDuration: 0
|
19127 | };
|
19128 | }
|
19129 |
|
19130 | return fiber;
|
19131 | }
|
19132 |
|
19133 | function createFiberFromSuspense(pendingProps, mode, lanes, key) {
|
19134 | var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
|
19135 | fiber.elementType = REACT_SUSPENSE_TYPE;
|
19136 | fiber.lanes = lanes;
|
19137 | return fiber;
|
19138 | }
|
19139 | function createFiberFromSuspenseList(pendingProps, mode, lanes, key) {
|
19140 | var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
|
19141 | fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
|
19142 | fiber.lanes = lanes;
|
19143 | return fiber;
|
19144 | }
|
19145 | function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
|
19146 | var fiber = createFiber(OffscreenComponent, pendingProps, key, mode);
|
19147 | fiber.elementType = REACT_OFFSCREEN_TYPE;
|
19148 | fiber.lanes = lanes;
|
19149 | var primaryChildInstance = {};
|
19150 | fiber.stateNode = primaryChildInstance;
|
19151 | return fiber;
|
19152 | }
|
19153 | function createFiberFromText(content, mode, lanes) {
|
19154 | var fiber = createFiber(HostText, content, null, mode);
|
19155 | fiber.lanes = lanes;
|
19156 | return fiber;
|
19157 | }
|
19158 | function createFiberFromPortal(portal, mode, lanes) {
|
19159 | var pendingProps = portal.children !== null ? portal.children : [];
|
19160 | var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
|
19161 | fiber.lanes = lanes;
|
19162 | fiber.stateNode = {
|
19163 | containerInfo: portal.containerInfo,
|
19164 | pendingChildren: null,
|
19165 |
|
19166 | implementation: portal.implementation
|
19167 | };
|
19168 | return fiber;
|
19169 | }
|
19170 |
|
19171 | function assignFiberPropertiesInDEV(target, source) {
|
19172 | if (target === null) {
|
19173 |
|
19174 |
|
19175 | target = createFiber(IndeterminateComponent, null, null, NoMode);
|
19176 | }
|
19177 |
|
19178 |
|
19179 |
|
19180 |
|
19181 |
|
19182 |
|
19183 | target.tag = source.tag;
|
19184 | target.key = source.key;
|
19185 | target.elementType = source.elementType;
|
19186 | target.type = source.type;
|
19187 | target.stateNode = source.stateNode;
|
19188 | target.return = source.return;
|
19189 | target.child = source.child;
|
19190 | target.sibling = source.sibling;
|
19191 | target.index = source.index;
|
19192 | target.ref = source.ref;
|
19193 | target.pendingProps = source.pendingProps;
|
19194 | target.memoizedProps = source.memoizedProps;
|
19195 | target.updateQueue = source.updateQueue;
|
19196 | target.memoizedState = source.memoizedState;
|
19197 | target.dependencies = source.dependencies;
|
19198 | target.mode = source.mode;
|
19199 | target.flags = source.flags;
|
19200 | target.subtreeFlags = source.subtreeFlags;
|
19201 | target.deletions = source.deletions;
|
19202 | target.lanes = source.lanes;
|
19203 | target.childLanes = source.childLanes;
|
19204 | target.alternate = source.alternate;
|
19205 |
|
19206 | {
|
19207 | target.actualDuration = source.actualDuration;
|
19208 | target.actualStartTime = source.actualStartTime;
|
19209 | target.selfBaseDuration = source.selfBaseDuration;
|
19210 | target.treeBaseDuration = source.treeBaseDuration;
|
19211 | }
|
19212 |
|
19213 | target._debugSource = source._debugSource;
|
19214 | target._debugOwner = source._debugOwner;
|
19215 | target._debugNeedsRemount = source._debugNeedsRemount;
|
19216 | target._debugHookTypes = source._debugHookTypes;
|
19217 | return target;
|
19218 | }
|
19219 |
|
19220 | function FiberRootNode(containerInfo, tag, hydrate, identifierPrefix, onRecoverableError) {
|
19221 | this.tag = tag;
|
19222 | this.containerInfo = containerInfo;
|
19223 | this.pendingChildren = null;
|
19224 | this.current = null;
|
19225 | this.pingCache = null;
|
19226 | this.finishedWork = null;
|
19227 | this.timeoutHandle = noTimeout;
|
19228 | this.context = null;
|
19229 | this.pendingContext = null;
|
19230 | this.callbackNode = null;
|
19231 | this.callbackPriority = NoLane;
|
19232 | this.eventTimes = createLaneMap(NoLanes);
|
19233 | this.expirationTimes = createLaneMap(NoTimestamp);
|
19234 | this.pendingLanes = NoLanes;
|
19235 | this.suspendedLanes = NoLanes;
|
19236 | this.pingedLanes = NoLanes;
|
19237 | this.expiredLanes = NoLanes;
|
19238 | this.mutableReadLanes = NoLanes;
|
19239 | this.finishedLanes = NoLanes;
|
19240 | this.entangledLanes = NoLanes;
|
19241 | this.entanglements = createLaneMap(NoLanes);
|
19242 | this.identifierPrefix = identifierPrefix;
|
19243 | this.onRecoverableError = onRecoverableError;
|
19244 |
|
19245 | {
|
19246 | this.effectDuration = 0;
|
19247 | this.passiveEffectDuration = 0;
|
19248 | }
|
19249 |
|
19250 | {
|
19251 | this.memoizedUpdaters = new Set();
|
19252 | var pendingUpdatersLaneMap = this.pendingUpdatersLaneMap = [];
|
19253 |
|
19254 | for (var _i = 0; _i < TotalLanes; _i++) {
|
19255 | pendingUpdatersLaneMap.push(new Set());
|
19256 | }
|
19257 | }
|
19258 |
|
19259 | {
|
19260 | switch (tag) {
|
19261 | case ConcurrentRoot:
|
19262 | this._debugRootType = hydrate ? 'hydrateRoot()' : 'createRoot()';
|
19263 | break;
|
19264 |
|
19265 | case LegacyRoot:
|
19266 | this._debugRootType = hydrate ? 'hydrate()' : 'render()';
|
19267 | break;
|
19268 | }
|
19269 | }
|
19270 | }
|
19271 |
|
19272 | function createFiberRoot(containerInfo, tag, hydrate, initialChildren, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, // TODO: We have several of these arguments that are conceptually part of the
|
19273 | // host config, but because they are passed in at runtime, we have to thread
|
19274 | // them through the root constructor. Perhaps we should put them all into a
|
19275 | // single type, like a DynamicHostConfig that is defined by the renderer.
|
19276 | identifierPrefix, onRecoverableError, transitionCallbacks) {
|
19277 | var root = new FiberRootNode(containerInfo, tag, hydrate, identifierPrefix, onRecoverableError);
|
19278 |
|
19279 |
|
19280 |
|
19281 | var uninitializedFiber = createHostRootFiber(tag, isStrictMode);
|
19282 | root.current = uninitializedFiber;
|
19283 | uninitializedFiber.stateNode = root;
|
19284 |
|
19285 | {
|
19286 | var _initialState = {
|
19287 | element: initialChildren,
|
19288 | isDehydrated: hydrate,
|
19289 | cache: null,
|
19290 |
|
19291 | transitions: null
|
19292 | };
|
19293 | uninitializedFiber.memoizedState = _initialState;
|
19294 | }
|
19295 |
|
19296 | initializeUpdateQueue(uninitializedFiber);
|
19297 | return root;
|
19298 | }
|
19299 |
|
19300 | var didWarnAboutNestedUpdates;
|
19301 |
|
19302 | {
|
19303 | didWarnAboutNestedUpdates = false;
|
19304 | }
|
19305 |
|
19306 | function getContextForSubtree(parentComponent) {
|
19307 | if (!parentComponent) {
|
19308 | return emptyContextObject;
|
19309 | }
|
19310 |
|
19311 | var fiber = get(parentComponent);
|
19312 | var parentContext = findCurrentUnmaskedContext(fiber);
|
19313 |
|
19314 | if (fiber.tag === ClassComponent) {
|
19315 | var Component = fiber.type;
|
19316 |
|
19317 | if (isContextProvider(Component)) {
|
19318 | return processChildContext(fiber, Component, parentContext);
|
19319 | }
|
19320 | }
|
19321 |
|
19322 | return parentContext;
|
19323 | }
|
19324 |
|
19325 | function createContainer(containerInfo, tag, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError, transitionCallbacks) {
|
19326 | var hydrate = false;
|
19327 | var initialChildren = null;
|
19328 | return createFiberRoot(containerInfo, tag, hydrate, initialChildren, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError);
|
19329 | }
|
19330 | function updateContainer(element, container, parentComponent, callback) {
|
19331 | {
|
19332 | onScheduleRoot(container, element);
|
19333 | }
|
19334 |
|
19335 | var current = container.current;
|
19336 | var eventTime = requestEventTime();
|
19337 | var lane = requestUpdateLane(current);
|
19338 |
|
19339 | {
|
19340 | markRenderScheduled(lane);
|
19341 | }
|
19342 |
|
19343 | var context = getContextForSubtree(parentComponent);
|
19344 |
|
19345 | if (container.context === null) {
|
19346 | container.context = context;
|
19347 | } else {
|
19348 | container.pendingContext = context;
|
19349 | }
|
19350 |
|
19351 | {
|
19352 | if (isRendering && current$1 !== null && !didWarnAboutNestedUpdates) {
|
19353 | didWarnAboutNestedUpdates = true;
|
19354 |
|
19355 | error('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.', getComponentNameFromFiber(current$1) || 'Unknown');
|
19356 | }
|
19357 | }
|
19358 |
|
19359 | var update = createUpdate(eventTime, lane);
|
19360 |
|
19361 |
|
19362 | update.payload = {
|
19363 | element: element
|
19364 | };
|
19365 | callback = callback === undefined ? null : callback;
|
19366 |
|
19367 | if (callback !== null) {
|
19368 | {
|
19369 | if (typeof callback !== 'function') {
|
19370 | error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
|
19371 | }
|
19372 | }
|
19373 |
|
19374 | update.callback = callback;
|
19375 | }
|
19376 |
|
19377 | enqueueUpdate(current, update);
|
19378 | var root = scheduleUpdateOnFiber(current, lane, eventTime);
|
19379 |
|
19380 | if (root !== null) {
|
19381 | entangleTransitions(root, current, lane);
|
19382 | }
|
19383 |
|
19384 | return lane;
|
19385 | }
|
19386 |
|
19387 | var shouldErrorImpl = function (fiber) {
|
19388 | return null;
|
19389 | };
|
19390 |
|
19391 | function shouldError(fiber) {
|
19392 | return shouldErrorImpl(fiber);
|
19393 | }
|
19394 |
|
19395 | var shouldSuspendImpl = function (fiber) {
|
19396 | return false;
|
19397 | };
|
19398 |
|
19399 | function shouldSuspend(fiber) {
|
19400 | return shouldSuspendImpl(fiber);
|
19401 | }
|
19402 | var overrideHookState = null;
|
19403 | var overrideHookStateDeletePath = null;
|
19404 | var overrideHookStateRenamePath = null;
|
19405 | var overrideProps = null;
|
19406 | var overridePropsDeletePath = null;
|
19407 | var overridePropsRenamePath = null;
|
19408 | var scheduleUpdate = null;
|
19409 | var setErrorHandler = null;
|
19410 | var setSuspenseHandler = null;
|
19411 |
|
19412 | {
|
19413 | var copyWithDeleteImpl = function (obj, path, index) {
|
19414 | var key = path[index];
|
19415 | var updated = isArray(obj) ? obj.slice() : assign({}, obj);
|
19416 |
|
19417 | if (index + 1 === path.length) {
|
19418 | if (isArray(updated)) {
|
19419 | updated.splice(key, 1);
|
19420 | } else {
|
19421 | delete updated[key];
|
19422 | }
|
19423 |
|
19424 | return updated;
|
19425 | }
|
19426 |
|
19427 |
|
19428 | updated[key] = copyWithDeleteImpl(obj[key], path, index + 1);
|
19429 | return updated;
|
19430 | };
|
19431 |
|
19432 | var copyWithDelete = function (obj, path) {
|
19433 | return copyWithDeleteImpl(obj, path, 0);
|
19434 | };
|
19435 |
|
19436 | var copyWithRenameImpl = function (obj, oldPath, newPath, index) {
|
19437 | var oldKey = oldPath[index];
|
19438 | var updated = isArray(obj) ? obj.slice() : assign({}, obj);
|
19439 |
|
19440 | if (index + 1 === oldPath.length) {
|
19441 | var newKey = newPath[index];
|
19442 |
|
19443 | updated[newKey] = updated[oldKey];
|
19444 |
|
19445 | if (isArray(updated)) {
|
19446 | updated.splice(oldKey, 1);
|
19447 | } else {
|
19448 | delete updated[oldKey];
|
19449 | }
|
19450 | } else {
|
19451 |
|
19452 | updated[oldKey] = copyWithRenameImpl(
|
19453 | obj[oldKey], oldPath, newPath, index + 1);
|
19454 | }
|
19455 |
|
19456 | return updated;
|
19457 | };
|
19458 |
|
19459 | var copyWithRename = function (obj, oldPath, newPath) {
|
19460 | if (oldPath.length !== newPath.length) {
|
19461 | warn('copyWithRename() expects paths of the same length');
|
19462 |
|
19463 | return;
|
19464 | } else {
|
19465 | for (var i = 0; i < newPath.length - 1; i++) {
|
19466 | if (oldPath[i] !== newPath[i]) {
|
19467 | warn('copyWithRename() expects paths to be the same except for the deepest key');
|
19468 |
|
19469 | return;
|
19470 | }
|
19471 | }
|
19472 | }
|
19473 |
|
19474 | return copyWithRenameImpl(obj, oldPath, newPath, 0);
|
19475 | };
|
19476 |
|
19477 | var copyWithSetImpl = function (obj, path, index, value) {
|
19478 | if (index >= path.length) {
|
19479 | return value;
|
19480 | }
|
19481 |
|
19482 | var key = path[index];
|
19483 | var updated = isArray(obj) ? obj.slice() : assign({}, obj);
|
19484 |
|
19485 | updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
|
19486 | return updated;
|
19487 | };
|
19488 |
|
19489 | var copyWithSet = function (obj, path, value) {
|
19490 | return copyWithSetImpl(obj, path, 0, value);
|
19491 | };
|
19492 |
|
19493 | var findHook = function (fiber, id) {
|
19494 |
|
19495 |
|
19496 | var currentHook = fiber.memoizedState;
|
19497 |
|
19498 | while (currentHook !== null && id > 0) {
|
19499 | currentHook = currentHook.next;
|
19500 | id--;
|
19501 | }
|
19502 |
|
19503 | return currentHook;
|
19504 | };
|
19505 |
|
19506 |
|
19507 | overrideHookState = function (fiber, id, path, value) {
|
19508 | var hook = findHook(fiber, id);
|
19509 |
|
19510 | if (hook !== null) {
|
19511 | var newState = copyWithSet(hook.memoizedState, path, value);
|
19512 | hook.memoizedState = newState;
|
19513 | hook.baseState = newState;
|
19514 |
|
19515 |
|
19516 |
|
19517 |
|
19518 |
|
19519 | fiber.memoizedProps = assign({}, fiber.memoizedProps);
|
19520 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
19521 | }
|
19522 | };
|
19523 |
|
19524 | overrideHookStateDeletePath = function (fiber, id, path) {
|
19525 | var hook = findHook(fiber, id);
|
19526 |
|
19527 | if (hook !== null) {
|
19528 | var newState = copyWithDelete(hook.memoizedState, path);
|
19529 | hook.memoizedState = newState;
|
19530 | hook.baseState = newState;
|
19531 |
|
19532 |
|
19533 |
|
19534 |
|
19535 |
|
19536 | fiber.memoizedProps = assign({}, fiber.memoizedProps);
|
19537 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
19538 | }
|
19539 | };
|
19540 |
|
19541 | overrideHookStateRenamePath = function (fiber, id, oldPath, newPath) {
|
19542 | var hook = findHook(fiber, id);
|
19543 |
|
19544 | if (hook !== null) {
|
19545 | var newState = copyWithRename(hook.memoizedState, oldPath, newPath);
|
19546 | hook.memoizedState = newState;
|
19547 | hook.baseState = newState;
|
19548 |
|
19549 |
|
19550 |
|
19551 |
|
19552 |
|
19553 | fiber.memoizedProps = assign({}, fiber.memoizedProps);
|
19554 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
19555 | }
|
19556 | };
|
19557 |
|
19558 |
|
19559 | overrideProps = function (fiber, path, value) {
|
19560 | fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
|
19561 |
|
19562 | if (fiber.alternate) {
|
19563 | fiber.alternate.pendingProps = fiber.pendingProps;
|
19564 | }
|
19565 |
|
19566 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
19567 | };
|
19568 |
|
19569 | overridePropsDeletePath = function (fiber, path) {
|
19570 | fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path);
|
19571 |
|
19572 | if (fiber.alternate) {
|
19573 | fiber.alternate.pendingProps = fiber.pendingProps;
|
19574 | }
|
19575 |
|
19576 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
19577 | };
|
19578 |
|
19579 | overridePropsRenamePath = function (fiber, oldPath, newPath) {
|
19580 | fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
19581 |
|
19582 | if (fiber.alternate) {
|
19583 | fiber.alternate.pendingProps = fiber.pendingProps;
|
19584 | }
|
19585 |
|
19586 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
19587 | };
|
19588 |
|
19589 | scheduleUpdate = function (fiber) {
|
19590 | scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
19591 | };
|
19592 |
|
19593 | setErrorHandler = function (newShouldErrorImpl) {
|
19594 | shouldErrorImpl = newShouldErrorImpl;
|
19595 | };
|
19596 |
|
19597 | setSuspenseHandler = function (newShouldSuspendImpl) {
|
19598 | shouldSuspendImpl = newShouldSuspendImpl;
|
19599 | };
|
19600 | }
|
19601 |
|
19602 | function findHostInstanceByFiber(fiber) {
|
19603 | var hostFiber = findCurrentHostFiber(fiber);
|
19604 |
|
19605 | if (hostFiber === null) {
|
19606 | return null;
|
19607 | }
|
19608 |
|
19609 | return hostFiber.stateNode;
|
19610 | }
|
19611 |
|
19612 | function emptyFindFiberByHostInstance(instance) {
|
19613 | return null;
|
19614 | }
|
19615 |
|
19616 | function getCurrentFiberForDevTools() {
|
19617 | return current$1;
|
19618 | }
|
19619 |
|
19620 | function injectIntoDevTools(devToolsConfig) {
|
19621 | var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
|
19622 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
19623 | return injectInternals({
|
19624 | bundleType: devToolsConfig.bundleType,
|
19625 | version: devToolsConfig.version,
|
19626 | rendererPackageName: devToolsConfig.rendererPackageName,
|
19627 | rendererConfig: devToolsConfig.rendererConfig,
|
19628 | overrideHookState: overrideHookState,
|
19629 | overrideHookStateDeletePath: overrideHookStateDeletePath,
|
19630 | overrideHookStateRenamePath: overrideHookStateRenamePath,
|
19631 | overrideProps: overrideProps,
|
19632 | overridePropsDeletePath: overridePropsDeletePath,
|
19633 | overridePropsRenamePath: overridePropsRenamePath,
|
19634 | setErrorHandler: setErrorHandler,
|
19635 | setSuspenseHandler: setSuspenseHandler,
|
19636 | scheduleUpdate: scheduleUpdate,
|
19637 | currentDispatcherRef: ReactCurrentDispatcher,
|
19638 | findHostInstanceByFiber: findHostInstanceByFiber,
|
19639 | findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance,
|
19640 |
|
19641 | findHostInstancesForRefresh: findHostInstancesForRefresh ,
|
19642 | scheduleRefresh: scheduleRefresh ,
|
19643 | scheduleRoot: scheduleRoot ,
|
19644 | setRefreshHandler: setRefreshHandler ,
|
19645 |
|
19646 | getCurrentFiber: getCurrentFiberForDevTools ,
|
19647 |
|
19648 |
|
19649 | reconcilerVersion: ReactVersion
|
19650 | });
|
19651 | }
|
19652 |
|
19653 | var container = _class({
|
19654 |
|
19655 | grab: function(){
|
19656 | for (var i = 0; i < arguments.length; i++) arguments[i].inject(this);
|
19657 | return this;
|
19658 | },
|
19659 |
|
19660 | empty: function(){
|
19661 | var node;
|
19662 | while (node = this.firstChild) node.eject();
|
19663 | return this;
|
19664 | }
|
19665 |
|
19666 | });
|
19667 |
|
19668 | function elementFrom(node){
|
19669 | if (node.toElement) return node.toElement();
|
19670 | if (node.getDOMNode) return node.getDOMNode();
|
19671 | if (node.getNode) return node.getNode();
|
19672 | return node;
|
19673 | }
|
19674 |
|
19675 | var native_1 = _class({
|
19676 |
|
19677 |
|
19678 |
|
19679 | toElement: function(){
|
19680 | return this.element;
|
19681 | },
|
19682 |
|
19683 | getDOMNode: function(){
|
19684 | return this.toElement();
|
19685 | },
|
19686 |
|
19687 | getNode: function(){
|
19688 | return this.toElement();
|
19689 | },
|
19690 |
|
19691 |
|
19692 |
|
19693 | inject: function(container){
|
19694 | (container.containerElement || elementFrom(container))
|
19695 | .appendChild(this.element);
|
19696 | return this;
|
19697 | },
|
19698 |
|
19699 | injectBefore: function(sibling){
|
19700 | var element = elementFrom(sibling);
|
19701 | element.parentNode.insertBefore(this.element, element);
|
19702 | return this;
|
19703 | },
|
19704 |
|
19705 | eject: function(){
|
19706 | var element = this.element, parent = element.parentNode;
|
19707 | if (parent) parent.removeChild(element);
|
19708 | return this;
|
19709 | },
|
19710 |
|
19711 |
|
19712 |
|
19713 | subscribe: function(type, fn, bind){
|
19714 | if (typeof type != 'string'){
|
19715 | var subscriptions = [];
|
19716 | for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
|
19717 | return function(){
|
19718 | for (var i = 0, l = subscriptions.length; i < l; i++)
|
19719 | subscriptions[i]();
|
19720 | return this;
|
19721 | };
|
19722 | } else {
|
19723 | if (!bind) bind = this;
|
19724 | var bound;
|
19725 | if (typeof fn === 'function'){
|
19726 | bound = fn.bind ? fn.bind(bind)
|
19727 | : function(){ return fn.apply(bind, arguments); };
|
19728 | } else {
|
19729 | bound = fn;
|
19730 | }
|
19731 | var element = this.element;
|
19732 | if (element.addEventListener){
|
19733 | element.addEventListener(type, bound, false);
|
19734 | return function(){
|
19735 | element.removeEventListener(type, bound, false);
|
19736 | return this;
|
19737 | };
|
19738 | } else {
|
19739 | element.attachEvent('on' + type, bound);
|
19740 | return function(){
|
19741 | element.detachEvent('on' + type, bound);
|
19742 | return this;
|
19743 | };
|
19744 | }
|
19745 | }
|
19746 | }
|
19747 |
|
19748 | });
|
19749 |
|
19750 | var fps = 1000 / 60, invalids = [], renderTimer, renderInvalids = function(){
|
19751 | clearTimeout(renderTimer);
|
19752 | renderTimer = null;
|
19753 | var canvases = invalids;
|
19754 | invalids = [];
|
19755 | for (var i = 0, l = canvases.length; i < l; i++){
|
19756 | var c = canvases[i];
|
19757 | c._valid = true;
|
19758 | c.render();
|
19759 | }
|
19760 | };
|
19761 |
|
19762 | var resolution = typeof window !== 'undefined' && window.devicePixelRatio || 1;
|
19763 |
|
19764 | var previousHit = null, previousHitSurface = null;
|
19765 |
|
19766 | var CanvasSurface = _class(native_1, container, {
|
19767 |
|
19768 | initialize: function(width, height, existingElement){
|
19769 | var element = this.element = existingElement || document.createElement('canvas');
|
19770 | var context = this.context = element.getContext('2d');
|
19771 | this._valid = true;
|
19772 | if (width != null && height != null) this.resize(width, height);
|
19773 |
|
19774 | element.addEventListener('mousemove', this, false);
|
19775 | element.addEventListener('mouseout', this, false);
|
19776 | element.addEventListener('mouseover', this, false);
|
19777 | element.addEventListener('mouseup', this, false);
|
19778 | element.addEventListener('mousedown', this, false);
|
19779 | element.addEventListener('click', this, false);
|
19780 | },
|
19781 |
|
19782 | handleEvent: function(event){
|
19783 | if (event.clientX == null) return;
|
19784 | var element = this.element,
|
19785 | rect = element.getBoundingClientRect(),
|
19786 | x = event.clientX - rect.left - element.clientLeft,
|
19787 | y = event.clientY - rect.top - element.clientTop,
|
19788 | hit = this.hitTest(x, y);
|
19789 |
|
19790 | if (hit !== previousHit){
|
19791 | if (previousHit){
|
19792 | previousHit.dispatch({
|
19793 | type: 'mouseout',
|
19794 | target: previousHit,
|
19795 | relatedTarget: hit,
|
19796 | sourceEvent: event
|
19797 | });
|
19798 | }
|
19799 | if (hit){
|
19800 | hit.dispatch({
|
19801 | type: 'mouseover',
|
19802 | target: hit,
|
19803 | relatedTarget: previousHit,
|
19804 | sourceEvent: event
|
19805 | });
|
19806 | }
|
19807 | previousHit = hit;
|
19808 | previousHitSurface = this;
|
19809 | this.refreshCursor();
|
19810 | }
|
19811 |
|
19812 | if (hit) hit.dispatch(event);
|
19813 | },
|
19814 |
|
19815 | refreshCursor: function(){
|
19816 | if (previousHitSurface !== this) return;
|
19817 | var hit = previousHit, hitCursor = '', hitTooltip = '';
|
19818 | while (hit){
|
19819 | if (!hitCursor && hit._cursor){
|
19820 | hitCursor = hit._cursor;
|
19821 | if (hitTooltip) break;
|
19822 | }
|
19823 | if (!hitTooltip && hit._tooltip){
|
19824 | hitTooltip = hit._tooltip;
|
19825 | if (hitCursor) break;
|
19826 | }
|
19827 | hit = hit.parentNode;
|
19828 | }
|
19829 |
|
19830 | this.element.style.cursor = hitCursor;
|
19831 | this.element.title = hitTooltip;
|
19832 | },
|
19833 |
|
19834 | resize: function(width, height){
|
19835 | var element = this.element;
|
19836 | element.setAttribute('width', width * resolution);
|
19837 | element.setAttribute('height', height * resolution);
|
19838 | element.style.width = width + 'px';
|
19839 | element.style.height = height + 'px';
|
19840 | this.width = width;
|
19841 | this.height = height;
|
19842 | return this;
|
19843 | },
|
19844 |
|
19845 | invalidate: function(left, top, width, height){
|
19846 | if (this._valid){
|
19847 | this._valid = false;
|
19848 | invalids.push(this);
|
19849 | if (!renderTimer){
|
19850 | if (window.mozRequestAnimationFrame){
|
19851 | renderTimer = true;
|
19852 | window.mozRequestAnimationFrame(renderInvalids);
|
19853 | } else {
|
19854 | renderTimer = setTimeout(renderInvalids, fps);
|
19855 | }
|
19856 | }
|
19857 | }
|
19858 | return this;
|
19859 | },
|
19860 |
|
19861 | hitTest: function(x, y){
|
19862 | if (x < 0 || y < 0 || x > this.width || y > this.height) return null;
|
19863 | var node = this.lastChild;
|
19864 | while (node){
|
19865 | var hit = node.hitTest(x, y);
|
19866 | if (hit) return hit;
|
19867 | node = node.previousSibling;
|
19868 | }
|
19869 | return null;
|
19870 | },
|
19871 |
|
19872 | render: function(){
|
19873 | var node = this.firstChild, context = this.context;
|
19874 | context.setTransform(resolution, 0, 0, resolution, 0, 0);
|
19875 | context.clearRect(0, 0, this.width, this.height);
|
19876 | while (node){
|
19877 | node.renderTo(context, resolution, 0, 0, resolution, 0, 0);
|
19878 | node = node.nextSibling;
|
19879 | }
|
19880 | this.refreshCursor();
|
19881 | }
|
19882 |
|
19883 | });
|
19884 |
|
19885 | CanvasSurface.tagName = 'canvas';
|
19886 |
|
19887 | var surface = CanvasSurface;
|
19888 |
|
19889 | var path = _class({
|
19890 |
|
19891 | initialize: function(path){
|
19892 | this.reset().push(path);
|
19893 | },
|
19894 |
|
19895 |
|
19896 |
|
19897 | push: function(){
|
19898 | var p = Array.prototype.join.call(arguments, ' ')
|
19899 | .match(/[a-df-z]|[\-+]?(?:[\d\.]e[\-+]?|[^\s\-+,a-z])+/ig);
|
19900 | if (!p) return this;
|
19901 |
|
19902 | var last, cmd = p[0], i = 1;
|
19903 | while (cmd){
|
19904 | switch (cmd){
|
19905 | case 'm': this.move(p[i++], p[i++]); break;
|
19906 | case 'l': this.line(p[i++], p[i++]); break;
|
19907 | case 'c': this.curve(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
|
19908 | case 's': this.curve(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
19909 | case 'q': this.curve(p[i++], p[i++], p[i++], p[i++]); break;
|
19910 | case 't': this.curve(p[i++], p[i++]); break;
|
19911 | 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;
|
19912 | case 'h': this.line(p[i++], 0); break;
|
19913 | case 'v': this.line(0, p[i++]); break;
|
19914 |
|
19915 | case 'M': this.moveTo(p[i++], p[i++]); break;
|
19916 | case 'L': this.lineTo(p[i++], p[i++]); break;
|
19917 | case 'C': this.curveTo(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
|
19918 | case 'S': this.curveTo(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
19919 | case 'Q': this.curveTo(p[i++], p[i++], p[i++], p[i++]); break;
|
19920 | case 'T': this.curveTo(p[i++], p[i++]); break;
|
19921 | 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;
|
19922 | case 'H': this.lineTo(p[i++], this.penY); break;
|
19923 | case 'V': this.lineTo(this.penX, p[i++]); break;
|
19924 |
|
19925 | case 'Z': case 'z': this.close(); break;
|
19926 | default: cmd = last; i--; continue;
|
19927 | }
|
19928 |
|
19929 | last = cmd;
|
19930 | if (last == 'm') last = 'l';
|
19931 | else if (last == 'M') last = 'L';
|
19932 | cmd = p[i++];
|
19933 | }
|
19934 | return this;
|
19935 | },
|
19936 |
|
19937 |
|
19938 |
|
19939 | reset: function(){
|
19940 | this.penX = this.penY = 0;
|
19941 | this.penDownX = this.penDownY = null;
|
19942 | this._pivotX = this._pivotY = 0;
|
19943 | this.onReset();
|
19944 | return this;
|
19945 | },
|
19946 |
|
19947 | move: function(x,y){
|
19948 | this.onMove(this.penX, this.penY, this._pivotX = this.penX += (+x), this._pivotY = this.penY += (+y));
|
19949 | return this;
|
19950 | },
|
19951 | moveTo: function(x,y){
|
19952 | this.onMove(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
|
19953 | return this;
|
19954 | },
|
19955 |
|
19956 | line: function(x,y){
|
19957 | return this.lineTo(this.penX + (+x), this.penY + (+y));
|
19958 | },
|
19959 | lineTo: function(x,y){
|
19960 | if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
|
19961 | this.onLine(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
|
19962 | return this;
|
19963 | },
|
19964 |
|
19965 | curve: function(c1x, c1y, c2x, c2y, ex, ey){
|
19966 | var x = this.penX, y = this.penY;
|
19967 | return this.curveTo(
|
19968 | x + (+c1x), y + (+c1y),
|
19969 | c2x == null ? null : x + (+c2x),
|
19970 | c2y == null ? null : y + (+c2y),
|
19971 | ex == null ? null : x + (+ex),
|
19972 | ey == null ? null : y + (+ey)
|
19973 | );
|
19974 | },
|
19975 | curveTo: function(c1x, c1y, c2x, c2y, ex, ey){
|
19976 | var x = this.penX, y = this.penY;
|
19977 | if (c2x == null){
|
19978 | c2x = +c1x; c2y = +c1y;
|
19979 | c1x = (x * 2) - (this._pivotX || 0); c1y = (y * 2) - (this._pivotY || 0);
|
19980 | }
|
19981 | if (ex == null){
|
19982 | this._pivotX = +c1x; this._pivotY = +c1y;
|
19983 | ex = +c2x; ey = +c2y;
|
19984 | c2x = (ex + (+c1x) * 2) / 3; c2y = (ey + (+c1y) * 2) / 3;
|
19985 | c1x = (x + (+c1x) * 2) / 3; c1y = (y + (+c1y) * 2) / 3;
|
19986 | } else {
|
19987 | this._pivotX = +c2x; this._pivotY = +c2y;
|
19988 | }
|
19989 | if (this.penDownX == null){ this.penDownX = x; this.penDownY = y; }
|
19990 | this.onBezierCurve(x, y, +c1x, +c1y, +c2x, +c2y, this.penX = +ex, this.penY = +ey);
|
19991 | return this;
|
19992 | },
|
19993 |
|
19994 | arc: function(x, y, rx, ry, outer, counterClockwise, rotation){
|
19995 | return this.arcTo(this.penX + (+x), this.penY + (+y), rx, ry, outer, counterClockwise, rotation);
|
19996 | },
|
19997 | arcTo: function(x, y, rx, ry, outer, counterClockwise, rotation){
|
19998 | ry = Math.abs(+ry || +rx || (+y - this.penY));
|
19999 | rx = Math.abs(+rx || (+x - this.penX));
|
20000 |
|
20001 | if (!rx || !ry || (x == this.penX && y == this.penY)) return this.lineTo(x, y);
|
20002 |
|
20003 | var tX = this.penX, tY = this.penY, clockwise = !+counterClockwise, large = !!+outer;
|
20004 |
|
20005 | var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad);
|
20006 | x -= tX; y -= tY;
|
20007 |
|
20008 |
|
20009 | var cx = cos * x / 2 + sin * y / 2,
|
20010 | cy = -sin * x / 2 + cos * y / 2,
|
20011 | rxry = rx * rx * ry * ry,
|
20012 | rycx = ry * ry * cx * cx,
|
20013 | rxcy = rx * rx * cy * cy,
|
20014 | a = rxry - rxcy - rycx;
|
20015 |
|
20016 | if (a < 0){
|
20017 | a = Math.sqrt(1 - a / rxry);
|
20018 | rx *= a; ry *= a;
|
20019 | cx = x / 2; cy = y / 2;
|
20020 | } else {
|
20021 | a = Math.sqrt(a / (rxcy + rycx));
|
20022 | if (large == clockwise) a = -a;
|
20023 | var cxd = -a * cy * rx / ry,
|
20024 | cyd = a * cx * ry / rx;
|
20025 | cx = cos * cxd - sin * cyd + x / 2;
|
20026 | cy = sin * cxd + cos * cyd + y / 2;
|
20027 | }
|
20028 |
|
20029 |
|
20030 | var xx = cos / rx, yx = sin / rx,
|
20031 | xy = -sin / ry, yy = cos / ry;
|
20032 |
|
20033 |
|
20034 | var sa = Math.atan2(xy * -cx + yy * -cy, xx * -cx + yx * -cy),
|
20035 | ea = Math.atan2(xy * (x - cx) + yy * (y - cy), xx * (x - cx) + yx * (y - cy));
|
20036 |
|
20037 | cx += tX; cy += tY;
|
20038 | x += tX; y += tY;
|
20039 |
|
20040 |
|
20041 | if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
|
20042 | this.onArc(
|
20043 | tX, tY, this._pivotX = this.penX = x, this._pivotY = this.penY = y,
|
20044 | cx, cy, rx, ry, sa, ea, !clockwise, rotation
|
20045 | );
|
20046 | return this;
|
20047 | },
|
20048 |
|
20049 | counterArc: function(x, y, rx, ry, outer){
|
20050 | return this.arc(x, y, rx, ry, outer, true);
|
20051 | },
|
20052 | counterArcTo: function(x, y, rx, ry, outer){
|
20053 | return this.arcTo(x, y, rx, ry, outer, true);
|
20054 | },
|
20055 |
|
20056 | close: function(){
|
20057 | if (this.penDownX != null){
|
20058 | this.onClose(this.penX, this.penY, this.penX = this.penDownX, this.penY = this.penDownY);
|
20059 | this.penDownX = null;
|
20060 | }
|
20061 | return this;
|
20062 | },
|
20063 |
|
20064 |
|
20065 |
|
20066 | onReset: function(){
|
20067 | },
|
20068 |
|
20069 | onMove: function(sx, sy, ex, ey){
|
20070 | },
|
20071 |
|
20072 | onLine: function(sx, sy, ex, ey){
|
20073 | this.onBezierCurve(sx, sy, sx, sy, ex, ey, ex, ey);
|
20074 | },
|
20075 |
|
20076 | onBezierCurve: function(sx, sy, c1x, c1y, c2x, c2y, ex, ey){
|
20077 | var gx = ex - sx, gy = ey - sy,
|
20078 | g = gx * gx + gy * gy,
|
20079 | v1, v2, cx, cy, u;
|
20080 |
|
20081 | cx = c1x - sx; cy = c1y - sy;
|
20082 | u = cx * gx + cy * gy;
|
20083 |
|
20084 | if (u > g){
|
20085 | cx -= gx;
|
20086 | cy -= gy;
|
20087 | } else if (u > 0 && g != 0){
|
20088 | cx -= u/g * gx;
|
20089 | cy -= u/g * gy;
|
20090 | }
|
20091 |
|
20092 | v1 = cx * cx + cy * cy;
|
20093 |
|
20094 | cx = c2x - sx; cy = c2y - sy;
|
20095 | u = cx * gx + cy * gy;
|
20096 |
|
20097 | if (u > g){
|
20098 | cx -= gx;
|
20099 | cy -= gy;
|
20100 | } else if (u > 0 && g != 0){
|
20101 | cx -= u/g * gx;
|
20102 | cy -= u/g * gy;
|
20103 | }
|
20104 |
|
20105 | v2 = cx * cx + cy * cy;
|
20106 |
|
20107 | if (v1 < 0.01 && v2 < 0.01){
|
20108 | this.onLine(sx, sy, ex, ey);
|
20109 | return;
|
20110 | }
|
20111 |
|
20112 |
|
20113 | if (isNaN(v1) || isNaN(v2)){
|
20114 | throw new Error('Bad input');
|
20115 | }
|
20116 |
|
20117 |
|
20118 | var s1x = (c1x + c2x) * 0.5, s1y = (c1y + c2y) * 0.5,
|
20119 | l1x = (c1x + sx) * 0.5, l1y = (c1y + sy) * 0.5,
|
20120 | l2x = (l1x + s1x) * 0.5, l2y = (l1y + s1y) * 0.5,
|
20121 | r2x = (ex + c2x) * 0.5, r2y = (ey + c2y) * 0.5,
|
20122 | r1x = (r2x + s1x) * 0.5, r1y = (r2y + s1y) * 0.5,
|
20123 | l2r1x = (l2x + r1x) * 0.5, l2r1y = (l2y + r1y) * 0.5;
|
20124 |
|
20125 |
|
20126 | this.onBezierCurve(sx, sy, l1x, l1y, l2x, l2y, l2r1x, l2r1y);
|
20127 | this.onBezierCurve(l2r1x, l2r1y, r1x, r1y, r2x, r2y, ex, ey);
|
20128 | },
|
20129 |
|
20130 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
20131 |
|
20132 | var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad),
|
20133 | xx = cos * rx, yx = -sin * ry,
|
20134 | xy = sin * rx, yy = cos * ry;
|
20135 |
|
20136 |
|
20137 | var arc = ea - sa;
|
20138 | if (arc < 0 && !ccw) arc += Math.PI * 2;
|
20139 | else if (arc > 0 && ccw) arc -= Math.PI * 2;
|
20140 |
|
20141 | var n = Math.ceil(Math.abs(arc / (Math.PI / 2))),
|
20142 | step = arc / n,
|
20143 | k = (4 / 3) * Math.tan(step / 4);
|
20144 |
|
20145 | var x = Math.cos(sa), y = Math.sin(sa);
|
20146 |
|
20147 | for (var i = 0; i < n; i++){
|
20148 | var cp1x = x - k * y, cp1y = y + k * x;
|
20149 |
|
20150 | sa += step;
|
20151 | x = Math.cos(sa); y = Math.sin(sa);
|
20152 |
|
20153 | var cp2x = x + k * y, cp2y = y - k * x;
|
20154 |
|
20155 | this.onBezierCurve(
|
20156 | sx, sy,
|
20157 | cx + xx * cp1x + yx * cp1y, cy + xy * cp1x + yy * cp1y,
|
20158 | cx + xx * cp2x + yx * cp2y, cy + xy * cp2x + yy * cp2y,
|
20159 | (sx = (cx + xx * x + yx * y)), (sy = (cy + xy * x + yy * y))
|
20160 | );
|
20161 | }
|
20162 | },
|
20163 |
|
20164 | onClose: function(sx, sy, ex, ey){
|
20165 | this.onLine(sx, sy, ex, ey);
|
20166 | }
|
20167 |
|
20168 | });
|
20169 |
|
20170 | var CanvasPath = _class(path, {
|
20171 |
|
20172 | initialize: function(path){
|
20173 | this.reset();
|
20174 | if (path instanceof CanvasPath){
|
20175 | this.path = path.path.slice(0);
|
20176 | } else if (path){
|
20177 | if (path.applyToPath)
|
20178 | path.applyToPath(this);
|
20179 | else
|
20180 | this.push(path);
|
20181 | }
|
20182 | },
|
20183 |
|
20184 | onReset: function(){
|
20185 | this.path = [];
|
20186 | },
|
20187 |
|
20188 | onMove: function(sx, sy, x, y){
|
20189 | this.path.push(function(context){
|
20190 | context.moveTo(x, y);
|
20191 | });
|
20192 | },
|
20193 |
|
20194 | onLine: function(sx, sy, x, y){
|
20195 | this.path.push(function(context){
|
20196 | context.lineTo(x, y);
|
20197 | });
|
20198 | },
|
20199 |
|
20200 | onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
|
20201 | this.path.push(function(context){
|
20202 | context.bezierCurveTo(p1x, p1y, p2x, p2y, x, y);
|
20203 | });
|
20204 | },
|
20205 |
|
20206 | _arcToBezier: path.prototype.onArc,
|
20207 |
|
20208 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
20209 | if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
|
20210 | this.path.push(function(context){
|
20211 | context.arc(cx, cy, rx, sa, ea, ccw);
|
20212 | });
|
20213 | },
|
20214 |
|
20215 | onClose: function(){
|
20216 | this.path.push(function(context){
|
20217 | context.closePath();
|
20218 | });
|
20219 | },
|
20220 |
|
20221 | toCommands: function(){
|
20222 | return this.path.slice(0);
|
20223 | }
|
20224 |
|
20225 | });
|
20226 |
|
20227 | var path$1 = CanvasPath;
|
20228 |
|
20229 | var colors = {
|
20230 | maroon: '#800000', red: '#ff0000', orange: '#ffA500', yellow: '#ffff00', olive: '#808000',
|
20231 | purple: '#800080', fuchsia: "#ff00ff", white: '#ffffff', lime: '#00ff00', green: '#008000',
|
20232 | navy: '#000080', blue: '#0000ff', aqua: '#00ffff', teal: '#008080',
|
20233 | black: '#000000', silver: '#c0c0c0', gray: '#808080'
|
20234 | };
|
20235 |
|
20236 | var map = function(array, fn){
|
20237 | var results = [];
|
20238 | for (var i = 0, l = array.length; i < l; i++)
|
20239 | results[i] = fn(array[i], i);
|
20240 | return results;
|
20241 | };
|
20242 |
|
20243 | var Color = function(color, type){
|
20244 |
|
20245 | if (color.isColor){
|
20246 |
|
20247 | this.red = color.red;
|
20248 | this.green = color.green;
|
20249 | this.blue = color.blue;
|
20250 | this.alpha = color.alpha;
|
20251 |
|
20252 | } else {
|
20253 |
|
20254 | var namedColor = colors[color];
|
20255 | if (namedColor){
|
20256 | color = namedColor;
|
20257 | type = 'hex';
|
20258 | }
|
20259 |
|
20260 | switch (typeof color){
|
20261 | case 'string': if (!type) type = (type = color.match(/^rgb|^hsb|^hsl/)) ? type[0] : 'hex'; break;
|
20262 | case 'object': type = type || 'rgb'; color = color.toString(); break;
|
20263 | case 'number': type = 'hex'; color = color.toString(16); break;
|
20264 | }
|
20265 |
|
20266 | color = Color['parse' + type.toUpperCase()](color);
|
20267 | this.red = color[0];
|
20268 | this.green = color[1];
|
20269 | this.blue = color[2];
|
20270 | this.alpha = color[3];
|
20271 | }
|
20272 |
|
20273 | this.isColor = true;
|
20274 |
|
20275 | };
|
20276 |
|
20277 | var limit = function(number, min, max){
|
20278 | return Math.min(max, Math.max(min, number));
|
20279 | };
|
20280 |
|
20281 | var listMatch = /([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,?\s*([-.\d]*\%?)/;
|
20282 | var hexMatch = /^#?([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{0,2})$/i;
|
20283 |
|
20284 | Color.parseRGB = function(color){
|
20285 | return map(color.match(listMatch).slice(1), function(bit, i){
|
20286 | if (bit) bit = parseFloat(bit) * (bit[bit.length - 1] == '%' ? 2.55 : 1);
|
20287 | return (i < 3) ? Math.round(((bit %= 256) < 0) ? bit + 256 : bit) : limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
20288 | });
|
20289 | };
|
20290 |
|
20291 | Color.parseHEX = function(color){
|
20292 | if (color.length == 1) color = color + color + color;
|
20293 | return map(color.match(hexMatch).slice(1), function(bit, i){
|
20294 | if (i == 3) return (bit) ? parseInt(bit, 16) / 255 : 1;
|
20295 | return parseInt((bit.length == 1) ? bit + bit : bit, 16);
|
20296 | });
|
20297 | };
|
20298 |
|
20299 | Color.parseHSB = function(color){
|
20300 | var hsb = map(color.match(listMatch).slice(1), function(bit, i){
|
20301 | if (bit) bit = parseFloat(bit);
|
20302 | if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
|
20303 | else if (i < 3) return limit(Math.round(bit), 0, 100);
|
20304 | else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
20305 | });
|
20306 |
|
20307 | var a = hsb[3];
|
20308 | var br = Math.round(hsb[2] / 100 * 255);
|
20309 | if (hsb[1] == 0) return [br, br, br, a];
|
20310 |
|
20311 | var hue = hsb[0];
|
20312 | var f = hue % 60;
|
20313 | var p = Math.round((hsb[2] * (100 - hsb[1])) / 10000 * 255);
|
20314 | var q = Math.round((hsb[2] * (6000 - hsb[1] * f)) / 600000 * 255);
|
20315 | var t = Math.round((hsb[2] * (6000 - hsb[1] * (60 - f))) / 600000 * 255);
|
20316 |
|
20317 | switch (Math.floor(hue / 60)){
|
20318 | case 0: return [br, t, p, a];
|
20319 | case 1: return [q, br, p, a];
|
20320 | case 2: return [p, br, t, a];
|
20321 | case 3: return [p, q, br, a];
|
20322 | case 4: return [t, p, br, a];
|
20323 | default: return [br, p, q, a];
|
20324 | }
|
20325 | };
|
20326 |
|
20327 | Color.parseHSL = function(color){
|
20328 | var hsb = map(color.match(listMatch).slice(1), function(bit, i){
|
20329 | if (bit) bit = parseFloat(bit);
|
20330 | if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
|
20331 | else if (i < 3) return limit(Math.round(bit), 0, 100);
|
20332 | else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
20333 | });
|
20334 |
|
20335 | var h = hsb[0] / 60;
|
20336 | var s = hsb[1] / 100;
|
20337 | var l = hsb[2] / 100;
|
20338 | var a = hsb[3];
|
20339 |
|
20340 | var c = (1 - Math.abs(2 * l - 1)) * s;
|
20341 | var x = c * (1 - Math.abs(h % 2 - 1));
|
20342 | var m = l - c / 2;
|
20343 |
|
20344 | var p = Math.round((c + m) * 255);
|
20345 | var q = Math.round((x + m) * 255);
|
20346 | var t = Math.round((m) * 255);
|
20347 |
|
20348 | switch (Math.floor(h)){
|
20349 | case 0: return [p, q, t, a];
|
20350 | case 1: return [q, p, t, a];
|
20351 | case 2: return [t, p, q, a];
|
20352 | case 3: return [t, q, p, a];
|
20353 | case 4: return [q, t, p, a];
|
20354 | default: return [p, t, q, a];
|
20355 | }
|
20356 | };
|
20357 |
|
20358 | var toString = function(type, array){
|
20359 | if (array[3] != 1) type += 'a';
|
20360 | else array.pop();
|
20361 | return type + '(' + array.join(', ') + ')';
|
20362 | };
|
20363 |
|
20364 | Color.prototype = {
|
20365 |
|
20366 | toHSB: function(array){
|
20367 | var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
|
20368 |
|
20369 | var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
|
20370 | var hue = 0, saturation = (delta != 0) ? delta / max : 0, brightness = max / 255;
|
20371 | if (saturation){
|
20372 | var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
|
20373 | hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
|
20374 | if ((hue /= 6) < 0) hue++;
|
20375 | }
|
20376 |
|
20377 | var hsb = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(brightness * 100), alpha];
|
20378 |
|
20379 | return (array) ? hsb : toString('hsb', hsb);
|
20380 | },
|
20381 |
|
20382 | toHSL: function(array){
|
20383 | var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
|
20384 |
|
20385 | var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
|
20386 | var hue = 0, saturation = (delta != 0) ? delta / (255 - Math.abs((max + min) - 255)) : 0, lightness = (max + min) / 512;
|
20387 | if (saturation){
|
20388 | var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
|
20389 | hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
|
20390 | if ((hue /= 6) < 0) hue++;
|
20391 | }
|
20392 |
|
20393 | var hsl = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(lightness * 100), alpha];
|
20394 |
|
20395 | return (array) ? hsl : toString('hsl', hsl);
|
20396 | },
|
20397 |
|
20398 | toHEX: function(array){
|
20399 |
|
20400 | var a = this.alpha;
|
20401 | var alpha = ((a = Math.round((a * 255)).toString(16)).length == 1) ? a + a : a;
|
20402 |
|
20403 | var hex = map([this.red, this.green, this.blue], function(bit){
|
20404 | bit = bit.toString(16);
|
20405 | return (bit.length == 1) ? '0' + bit : bit;
|
20406 | });
|
20407 |
|
20408 | return (array) ? hex.concat(alpha) : '#' + hex.join('') + ((alpha == 'ff') ? '' : alpha);
|
20409 | },
|
20410 |
|
20411 | toRGB: function(array){
|
20412 | var rgb = [this.red, this.green, this.blue, this.alpha];
|
20413 | return (array) ? rgb : toString('rgb', rgb);
|
20414 | }
|
20415 |
|
20416 | };
|
20417 |
|
20418 | Color.prototype.toString = Color.prototype.toRGB;
|
20419 |
|
20420 | Color.hex = function(hex){
|
20421 | return new Color(hex, 'hex');
|
20422 | };
|
20423 |
|
20424 | if (commonjsGlobal.hex == null) commonjsGlobal.hex = Color.hex;
|
20425 |
|
20426 | Color.hsb = function(h, s, b, a){
|
20427 | return new Color([h || 0, s || 0, b || 0, (a == null) ? 1 : a], 'hsb');
|
20428 | };
|
20429 |
|
20430 | if (commonjsGlobal.hsb == null) commonjsGlobal.hsb = Color.hsb;
|
20431 |
|
20432 | Color.hsl = function(h, s, l, a){
|
20433 | return new Color([h || 0, s || 0, l || 0, (a == null) ? 1 : a], 'hsl');
|
20434 | };
|
20435 |
|
20436 | if (commonjsGlobal.hsl == null) commonjsGlobal.hsl = Color.hsl;
|
20437 |
|
20438 | Color.rgb = function(r, g, b, a){
|
20439 | return new Color([r || 0, g || 0, b || 0, (a == null) ? 1 : a], 'rgb');
|
20440 | };
|
20441 |
|
20442 | if (commonjsGlobal.rgb == null) commonjsGlobal.rgb = Color.rgb;
|
20443 |
|
20444 | Color.detach = function(color){
|
20445 | color = new Color(color);
|
20446 | return [Color.rgb(color.red, color.green, color.blue).toString(), color.alpha];
|
20447 | };
|
20448 |
|
20449 | var color = Color;
|
20450 |
|
20451 | var dummy = _class({
|
20452 |
|
20453 |
|
20454 |
|
20455 | _resetPlacement: function(){
|
20456 | var container = this.parentNode;
|
20457 | if (container){
|
20458 | var previous = this.previousSibling, next = this.nextSibling;
|
20459 | if (previous){
|
20460 | previous.nextSibling = next;
|
20461 | } else {
|
20462 | container.firstChild = next;
|
20463 | }
|
20464 | if (next){
|
20465 | next.previousSibling = previous;
|
20466 | } else {
|
20467 | container.lastChild = this.previousSibling;
|
20468 | }
|
20469 | }
|
20470 | this.previousSibling = null;
|
20471 | this.nextSibling = null;
|
20472 | this.parentNode = null;
|
20473 | return this;
|
20474 | },
|
20475 |
|
20476 | inject: function(container){
|
20477 | this._resetPlacement();
|
20478 | var last = container.lastChild;
|
20479 | if (last){
|
20480 | last.nextSibling = this;
|
20481 | this.previousSibling = last;
|
20482 | } else {
|
20483 | container.firstChild = this;
|
20484 | }
|
20485 | container.lastChild = this;
|
20486 | this.parentNode = container;
|
20487 | this._place();
|
20488 | return this;
|
20489 | },
|
20490 |
|
20491 | injectBefore: function(sibling){
|
20492 | this._resetPlacement();
|
20493 | var container = sibling.parentNode;
|
20494 | if (!container) return this;
|
20495 | var previous = sibling.previousSibling;
|
20496 | if (previous){
|
20497 | previous.nextSibling = this;
|
20498 | this.previousSibling = previous;
|
20499 | } else {
|
20500 | container.firstChild = this;
|
20501 | }
|
20502 | sibling.previousSibling = this;
|
20503 | this.nextSibling = sibling;
|
20504 | this.parentNode = container;
|
20505 | this._place();
|
20506 | return this;
|
20507 | },
|
20508 |
|
20509 | eject: function(){
|
20510 | this._resetPlacement();
|
20511 | this._place();
|
20512 | return this;
|
20513 | },
|
20514 |
|
20515 | _place: function(){},
|
20516 |
|
20517 |
|
20518 |
|
20519 | dispatch: function(event){
|
20520 | var events = this._events,
|
20521 | listeners = events && events[event.type];
|
20522 | if (listeners){
|
20523 | listeners = listeners.slice(0);
|
20524 | for (var i = 0, l = listeners.length; i < l; i++){
|
20525 | var fn = listeners[i], result;
|
20526 | if (typeof fn == 'function')
|
20527 | result = fn.call(this, event);
|
20528 | else
|
20529 | result = fn.handleEvent(event);
|
20530 | if (result === false) event.preventDefault();
|
20531 | }
|
20532 | }
|
20533 | if (this.parentNode && this.parentNode.dispatch){
|
20534 | this.parentNode.dispatch(event);
|
20535 | }
|
20536 | },
|
20537 |
|
20538 | subscribe: function(type, fn, bind){
|
20539 | if (typeof type != 'string'){
|
20540 | var subscriptions = [];
|
20541 | for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
|
20542 | return function(){
|
20543 | for (var i = 0, l = subscriptions.length; i < l; i++)
|
20544 | subscriptions[i]();
|
20545 | return this;
|
20546 | };
|
20547 | } else {
|
20548 | var bound = typeof fn === 'function' ? fn.bind(bind || this) : fn,
|
20549 | events = this._events || (this._events = {}),
|
20550 | listeners = events[type] || (events[type] = []);
|
20551 | listeners.push(bound);
|
20552 | return function(){
|
20553 |
|
20554 | for (var i = 0, l = listeners.length; i < l; i++){
|
20555 | if (listeners[i] === bound){
|
20556 | listeners.splice(i, 1);
|
20557 | break;
|
20558 | }
|
20559 | }
|
20560 | }
|
20561 | }
|
20562 | }
|
20563 |
|
20564 | });
|
20565 |
|
20566 | var CanvasNode = _class(transform, dummy, {
|
20567 |
|
20568 | invalidate: function(){
|
20569 | if (this.parentNode) this.parentNode.invalidate();
|
20570 | if (this._layer) this._layerCache = null;
|
20571 | return this;
|
20572 | },
|
20573 |
|
20574 | _place: function(){
|
20575 | this.invalidate();
|
20576 | },
|
20577 |
|
20578 | _transform: function(){
|
20579 | this.invalidate();
|
20580 | },
|
20581 |
|
20582 | blend: function(opacity){
|
20583 | if (opacity >= 1 && this._layer) this._layer = null;
|
20584 | this._opacity = opacity;
|
20585 | if (this.parentNode) this.parentNode.invalidate();
|
20586 | return this;
|
20587 | },
|
20588 |
|
20589 |
|
20590 |
|
20591 | hide: function(){
|
20592 | this._invisible = true;
|
20593 | if (this.parentNode) this.parentNode.invalidate();
|
20594 | return this;
|
20595 | },
|
20596 |
|
20597 | show: function(){
|
20598 | this._invisible = false;
|
20599 | if (this.parentNode) this.parentNode.invalidate();
|
20600 | return this;
|
20601 | },
|
20602 |
|
20603 |
|
20604 |
|
20605 | indicate: function(cursor, tooltip){
|
20606 | this._cursor = cursor;
|
20607 | this._tooltip = tooltip;
|
20608 | return this.invalidate();
|
20609 | },
|
20610 |
|
20611 | hitTest: function(x, y){
|
20612 | if (this._invisible) return null;
|
20613 | var point = this.inversePoint(x, y);
|
20614 | if (!point) return null;
|
20615 | return this.localHitTest(point.x, point.y);
|
20616 | },
|
20617 |
|
20618 |
|
20619 |
|
20620 | renderTo: function(context, xx, yx, xy, yy, x, y){
|
20621 | var opacity = this._opacity;
|
20622 | if (opacity == null || opacity >= 1){
|
20623 | return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
20624 | }
|
20625 |
|
20626 |
|
20627 |
|
20628 | var layer = this._layer, canvas, isDirty = true,
|
20629 | w = context.canvas.width, h = context.canvas.height;
|
20630 | if (layer){
|
20631 | layer.setTransform(1, 0, 0, 1, 0, 0);
|
20632 | canvas = layer.canvas;
|
20633 | if (canvas.width < w || canvas.height < h){
|
20634 | canvas.width = w;
|
20635 | canvas.height = h;
|
20636 | } else {
|
20637 | var c = this._layerCache;
|
20638 | if (c && c.xx === xx && c.yx === yx && c.xy === xy
|
20639 | && c.yy === yy && c.x === x && c.y === y){
|
20640 | isDirty = false;
|
20641 | } else {
|
20642 | layer.clearRect(0, 0, w, h);
|
20643 | }
|
20644 | }
|
20645 | } else {
|
20646 | canvas = document.createElement('canvas');
|
20647 | canvas.width = w;
|
20648 | canvas.height = h;
|
20649 | this._layer = layer = canvas.getContext('2d');
|
20650 | }
|
20651 |
|
20652 | if (isDirty){
|
20653 | this.renderLayerTo(layer, xx, yx, xy, yy, x, y);
|
20654 | this._layerCache = {
|
20655 | xx: xx,
|
20656 | yx: yx,
|
20657 | xy: xy,
|
20658 | yy: yy,
|
20659 | x: x,
|
20660 | y: y
|
20661 | };
|
20662 | }
|
20663 |
|
20664 | context.globalAlpha = opacity;
|
20665 | context.setTransform(1, 0, 0, 1, 0, 0);
|
20666 | context.drawImage(
|
20667 | canvas,
|
20668 | 0, 0, w, h,
|
20669 | 0, 0, w, h
|
20670 | );
|
20671 | context.globalAlpha = 1;
|
20672 | }
|
20673 |
|
20674 | });
|
20675 |
|
20676 | var node = CanvasNode;
|
20677 |
|
20678 | var genericCanvas = typeof document !== 'undefined' && document.createElement('canvas'),
|
20679 | genericContext = genericCanvas && genericCanvas.getContext && genericCanvas.getContext('2d');
|
20680 |
|
20681 | function recolorImage(img, color1, color2){
|
20682 |
|
20683 | color1 = color.detach(color1);
|
20684 | color2 = color.detach(color2);
|
20685 | var canvas = document.createElement('canvas'),
|
20686 | context = canvas.getContext('2d');
|
20687 | canvas.width = img.width;
|
20688 | canvas.height = img.height;
|
20689 | context.fillStyle = color2[0];
|
20690 | context.fillRect(0, 0, img.width, img.height);
|
20691 | context.globalCompositeOperation = 'lighter';
|
20692 | context.drawImage(img, 0, 0);
|
20693 | return canvas;
|
20694 | }
|
20695 |
|
20696 | var Base = _class(node, {
|
20697 |
|
20698 | initialize: function(){
|
20699 | this._fill = null;
|
20700 | this._pendingFill = null;
|
20701 | this._fillTransform = null;
|
20702 | this._stroke = null;
|
20703 | this._strokeCap = null;
|
20704 | this._strokeDash = null;
|
20705 | this._strokeJoin = null;
|
20706 | this._strokeWidth = null;
|
20707 | },
|
20708 |
|
20709 |
|
20710 |
|
20711 | _addColors: function(gradient, stops){
|
20712 |
|
20713 |
|
20714 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++)
|
20715 | gradient.addColorStop(i / l, new color(stops[i]).toString());
|
20716 | else for (var offset in stops)
|
20717 | gradient.addColorStop(offset, new color(stops[offset]).toString());
|
20718 | return gradient;
|
20719 | },
|
20720 |
|
20721 |
|
20722 | fill: function(color$1){
|
20723 | if (arguments.length > 1) return this.fillLinear(arguments);
|
20724 | if (this._pendingFill) this._pendingFill();
|
20725 | this._fill = color$1 ? new color(color$1).toString() : null;
|
20726 | return this.invalidate();
|
20727 | },
|
20728 |
|
20729 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
20730 | if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
|
20731 | if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
|
20732 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
|
20733 | if (radiusX == null) radiusX = (this.width || 0) * 0.5;
|
20734 | if (centerX == null) centerX = focusX;
|
20735 | if (centerY == null) centerY = focusY;
|
20736 |
|
20737 | centerX += centerX - focusX;
|
20738 | centerY += centerY - focusY;
|
20739 |
|
20740 | if (radiusX === 0 || radiusX === '0') return this.fillLinear(stops);
|
20741 | var ys = radiusY / radiusX;
|
20742 |
|
20743 | if (this._pendingFill) this._pendingFill();
|
20744 |
|
20745 | var gradient = genericContext.createRadialGradient(focusX, focusY / ys, 0, centerX, centerY / ys, radiusX * 2);
|
20746 |
|
20747 |
|
20748 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++){
|
20749 | gradient.addColorStop(i / l / 2, new color(stops[i]).toString());
|
20750 | gradient.addColorStop(1 - i / l / 2, new color(stops[i]).toString());
|
20751 | } else for (var offset in stops){
|
20752 | gradient.addColorStop(offset / 2, new color(stops[offset]).toString());
|
20753 | gradient.addColorStop(1- offset / 2, new color(stops[offset]).toString());
|
20754 | }
|
20755 |
|
20756 | this._fill = gradient;
|
20757 | this._fillTransform = new transform(1, 0, 0, ys);
|
20758 | return this.invalidate();
|
20759 | },
|
20760 |
|
20761 | fillLinear: function(stops, x1, y1, x2, y2){
|
20762 | if (arguments.length < 5){
|
20763 | var angle = ((x1 == null) ? 270 : x1) * Math.PI / 180;
|
20764 |
|
20765 | var x = Math.cos(angle), y = -Math.sin(angle),
|
20766 | l = (Math.abs(x) + Math.abs(y)) / 2,
|
20767 | w = this.width || 1, h = this.height || 1;
|
20768 |
|
20769 | x *= l; y *= l;
|
20770 |
|
20771 | x1 = 0.5 - x;
|
20772 | x2 = 0.5 + x;
|
20773 | y1 = 0.5 - y;
|
20774 | y2 = 0.5 + y;
|
20775 | this._fillTransform = new transform(w, 0, 0, h);
|
20776 | } else {
|
20777 | this._fillTransform = null;
|
20778 | }
|
20779 | if (this._pendingFill) this._pendingFill();
|
20780 | var gradient = genericContext.createLinearGradient(x1, y1, x2, y2);
|
20781 | this._addColors(gradient, stops);
|
20782 | this._fill = gradient;
|
20783 | return this.invalidate();
|
20784 | },
|
20785 |
|
20786 | fillImage: function(url, width, height, left, top, color1, color2){
|
20787 | if (this._pendingFill) this._pendingFill();
|
20788 | var img = url;
|
20789 | if (!(img instanceof Image)){
|
20790 | img = new Image();
|
20791 | img.src = url;
|
20792 | }
|
20793 | if (img.width && img.height){
|
20794 | return this._fillImage(img, width, height, left || 0, top || 0, color1, color2);
|
20795 | }
|
20796 |
|
20797 |
|
20798 | this._fill = null;
|
20799 | var self = this,
|
20800 | callback = function(){
|
20801 | cancel();
|
20802 | self._fillImage(img, width, height, left || 0, top || 0, color1, color2);
|
20803 | },
|
20804 | cancel = function(){
|
20805 | img.removeEventListener('load', callback, false);
|
20806 | self._pendingFill = null;
|
20807 | };
|
20808 | this._pendingFill = cancel;
|
20809 | img.addEventListener('load', callback, false);
|
20810 | return this;
|
20811 | },
|
20812 |
|
20813 | _fillImage: function(img, width, height, left, top, color1, color2){
|
20814 | var w = width ? width / img.width : 1,
|
20815 | h = height ? height / img.height : 1;
|
20816 | if (color1 != null) img = recolorImage(img, color1, color2);
|
20817 | this._fill = genericContext.createPattern(img, 'repeat');
|
20818 | this._fillTransform = new transform(w, 0, 0, h, left || 0, top || 0);
|
20819 | return this.invalidate();
|
20820 | },
|
20821 |
|
20822 | stroke: function(color$1, width, cap, join, dash){
|
20823 | this._stroke = color$1 ? new color(color$1).toString() : null;
|
20824 | this._strokeWidth = (width != null) ? width : 1;
|
20825 | this._strokeCap = (cap != null) ? cap : 'round';
|
20826 | this._strokeJoin = (join != null) ? join : 'round';
|
20827 | this._strokeDash = dash;
|
20828 | return this.invalidate();
|
20829 | },
|
20830 |
|
20831 |
|
20832 |
|
20833 | element_renderTo: node.prototype.renderTo,
|
20834 |
|
20835 | renderTo: function(context, xx, yx, xy, yy, x, y){
|
20836 | var opacity = this._opacity;
|
20837 | if (opacity == null || opacity >= 1){
|
20838 | return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
20839 | }
|
20840 | if (this._fill && this._stroke){
|
20841 | return this.element_renderTo(context, xx, yx, xy, yy, x, y);
|
20842 | }
|
20843 | context.globalAlpha = opacity;
|
20844 | var r = this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
20845 | context.globalAlpha = 1;
|
20846 | return r;
|
20847 | },
|
20848 |
|
20849 | renderLayerTo: function(context, xx, yx, xy, yy, x, y){
|
20850 | context.setTransform(xx, yx, xy, yy, x, y);
|
20851 | this.renderShapeTo(context);
|
20852 | }
|
20853 |
|
20854 | });
|
20855 |
|
20856 | Base._genericContext = genericContext;
|
20857 |
|
20858 | var base = Base;
|
20859 |
|
20860 | var shape = _class(base, {
|
20861 |
|
20862 | base_initialize: base.prototype.initialize,
|
20863 |
|
20864 | initialize: function(path, width, height){
|
20865 | this.base_initialize();
|
20866 | this.width = width;
|
20867 | this.height = height;
|
20868 | if (path != null) this.draw(path);
|
20869 | },
|
20870 |
|
20871 | draw: function(path, width, height){
|
20872 | if (!(path instanceof path$1)) path = new path$1(path);
|
20873 | this.path = path;
|
20874 | this._commands = path.toCommands();
|
20875 | if (width != null) this.width = width;
|
20876 | if (height != null) this.height = height;
|
20877 | return this.invalidate();
|
20878 | },
|
20879 |
|
20880 | localHitTest: function(x, y){
|
20881 | if (!this._fill) return null;
|
20882 | if (this.width == null || this.height == null){
|
20883 | var context = base._genericContext, commands = this._commands;
|
20884 | if (!commands) return null;
|
20885 | context.beginPath();
|
20886 | for (var i = 0, l = commands.length; i < l; i++)
|
20887 | commands[i](context);
|
20888 | return context.isPointInPath(x, y) ? this : null;
|
20889 | }
|
20890 | if (x > 0 && y > 0 && x < this.width && y < this.height){
|
20891 | return this;
|
20892 | }
|
20893 | return null;
|
20894 | },
|
20895 |
|
20896 | renderShapeTo: function(context){
|
20897 | if (this._invisible || !this._commands || (!this._fill && !this._stroke)) {
|
20898 | return null;
|
20899 | }
|
20900 | context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
|
20901 | var commands = this._commands,
|
20902 | fill = this._fill,
|
20903 | stroke = this._stroke,
|
20904 | dash = this._strokeDash;
|
20905 |
|
20906 | context.beginPath();
|
20907 |
|
20908 | if (dash) {
|
20909 | if (context.setLineDash) {
|
20910 | context.setLineDash(dash);
|
20911 | } else {
|
20912 |
|
20913 | context.mozDash = dash;
|
20914 | }
|
20915 |
|
20916 | } else {
|
20917 | if (context.setLineDash) {
|
20918 | context.setLineDash([]);
|
20919 | } else {
|
20920 | context.mozDash = null;
|
20921 | }
|
20922 | }
|
20923 |
|
20924 | for (var i = 0, l = commands.length; i < l; i++)
|
20925 | commands[i](context);
|
20926 |
|
20927 | if (fill){
|
20928 | var m = this._fillTransform;
|
20929 | if (m){
|
20930 | context.save();
|
20931 | context.transform(m.xx, m.yx, m.xy, m.yy, m.x, m.y);
|
20932 | context.fillStyle = fill;
|
20933 | context.fill();
|
20934 | context.restore();
|
20935 | } else {
|
20936 | context.fillStyle = fill;
|
20937 | context.fill();
|
20938 | }
|
20939 | }
|
20940 | if (stroke){
|
20941 | context.strokeStyle = stroke;
|
20942 | context.lineWidth = this._strokeWidth;
|
20943 | context.lineCap = this._strokeCap;
|
20944 | context.lineJoin = this._strokeJoin;
|
20945 | context.stroke();
|
20946 | }
|
20947 | }
|
20948 |
|
20949 | });
|
20950 |
|
20951 | var group = _class(node, container, {
|
20952 |
|
20953 | initialize: function(width, height){
|
20954 | this.width = width;
|
20955 | this.height = height;
|
20956 | },
|
20957 |
|
20958 | localHitTest: function(x, y){
|
20959 | var node = this.lastChild;
|
20960 | while (node){
|
20961 | var hit = node.hitTest(x, y);
|
20962 | if (hit) return hit;
|
20963 | node = node.previousSibling;
|
20964 | }
|
20965 | return null;
|
20966 | },
|
20967 |
|
20968 | renderLayerTo: function(context, xx, yx, xy, yy, x, y){
|
20969 | if (this._invisible) return;
|
20970 |
|
20971 | x = xx * this.x + xy * this.y + x;
|
20972 | y = yx * this.x + yy * this.y + y;
|
20973 |
|
20974 | var t = xx;
|
20975 | xx = t * this.xx + xy * this.yx;
|
20976 | xy = t * this.xy + xy * this.yy;
|
20977 | t = yx;
|
20978 | yx = t * this.xx + yy * this.yx;
|
20979 | yy = t * this.xy + yy * this.yy;
|
20980 |
|
20981 | var node = this.firstChild;
|
20982 | while (node){
|
20983 | node.renderTo(context, xx, yx, xy, yy, x, y);
|
20984 | node = node.nextSibling;
|
20985 | }
|
20986 | }
|
20987 |
|
20988 | });
|
20989 |
|
20990 | var clippingrectangle = _class(node, container, {
|
20991 |
|
20992 | initialize: function(width, height){
|
20993 | this.width = width;
|
20994 | this.height = height;
|
20995 | },
|
20996 |
|
20997 | localHitTest: function(x, y) {
|
20998 | var node = this.lastChild;
|
20999 | while (node){
|
21000 | var hit = node.hitTest(x, y);
|
21001 | if (hit) return hit;
|
21002 | node = node.previousSibling;
|
21003 | }
|
21004 | return null;
|
21005 | },
|
21006 |
|
21007 | renderLayerTo: function(context, xx, yx, xy, yy, x, y) {
|
21008 | context.setTransform(xx, yx, xy, yy, x, y);
|
21009 | context.save();
|
21010 |
|
21011 | context.beginPath();
|
21012 | context.rect(this.x, this.y, this.width, this.height);
|
21013 | context.clip();
|
21014 |
|
21015 | var node = this.firstChild;
|
21016 | while(node) {
|
21017 | node.renderTo(context, xx, yx, xy, yy, x, y);
|
21018 | node = node.nextSibling;
|
21019 | }
|
21020 | context.restore();
|
21021 | }
|
21022 | });
|
21023 |
|
21024 | var fontAnchors = { middle: 'center' };
|
21025 |
|
21026 | var text = _class(base, {
|
21027 |
|
21028 | base_initialize: base.prototype.initialize,
|
21029 |
|
21030 | initialize: function(text, font, alignment, path){
|
21031 | this.base_initialize();
|
21032 | this.draw.apply(this, arguments);
|
21033 | },
|
21034 |
|
21035 | draw: function(text, font, alignment, path){
|
21036 | var em;
|
21037 | if (typeof font == 'string'){
|
21038 | em = Number(/(\d+)/.exec(font)[0]);
|
21039 | } else if (font){
|
21040 | em = parseFloat(font.fontSize || font['font-size'] || '12');
|
21041 | font = (font.fontStyle || font['font-style'] || '') + ' ' +
|
21042 | (font.fontVariant || font['font-variant'] || '') + ' ' +
|
21043 | (font.fontWeight || font['font-weight'] || '') + ' ' +
|
21044 | em + 'px ' +
|
21045 | (font.fontFamily || font['font-family'] || 'Arial');
|
21046 | } else {
|
21047 | font = this._font;
|
21048 | }
|
21049 |
|
21050 | var lines = text && text.split(/\r?\n/);
|
21051 | this._font = font;
|
21052 | this._fontSize = em;
|
21053 | this._text = lines;
|
21054 | this._alignment = fontAnchors[alignment] || alignment || 'left';
|
21055 |
|
21056 | var context = base._genericContext;
|
21057 |
|
21058 | context.font = this._font;
|
21059 | context.textAlign = this._alignment;
|
21060 | context.textBaseline = 'middle';
|
21061 |
|
21062 | lines = this._text;
|
21063 | var l = lines.length, width = 0;
|
21064 | for (var i = 0; i < l; i++){
|
21065 | var w = context.measureText(lines[i]).width;
|
21066 | if (w > width) width = w;
|
21067 | }
|
21068 | this.width = width;
|
21069 | this.height = l ? l * 1.1 * em : 0;
|
21070 | return this.invalidate();
|
21071 | },
|
21072 |
|
21073 |
|
21074 |
|
21075 | localHitTest: function(x, y){
|
21076 | if (!this._fill) return null;
|
21077 | if (x > 0 && y > 0 && x < this.width && y < this.height){
|
21078 | return this;
|
21079 | }
|
21080 | return null;
|
21081 | },
|
21082 |
|
21083 |
|
21084 |
|
21085 | renderShapeTo: function(context){
|
21086 | if (this._invisible || !this._text || (!this._fill && !this._stroke)) {
|
21087 | return null;
|
21088 | }
|
21089 | context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
|
21090 | var fill = this._fill,
|
21091 | stroke = this._stroke,
|
21092 | text = this._text,
|
21093 | dash = this._strokeDash;
|
21094 |
|
21095 | context.font = this._font;
|
21096 | context.textAlign = this._alignment;
|
21097 | context.textBaseline = 'middle';
|
21098 |
|
21099 | var em = this._fontSize,
|
21100 | y = em / 2,
|
21101 | lineHeight = 1.1 * em,
|
21102 | lines = text,
|
21103 | l = lines.length;
|
21104 |
|
21105 | if (fill){
|
21106 | context.fillStyle = fill;
|
21107 | for (var i = 0; i < l; i++)
|
21108 | context.fillText(lines[i], 0, y + i * lineHeight);
|
21109 | }
|
21110 | if (stroke){
|
21111 | if (dash) {
|
21112 | if (context.setLineDash) {
|
21113 | context.setLineDash(dash);
|
21114 | } else {
|
21115 |
|
21116 | context.mozDash = dash;
|
21117 | }
|
21118 |
|
21119 | } else {
|
21120 | if (context.setLineDash) {
|
21121 | context.setLineDash([]);
|
21122 | } else {
|
21123 | context.mozDash = null;
|
21124 | }
|
21125 | }
|
21126 |
|
21127 | context.strokeStyle = stroke;
|
21128 | context.lineWidth = this._strokeWidth;
|
21129 | context.lineCap = this._strokeCap;
|
21130 | context.lineJoin = this._strokeJoin;
|
21131 | for (i = 0; i < l; i++)
|
21132 | context.strokeText(lines[i], 0, y + i * lineHeight);
|
21133 | }
|
21134 | }
|
21135 |
|
21136 | });
|
21137 |
|
21138 | var VMLCSS = 'behavior:url(#default#VML);display:inline-block;position:absolute;left:0px;top:0px;';
|
21139 |
|
21140 | var styleSheet, styledTags = {}, styleTag = function(tag){
|
21141 | if (styleSheet) styledTags[tag] = styleSheet.addRule('av\\:' + tag, VMLCSS);
|
21142 | };
|
21143 |
|
21144 | var init = function(document){
|
21145 |
|
21146 | var namespaces;
|
21147 | try {
|
21148 | namespaces = document.namespaces;
|
21149 | } catch (e) {
|
21150 | }
|
21151 | if (!namespaces) return false;
|
21152 |
|
21153 | namespaces.add('av', 'urn:schemas-microsoft-com:vml');
|
21154 | namespaces.add('ao', 'urn:schemas-microsoft-com:office:office');
|
21155 |
|
21156 | styleSheet = document.createStyleSheet();
|
21157 | styleSheet.addRule('vml', 'display:inline-block;position:relative;overflow:hidden;');
|
21158 | |
21159 |
|
21160 |
|
21161 |
|
21162 |
|
21163 |
|
21164 |
|
21165 | styleTag('vml');
|
21166 |
|
21167 | return true;
|
21168 |
|
21169 | };
|
21170 |
|
21171 | var createElement = function(tag){
|
21172 | if (!(tag in styledTags)) styleTag(tag);
|
21173 | return document.createElement('av:' + tag);
|
21174 | };
|
21175 |
|
21176 | var dom = {
|
21177 | init: init,
|
21178 | createElement: createElement
|
21179 | };
|
21180 |
|
21181 | var precision = 100;
|
21182 |
|
21183 | var VMLSurface = _class(native_1, container, {
|
21184 |
|
21185 | initialize: function VMLSurface(width, height, existingElement){
|
21186 | this.element = existingElement || document.createElement('vml');
|
21187 | this.containerElement = dom.createElement('group');
|
21188 | this.element.appendChild(this.containerElement);
|
21189 | if (width != null && height != null) this.resize(width, height);
|
21190 | },
|
21191 |
|
21192 | resize: function(width, height){
|
21193 | this.width = width;
|
21194 | this.height = height;
|
21195 |
|
21196 | var style = this.element.style;
|
21197 | style.pixelWidth = width;
|
21198 | style.pixelHeight = height;
|
21199 |
|
21200 | style = this.containerElement.style;
|
21201 | style.width = width;
|
21202 | style.height = height;
|
21203 |
|
21204 | var halfPixel = (0.5 * precision);
|
21205 |
|
21206 | this.containerElement.coordorigin = halfPixel + ',' + halfPixel;
|
21207 | this.containerElement.coordsize = (width * precision) + ',' + (height * precision);
|
21208 |
|
21209 | return this;
|
21210 | }
|
21211 |
|
21212 | });
|
21213 |
|
21214 | VMLSurface.tagName = 'av:vml';
|
21215 |
|
21216 | var surface$1 = VMLSurface;
|
21217 |
|
21218 | var precision$1 = 100;
|
21219 |
|
21220 | var round = Math.round;
|
21221 |
|
21222 | var VMLPath = _class(path, {
|
21223 |
|
21224 | initialize: function(path){
|
21225 | this.reset();
|
21226 | if (path instanceof VMLPath){
|
21227 | this.path = [Array.prototype.join.call(path.path, ' ')];
|
21228 | } else if (path){
|
21229 | if (path.applyToPath)
|
21230 | path.applyToPath(this);
|
21231 | else
|
21232 | this.push(path);
|
21233 | }
|
21234 | },
|
21235 |
|
21236 | onReset: function(){
|
21237 | this.path = [];
|
21238 | },
|
21239 |
|
21240 | onMove: function(sx, sy, x, y){
|
21241 | this.path.push('m', round(x * precision$1), round(y * precision$1));
|
21242 | },
|
21243 |
|
21244 | onLine: function(sx, sy, x, y){
|
21245 | this.path.push('l', round(x * precision$1), round(y * precision$1));
|
21246 | },
|
21247 |
|
21248 | onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
|
21249 | this.path.push('c',
|
21250 | round(p1x * precision$1), round(p1y * precision$1),
|
21251 | round(p2x * precision$1), round(p2y * precision$1),
|
21252 | round(x * precision$1), round(y * precision$1)
|
21253 | );
|
21254 | },
|
21255 |
|
21256 | _arcToBezier: path.prototype.onArc,
|
21257 |
|
21258 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
21259 | if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
|
21260 | cx *= precision$1;
|
21261 | cy *= precision$1;
|
21262 | rx *= precision$1;
|
21263 | this.path.push(ccw ? 'at' : 'wa',
|
21264 | round(cx - rx), round(cy - rx),
|
21265 | round(cx + rx), round(cy + rx),
|
21266 | round(sx * precision$1), round(sy * precision$1),
|
21267 | round(ex * precision$1), round(ey * precision$1)
|
21268 | );
|
21269 | },
|
21270 |
|
21271 | onClose: function(){
|
21272 | this.path.push('x');
|
21273 | },
|
21274 |
|
21275 | toVML: function(){
|
21276 | return this.path.join(' ');
|
21277 | }
|
21278 |
|
21279 | });
|
21280 |
|
21281 | VMLPath.prototype.toString = VMLPath.prototype.toVML;
|
21282 |
|
21283 | var path$2 = VMLPath;
|
21284 |
|
21285 | var shadow = _class(dummy, native_1, {
|
21286 |
|
21287 | dummy_inject: dummy.prototype.inject,
|
21288 | dummy_injectBefore: dummy.prototype.injectBefore,
|
21289 | dummy_eject: dummy.prototype.eject,
|
21290 | native_inject: native_1.prototype.inject,
|
21291 | native_injectBefore: native_1.prototype.injectBefore,
|
21292 | native_eject: native_1.prototype.eject,
|
21293 |
|
21294 | inject: function(container){
|
21295 | this.dummy_inject(container);
|
21296 | this.native_inject(container);
|
21297 | return this;
|
21298 | },
|
21299 |
|
21300 | injectBefore: function(sibling){
|
21301 | this.dummy_injectBefore(sibling);
|
21302 | this.native_injectBefore(sibling);
|
21303 | return this;
|
21304 | },
|
21305 |
|
21306 | eject: function(){
|
21307 | this.dummy_eject();
|
21308 | this.native_eject();
|
21309 | return this;
|
21310 | }
|
21311 |
|
21312 | });
|
21313 |
|
21314 | var node$1 = _class(shadow, transform, {
|
21315 |
|
21316 | initialize: function(tag){
|
21317 |
|
21318 | var element = this.element = dom.createElement(tag);
|
21319 |
|
21320 | },
|
21321 |
|
21322 | _place: function(){
|
21323 | if (this.parentNode){
|
21324 | this._transform();
|
21325 | }
|
21326 | },
|
21327 |
|
21328 |
|
21329 |
|
21330 | hide: function(){
|
21331 | this.element.style.display = 'none';
|
21332 | return this;
|
21333 | },
|
21334 |
|
21335 | show: function(){
|
21336 | this.element.style.display = '';
|
21337 | return this;
|
21338 | },
|
21339 |
|
21340 |
|
21341 |
|
21342 | indicate: function(cursor, tooltip){
|
21343 | if (cursor) this.element.style.cursor = cursor;
|
21344 | if (tooltip) this.element.title = tooltip;
|
21345 | return this;
|
21346 | }
|
21347 |
|
21348 | });
|
21349 |
|
21350 | var precision$2 = 100;
|
21351 |
|
21352 | var defaultBox = { left: 0, top: 0, width: 500, height: 500 };
|
21353 |
|
21354 | var base$1 = _class(node$1, {
|
21355 |
|
21356 | element_initialize: node$1.prototype.initialize,
|
21357 |
|
21358 | initialize: function(tag){
|
21359 | this.element_initialize(tag);
|
21360 | var element = this.element;
|
21361 |
|
21362 | var skew = this.skewElement = dom.createElement('skew');
|
21363 | skew.on = true;
|
21364 | element.appendChild(skew);
|
21365 |
|
21366 | var fill = this.fillElement = dom.createElement('fill');
|
21367 | fill.on = false;
|
21368 | element.appendChild(fill);
|
21369 |
|
21370 | var stroke = this.strokeElement = dom.createElement('stroke');
|
21371 | stroke.on = false;
|
21372 | element.appendChild(stroke);
|
21373 | },
|
21374 |
|
21375 |
|
21376 |
|
21377 | _transform: function(){
|
21378 | var container = this.parentNode;
|
21379 |
|
21380 |
|
21381 | var m = container ? new transform(container._activeTransform).transform(this) : this;
|
21382 |
|
21383 |
|
21384 |
|
21385 | var box = this._boxCoords || this._size || defaultBox;
|
21386 |
|
21387 | var originX = box.left || 0,
|
21388 | originY = box.top || 0,
|
21389 | width = box.width || 1,
|
21390 | height = box.height || 1;
|
21391 |
|
21392 |
|
21393 | var flip = m.yx / m.xx > m.yy / m.xy;
|
21394 | if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = !flip;
|
21395 | flip = flip ? -1 : 1;
|
21396 |
|
21397 | m = new transform().scale(flip, 1).transform(m);
|
21398 |
|
21399 |
|
21400 | var rotation = Math.atan2(-m.xy, m.yy) * 180 / Math.PI;
|
21401 |
|
21402 |
|
21403 | var rad = rotation * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
|
21404 |
|
21405 | var transform$1 = new transform(
|
21406 | (m.xx * cos - m.xy * sin),
|
21407 | (m.yx * cos - m.yy * sin) * flip,
|
21408 | (m.xy * cos + m.xx * sin) * flip,
|
21409 | (m.yy * cos + m.yx * sin)
|
21410 | );
|
21411 |
|
21412 | var rotationTransform = new transform().rotate(rotation, 0, 0);
|
21413 |
|
21414 | var shapeToBox = new transform().rotate(-rotation, 0, 0).transform(m).moveTo(0,0);
|
21415 |
|
21416 |
|
21417 | width *= Math.abs(shapeToBox.xx);
|
21418 | height *= Math.abs(shapeToBox.yy);
|
21419 |
|
21420 |
|
21421 | var left = m.x, top = m.y;
|
21422 |
|
21423 |
|
21424 | var vx = -width / 2, vy = -height / 2;
|
21425 | var point = rotationTransform.point(vx, vy);
|
21426 | left -= point.x - vx;
|
21427 | top -= point.y - vy;
|
21428 |
|
21429 |
|
21430 | var rsm = new transform(m).moveTo(0,0);
|
21431 | point = rsm.point(originX, originY);
|
21432 | left += point.x;
|
21433 | top += point.y;
|
21434 |
|
21435 | if (flip < 0) left = -left - width;
|
21436 |
|
21437 |
|
21438 | var point0 = rsm.point(-originX, -originY);
|
21439 | var point1 = rotationTransform.point(width, height);
|
21440 | var point2 = rotationTransform.point(width, 0);
|
21441 | var point3 = rotationTransform.point(0, height);
|
21442 |
|
21443 | var minX = Math.min(0, point1.x, point2.x, point3.x),
|
21444 | maxX = Math.max(0, point1.x, point2.x, point3.x),
|
21445 | minY = Math.min(0, point1.y, point2.y, point3.y),
|
21446 | maxY = Math.max(0, point1.y, point2.y, point3.y);
|
21447 |
|
21448 | var transformOriginX = (point0.x - point1.x / 2) / (maxX - minX) * flip,
|
21449 | transformOriginY = (point0.y - point1.y / 2) / (maxY - minY);
|
21450 |
|
21451 |
|
21452 | point = shapeToBox.point(originX, originY);
|
21453 | originX = point.x;
|
21454 | originY = point.y;
|
21455 |
|
21456 |
|
21457 | var strokeWidth = this._strokeWidth;
|
21458 | if (strokeWidth){
|
21459 |
|
21460 |
|
21461 | var vx = m.xx + m.xy, vy = m.yy + m.yx;
|
21462 | strokeWidth *= Math.sqrt(vx * vx + vy * vy) / Math.sqrt(2);
|
21463 | }
|
21464 |
|
21465 |
|
21466 | originX *= precision$2;
|
21467 | originY *= precision$2;
|
21468 | left *= precision$2;
|
21469 | top *= precision$2;
|
21470 | width *= precision$2;
|
21471 | height *= precision$2;
|
21472 |
|
21473 |
|
21474 | var element = this.element;
|
21475 | element.coordorigin = originX + ',' + originY;
|
21476 | element.coordsize = width + ',' + height;
|
21477 | element.style.left = left + 'px';
|
21478 | element.style.top = top + 'px';
|
21479 | element.style.width = width;
|
21480 | element.style.height = height;
|
21481 | element.style.rotation = rotation.toFixed(8);
|
21482 | element.style.flip = flip < 0 ? 'x' : '';
|
21483 |
|
21484 |
|
21485 | var skew = this.skewElement;
|
21486 | skew.matrix = [transform$1.xx.toFixed(4), transform$1.xy.toFixed(4), transform$1.yx.toFixed(4), transform$1.yy.toFixed(4), 0, 0];
|
21487 | skew.origin = transformOriginX + ',' + transformOriginY;
|
21488 |
|
21489 |
|
21490 | this.strokeElement.weight = strokeWidth + 'px';
|
21491 | },
|
21492 |
|
21493 |
|
21494 |
|
21495 | _createGradient: function(style, stops){
|
21496 | var fill = this.fillElement;
|
21497 |
|
21498 |
|
21499 | this.element.removeChild(fill);
|
21500 |
|
21501 | fill.type = style;
|
21502 | fill.method = 'none';
|
21503 | fill.rotate = true;
|
21504 |
|
21505 | var colors = [], color1, color2;
|
21506 |
|
21507 | var addColor = function(offset, color$1){
|
21508 | color$1 = color.detach(color$1);
|
21509 | if (color1 == null) color1 = color2 = color$1;
|
21510 | else color2 = color$1;
|
21511 | colors.push(offset + ' ' + color$1[0]);
|
21512 | };
|
21513 |
|
21514 |
|
21515 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++) addColor(i / l, stops[i]);
|
21516 | else for (var offset in stops) addColor(offset, stops[offset]);
|
21517 |
|
21518 | fill.color = color1[0];
|
21519 | fill.color2 = color2[0];
|
21520 |
|
21521 |
|
21522 | fill.colors = colors;
|
21523 |
|
21524 |
|
21525 | fill.opacity = color2[1];
|
21526 | fill['ao:opacity2'] = color1[1];
|
21527 |
|
21528 | fill.on = true;
|
21529 | this.element.appendChild(fill);
|
21530 | return fill;
|
21531 | },
|
21532 |
|
21533 | _setColor: function(type, color$1){
|
21534 | var element = type == 'fill' ? this.fillElement : this.strokeElement;
|
21535 | if (color$1 == null){
|
21536 | element.on = false;
|
21537 | } else {
|
21538 | color$1 = color.detach(color$1);
|
21539 | element.color = color$1[0];
|
21540 | element.opacity = color$1[1];
|
21541 | element.on = true;
|
21542 | }
|
21543 | },
|
21544 |
|
21545 | fill: function(color){
|
21546 | if (arguments.length > 1){
|
21547 | this.fillLinear(arguments);
|
21548 | } else {
|
21549 | this._boxCoords = defaultBox;
|
21550 | var fill = this.fillElement;
|
21551 | fill.type = 'solid';
|
21552 | fill.color2 = '';
|
21553 | fill['ao:opacity2'] = '';
|
21554 | if (fill.colors) fill.colors.value = '';
|
21555 | this._setColor('fill', color);
|
21556 | }
|
21557 | return this;
|
21558 | },
|
21559 |
|
21560 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
21561 | var fill = this._createGradient('gradientradial', stops);
|
21562 | if (focusX == null) focusX = this.left + this.width * 0.5;
|
21563 | if (focusY == null) focusY = this.top + this.height * 0.5;
|
21564 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5);
|
21565 | if (radiusX == null) radiusX = this.width * 0.5;
|
21566 | if (centerX == null) centerX = focusX;
|
21567 | if (centerY == null) centerY = focusY;
|
21568 |
|
21569 | centerX += centerX - focusX;
|
21570 | centerY += centerY - focusY;
|
21571 |
|
21572 | var box = this._boxCoords = {
|
21573 | left: centerX - radiusX * 2,
|
21574 | top: centerY - radiusY * 2,
|
21575 | width: radiusX * 4,
|
21576 | height: radiusY * 4
|
21577 | };
|
21578 | focusX -= box.left;
|
21579 | focusY -= box.top;
|
21580 | focusX /= box.width;
|
21581 | focusY /= box.height;
|
21582 |
|
21583 | fill.focussize = '0 0';
|
21584 | fill.focusposition = focusX + ',' + focusY;
|
21585 | fill.focus = '50%';
|
21586 |
|
21587 | this._transform();
|
21588 |
|
21589 | return this;
|
21590 | },
|
21591 |
|
21592 | fillLinear: function(stops, x1, y1, x2, y2){
|
21593 | var fill = this._createGradient('gradient', stops);
|
21594 | fill.focus = '100%';
|
21595 | if (arguments.length == 5){
|
21596 | var w = Math.abs(x2 - x1), h = Math.abs(y2 - y1);
|
21597 | this._boxCoords = {
|
21598 | left: Math.min(x1, x2),
|
21599 | top: Math.min(y1, y2),
|
21600 | width: w < 1 ? h : w,
|
21601 | height: h < 1 ? w : h
|
21602 | };
|
21603 | fill.angle = (360 + Math.atan2((x2 - x1) / h, (y2 - y1) / w) * 180 / Math.PI) % 360;
|
21604 | } else {
|
21605 | this._boxCoords = null;
|
21606 | fill.angle = (x1 == null) ? 0 : (90 + x1) % 360;
|
21607 | }
|
21608 | this._transform();
|
21609 | return this;
|
21610 | },
|
21611 |
|
21612 | fillImage: function(url, width, height, left, top, color1, color2){
|
21613 | var fill = this.fillElement;
|
21614 | if (color1 != null){
|
21615 | color1 = color.detach(color1);
|
21616 | if (color2 != null) color2 = color.detach(color2);
|
21617 | fill.type = 'pattern';
|
21618 | fill.color = color1[0];
|
21619 | fill.color2 = color2 == null ? color1[0] : color2[0];
|
21620 | fill.opacity = color2 == null ? 0 : color2[1];
|
21621 | fill['ao:opacity2'] = color1[1];
|
21622 | } else {
|
21623 | fill.type = 'tile';
|
21624 | fill.color = '';
|
21625 | fill.color2 = '';
|
21626 | fill.opacity = 1;
|
21627 | fill['ao:opacity2'] = 1;
|
21628 | }
|
21629 | if (fill.colors) fill.colors.value = '';
|
21630 | fill.rotate = true;
|
21631 | fill.src = url;
|
21632 |
|
21633 | fill.size = '1,1';
|
21634 | fill.position = '0,0';
|
21635 | fill.origin = '0,0';
|
21636 | fill.aspect = 'ignore';
|
21637 | fill.on = true;
|
21638 |
|
21639 | if (!left) left = 0;
|
21640 | if (!top) top = 0;
|
21641 | this._boxCoords = width ? { left: left + 0.5, top: top + 0.5, width: width, height: height } : null;
|
21642 | this._transform();
|
21643 | return this;
|
21644 | },
|
21645 |
|
21646 |
|
21647 |
|
21648 | stroke: function(color, width, cap, join){
|
21649 | var stroke = this.strokeElement;
|
21650 | this._strokeWidth = (width != null) ? width : 1;
|
21651 | stroke.weight = (width != null) ? width + 'px' : 1;
|
21652 | stroke.endcap = (cap != null) ? ((cap == 'butt') ? 'flat' : cap) : 'round';
|
21653 | stroke.joinstyle = (join != null) ? join : 'round';
|
21654 |
|
21655 | this._setColor('stroke', color);
|
21656 | return this;
|
21657 | }
|
21658 |
|
21659 | });
|
21660 |
|
21661 | var precision$3 = 100;
|
21662 |
|
21663 | var shape$1 = _class(base$1, {
|
21664 |
|
21665 | base_initialize: base$1.prototype.initialize,
|
21666 |
|
21667 | initialize: function(path, width, height){
|
21668 | this.base_initialize('shape');
|
21669 |
|
21670 | var p = this.pathElement = dom.createElement('path');
|
21671 | p.gradientshapeok = true;
|
21672 | this.element.appendChild(p);
|
21673 |
|
21674 | this.width = width;
|
21675 | this.height = height;
|
21676 |
|
21677 | if (path != null) this.draw(path);
|
21678 | },
|
21679 |
|
21680 |
|
21681 |
|
21682 | draw: function(path, width, height){
|
21683 |
|
21684 | if (!(path instanceof path$2)) path = new path$2(path);
|
21685 | this._vml = path.toVML();
|
21686 |
|
21687 |
|
21688 | if (width != null) this.width = width;
|
21689 | if (height != null) this.height = height;
|
21690 |
|
21691 | if (!this._boxCoords) this._transform();
|
21692 | this._redraw(this._prefix, this._suffix);
|
21693 |
|
21694 | return this;
|
21695 | },
|
21696 |
|
21697 |
|
21698 |
|
21699 | _redraw: function(prefix, suffix){
|
21700 | var vml = this._vml || '';
|
21701 |
|
21702 | this._prefix = prefix;
|
21703 | this._suffix = suffix;
|
21704 | if (prefix){
|
21705 | vml = [
|
21706 | prefix, vml, suffix,
|
21707 |
|
21708 | 'ns e', vml, 'nf'
|
21709 | ].join(' ');
|
21710 | }
|
21711 |
|
21712 | this.element.path = vml + 'e';
|
21713 | },
|
21714 |
|
21715 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
21716 | var fill = this._createGradient('gradientradial', stops);
|
21717 | if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
|
21718 | if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
|
21719 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
|
21720 | if (radiusX == null) radiusX = (this.width || 0) * 0.5;
|
21721 | if (centerX == null) centerX = focusX;
|
21722 | if (centerY == null) centerY = focusY;
|
21723 |
|
21724 | centerX += centerX - focusX;
|
21725 | centerY += centerY - focusY;
|
21726 |
|
21727 | var cx = Math.round(centerX * precision$3),
|
21728 | cy = Math.round(centerY * precision$3),
|
21729 |
|
21730 | rx = Math.round(radiusX * 2 * precision$3),
|
21731 | ry = Math.round(radiusY * 2 * precision$3),
|
21732 |
|
21733 | arc = ['wa', cx - rx, cy - ry, cx + rx, cy + ry].join(' ');
|
21734 |
|
21735 | this._redraw(
|
21736 |
|
21737 | ['m', cx, cy - ry, 'l', cx, cy - ry].join(' '),
|
21738 |
|
21739 | [
|
21740 | 'm', cx, cy - ry,
|
21741 | arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry,
|
21742 | arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry
|
21743 | ].join(' ')
|
21744 | );
|
21745 |
|
21746 | this._boxCoords = { left: focusX - 2, top: focusY - 2, width: 4, height: 4 };
|
21747 |
|
21748 | fill.focusposition = '0.5,0.5';
|
21749 | fill.focussize = '0 0';
|
21750 | fill.focus = '50%';
|
21751 |
|
21752 | this._transform();
|
21753 |
|
21754 | return this;
|
21755 | }
|
21756 |
|
21757 | });
|
21758 |
|
21759 | var group$1 = _class(node$1, container, {
|
21760 |
|
21761 | element_initialize: node$1.prototype.initialize,
|
21762 |
|
21763 | initialize: function(width, height){
|
21764 | this.element_initialize('group');
|
21765 | this.width = width;
|
21766 | this.height = height;
|
21767 | },
|
21768 |
|
21769 | _transform: function(){
|
21770 | var element = this.element;
|
21771 | element.coordorigin = '0,0';
|
21772 | element.coordsize = '1000,1000';
|
21773 | element.style.left = 0;
|
21774 | element.style.top = 0;
|
21775 | element.style.width = 1000;
|
21776 | element.style.height = 1000;
|
21777 | element.style.rotation = 0;
|
21778 |
|
21779 | var container = this.parentNode;
|
21780 | this._activeTransform = container ? new transform(container._activeTransform).transform(this) : this;
|
21781 | var node = this.firstChild;
|
21782 | while (node){
|
21783 | node._transform();
|
21784 | node = node.nextSibling;
|
21785 | }
|
21786 | }
|
21787 |
|
21788 | });
|
21789 |
|
21790 | var clippingrectangle$1 = _class(node$1, container, {
|
21791 |
|
21792 | element_initialize: node$1.prototype.initialize,
|
21793 |
|
21794 | initialize: function(width, height){
|
21795 | this.element_initialize('clippingrectangle');
|
21796 | this.width = width;
|
21797 | this.height = height;
|
21798 | },
|
21799 |
|
21800 | _transform: function(){
|
21801 | var element = this.element;
|
21802 | element.clip = true;
|
21803 | element.coordorigin = -this.x + ',' + (-1 * this.y);
|
21804 | element.coordsize = this.width + ',' + this.height;
|
21805 |
|
21806 |
|
21807 | element.style.clipLeft = this.x;
|
21808 | element.style.clipRight = this.width + this.x;
|
21809 | element.style.clipTop = this.y;
|
21810 | element.style.left = -this.x;
|
21811 | element.style.top = -this.y;
|
21812 | element.style.width = this.width + this.x;
|
21813 | element.style.height = this.height + this.y;
|
21814 | element.style.rotation = 0;
|
21815 |
|
21816 | var container = this.parentNode;
|
21817 | this._activeTransform = container ? new transform(container._activeTransform).transform(this) : this;
|
21818 | var node = this.firstChild;
|
21819 | while (node){
|
21820 | node._transform();
|
21821 | node = node.nextSibling;
|
21822 | }
|
21823 | }
|
21824 |
|
21825 | });
|
21826 |
|
21827 | var fontAnchors$1 = { start: 'left', middle: 'center', end: 'right' };
|
21828 |
|
21829 | var text$1 = _class(base$1, {
|
21830 |
|
21831 | base_initialize: base$1.prototype.initialize,
|
21832 |
|
21833 | initialize: function(text, font, alignment, path){
|
21834 | this.base_initialize('shape');
|
21835 |
|
21836 | var p = this.pathElement = dom.createElement('path');
|
21837 | p.textpathok = true;
|
21838 | this.element.appendChild(p);
|
21839 |
|
21840 | p = this.textPathElement = dom.createElement("textpath");
|
21841 | p.on = true;
|
21842 | p.style['v-text-align'] = 'left';
|
21843 | this.element.appendChild(p);
|
21844 |
|
21845 | this.draw.apply(this, arguments);
|
21846 | },
|
21847 |
|
21848 | draw: function(text, font, alignment, path){
|
21849 | var element = this.element,
|
21850 | textPath = this.textPathElement,
|
21851 | style = textPath.style;
|
21852 |
|
21853 | textPath.string = text;
|
21854 |
|
21855 | if (font){
|
21856 | if (typeof font == 'string'){
|
21857 | style.font = font;
|
21858 | } else {
|
21859 | for (var key in font){
|
21860 | var ckey = key.camelCase ? key.camelCase() : key;
|
21861 | if (ckey == 'fontFamily') style[ckey] = "'" + font[key] + "'";
|
21862 |
|
21863 |
|
21864 |
|
21865 |
|
21866 | else style[ckey] = font[key];
|
21867 | }
|
21868 | }
|
21869 | }
|
21870 |
|
21871 | if (alignment) style['v-text-align'] = fontAnchors$1[alignment] || alignment;
|
21872 |
|
21873 | if (path){
|
21874 | this.currentPath = path = new path$2(path);
|
21875 | this.element.path = path.toVML();
|
21876 | } else if (!this.currentPath){
|
21877 | var i = -1, offsetRows = '\n';
|
21878 | while ((i = text.indexOf('\n', i + 1)) > -1) offsetRows += '\n';
|
21879 | textPath.string = offsetRows + textPath.string;
|
21880 | this.element.path = 'm0,0l1,0';
|
21881 | }
|
21882 |
|
21883 |
|
21884 |
|
21885 |
|
21886 | element = element.cloneNode(true);
|
21887 | style = element.style;
|
21888 |
|
21889 |
|
21890 | element.coordorigin = '0,0';
|
21891 | element.coordsize = '10000,10000';
|
21892 | style.left = '0px';
|
21893 | style.top = '0px';
|
21894 | style.width = '10000px';
|
21895 | style.height = '10000px';
|
21896 | style.rotation = 0;
|
21897 | element.removeChild(element.firstChild);
|
21898 |
|
21899 |
|
21900 |
|
21901 | var canvas = new surface$1(1, 1),
|
21902 | group = new group$1(),
|
21903 | body = element.ownerDocument.body;
|
21904 |
|
21905 | canvas.inject(body);
|
21906 | group.element.appendChild(element);
|
21907 | group.inject(canvas);
|
21908 |
|
21909 | var ebb = element.getBoundingClientRect(),
|
21910 | cbb = canvas.toElement().getBoundingClientRect();
|
21911 |
|
21912 | canvas.eject();
|
21913 |
|
21914 | this.left = ebb.left - cbb.left;
|
21915 | this.top = ebb.top - cbb.top;
|
21916 | this.width = ebb.right - ebb.left;
|
21917 | this.height = ebb.bottom - ebb.top;
|
21918 | this.right = ebb.right - cbb.left;
|
21919 | this.bottom = ebb.bottom - cbb.top;
|
21920 |
|
21921 | this._transform();
|
21922 |
|
21923 |
|
21924 | return this;
|
21925 | }
|
21926 |
|
21927 | });
|
21928 |
|
21929 | var fastNoSideEffects = createCommonjsModule(function (module, exports) {
|
21930 | var hasCanvas = function(){
|
21931 |
|
21932 | var canvas = document.createElement('canvas');
|
21933 | return canvas && !!canvas.getContext;
|
21934 |
|
21935 | };
|
21936 |
|
21937 | if (hasCanvas()) {
|
21938 | exports.Surface = surface;
|
21939 | exports.Path = path$1;
|
21940 | exports.Shape = shape;
|
21941 | exports.Group = group;
|
21942 | exports.ClippingRectangle = clippingrectangle;
|
21943 | exports.Text = text;
|
21944 | } else {
|
21945 | exports.Surface = surface$1;
|
21946 | exports.Path = path$2;
|
21947 | exports.Shape = shape$1;
|
21948 | exports.Group = group$1;
|
21949 | exports.ClippingRectangle = clippingrectangle$1;
|
21950 | exports.Text = text$1;
|
21951 |
|
21952 | var DOM = dom;
|
21953 | if (typeof document !== 'undefined') DOM.init(document);
|
21954 | }
|
21955 | });
|
21956 | var fastNoSideEffects_1 = fastNoSideEffects.Surface;
|
21957 | var fastNoSideEffects_2 = fastNoSideEffects.Path;
|
21958 | var fastNoSideEffects_3 = fastNoSideEffects.Shape;
|
21959 | var fastNoSideEffects_4 = fastNoSideEffects.Group;
|
21960 | var fastNoSideEffects_5 = fastNoSideEffects.ClippingRectangle;
|
21961 | var fastNoSideEffects_6 = fastNoSideEffects.Text;
|
21962 |
|
21963 | current.setCurrent(
|
21964 | fastNoSideEffects);
|
21965 |
|
21966 |
|
21967 | var slice = Array.prototype.slice;
|
21968 |
|
21969 | var LinearGradient = function () {
|
21970 | function LinearGradient(stops, x1, y1, x2, y2) {
|
21971 | this._args = slice.call(arguments);
|
21972 | }
|
21973 |
|
21974 | var _proto = LinearGradient.prototype;
|
21975 |
|
21976 | _proto.applyFill = function applyFill(node) {
|
21977 | node.fillLinear.apply(node, this._args);
|
21978 | };
|
21979 |
|
21980 | return LinearGradient;
|
21981 | }();
|
21982 |
|
21983 | var RadialGradient = function () {
|
21984 | function RadialGradient(stops, fx, fy, rx, ry, cx, cy) {
|
21985 | this._args = slice.call(arguments);
|
21986 | }
|
21987 |
|
21988 | var _proto2 = RadialGradient.prototype;
|
21989 |
|
21990 | _proto2.applyFill = function applyFill(node) {
|
21991 | node.fillRadial.apply(node, this._args);
|
21992 | };
|
21993 |
|
21994 | return RadialGradient;
|
21995 | }();
|
21996 |
|
21997 | var Pattern = function () {
|
21998 | function Pattern(url, width, height, left, top) {
|
21999 | this._args = slice.call(arguments);
|
22000 | }
|
22001 |
|
22002 | var _proto3 = Pattern.prototype;
|
22003 |
|
22004 | _proto3.applyFill = function applyFill(node) {
|
22005 | node.fillImage.apply(node, this._args);
|
22006 | };
|
22007 |
|
22008 | return Pattern;
|
22009 | }();
|
22010 |
|
22011 |
|
22012 |
|
22013 | var Surface = function (_React$Component) {
|
22014 | _inheritsLoose(Surface, _React$Component);
|
22015 |
|
22016 | function Surface() {
|
22017 | return _React$Component.apply(this, arguments) || this;
|
22018 | }
|
22019 |
|
22020 | var _proto4 = Surface.prototype;
|
22021 |
|
22022 | _proto4.componentDidMount = function componentDidMount() {
|
22023 | var _this$props = this.props,
|
22024 | height = _this$props.height,
|
22025 | width = _this$props.width;
|
22026 | this._surface = current.Surface(+width, +height, this._tagRef);
|
22027 | this._mountNode = createContainer(this._surface, LegacyRoot, null, false, false, '');
|
22028 | updateContainer(this.props.children, this._mountNode, this);
|
22029 | };
|
22030 |
|
22031 | _proto4.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
22032 | var props = this.props;
|
22033 |
|
22034 | if (props.height !== prevProps.height || props.width !== prevProps.width) {
|
22035 | this._surface.resize(+props.width, +props.height);
|
22036 | }
|
22037 |
|
22038 | updateContainer(this.props.children, this._mountNode, this);
|
22039 |
|
22040 | if (this._surface.render) {
|
22041 | this._surface.render();
|
22042 | }
|
22043 | };
|
22044 |
|
22045 | _proto4.componentWillUnmount = function componentWillUnmount() {
|
22046 | updateContainer(null, this._mountNode, this);
|
22047 | };
|
22048 |
|
22049 | _proto4.render = function render() {
|
22050 | var _this = this;
|
22051 |
|
22052 |
|
22053 |
|
22054 |
|
22055 |
|
22056 | var props = this.props;
|
22057 |
|
22058 | var Tag = current.Surface.tagName;
|
22059 | return React.createElement(Tag, {
|
22060 | ref: function (ref) {
|
22061 | return _this._tagRef = ref;
|
22062 | },
|
22063 | accessKey: props.accessKey,
|
22064 | className: props.className,
|
22065 | draggable: props.draggable,
|
22066 | role: props.role,
|
22067 | style: props.style,
|
22068 | tabIndex: props.tabIndex,
|
22069 | title: props.title
|
22070 | });
|
22071 | };
|
22072 |
|
22073 | return Surface;
|
22074 | }(React.Component);
|
22075 |
|
22076 | var Text = function (_React$Component2) {
|
22077 | _inheritsLoose(Text, _React$Component2);
|
22078 |
|
22079 | function Text(props) {
|
22080 | var _this2;
|
22081 |
|
22082 | _this2 = _React$Component2.call(this, props) || this;
|
22083 |
|
22084 |
|
22085 | ['height', 'width', 'x', 'y'].forEach(function (key) {
|
22086 | Object.defineProperty(_assertThisInitialized(_this2), key, {
|
22087 | get: function () {
|
22088 | return this._text ? this._text[key] : undefined;
|
22089 | }
|
22090 | });
|
22091 | });
|
22092 | return _this2;
|
22093 | }
|
22094 |
|
22095 | var _proto5 = Text.prototype;
|
22096 |
|
22097 | _proto5.render = function render() {
|
22098 | var _this3 = this;
|
22099 |
|
22100 |
|
22101 | var T = TYPES.TEXT;
|
22102 | return React.createElement(T, _extends({}, this.props, {
|
22103 | ref: function (t) {
|
22104 | return _this3._text = t;
|
22105 | }
|
22106 | }), childrenAsString(this.props.children));
|
22107 | };
|
22108 |
|
22109 | return Text;
|
22110 | }(React.Component);
|
22111 |
|
22112 | injectIntoDevTools({
|
22113 | findFiberByHostInstance: function () {
|
22114 | return null;
|
22115 | },
|
22116 | bundleType: 1 ,
|
22117 | version: ReactVersion,
|
22118 | rendererPackageName: 'react-art'
|
22119 | });
|
22120 |
|
22121 |
|
22122 | var ClippingRectangle = TYPES.CLIPPING_RECTANGLE;
|
22123 | var Group = TYPES.GROUP;
|
22124 | var Shape = TYPES.SHAPE;
|
22125 | var Path = current.Path;
|
22126 |
|
22127 | exports.ClippingRectangle = ClippingRectangle;
|
22128 | exports.Group = Group;
|
22129 | exports.LinearGradient = LinearGradient;
|
22130 | exports.Path = Path;
|
22131 | exports.Pattern = Pattern;
|
22132 | exports.RadialGradient = RadialGradient;
|
22133 | exports.Shape = Shape;
|
22134 | exports.Surface = Surface;
|
22135 | exports.Text = Text;
|
22136 | exports.Transform = transform;
|
22137 |
|
22138 | })));
|