UNPKG

580 kBJavaScriptView Raw
1/** @license React v16.9.0-alpha.0
2 * react-art.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18var _assign = require('object-assign');
19var React = require('react');
20var Transform = require('art/core/transform');
21var Mode = require('art/modes/current');
22var Scheduler = require('scheduler');
23var checkPropTypes = require('prop-types/checkPropTypes');
24var tracing = require('scheduler/tracing');
25var FastNoSideEffects = require('art/modes/fast-noSideEffects');
26
27// TODO: this is special because it gets imported during build.
28
29var ReactVersion = '16.9.0-alpha.0';
30
31// Do not require this module directly! Use a normal error constructor with
32// template literal strings. The messages will be converted to ReactError during
33// build, and in production they will be minified.
34
35// Do not require this module directly! Use a normal error constructor with
36// template literal strings. The messages will be converted to ReactError during
37// build, and in production they will be minified.
38
39function ReactError(message) {
40 var error = new Error(message);
41 error.name = 'Invariant Violation';
42 return error;
43}
44
45/**
46 * Use invariant() to assert state which your program assumes to be true.
47 *
48 * Provide sprintf-style format (only %s is supported) and arguments
49 * to provide information about what broke and what you were
50 * expecting.
51 *
52 * The invariant message will be stripped in production, but the invariant
53 * will remain to ensure logic does not differ in production.
54 */
55
56/**
57 * Similar to invariant but only logs a warning if the condition is not met.
58 * This can be used to log issues in development environments in critical
59 * paths. Removing the logging code for production environments will keep the
60 * same logic and follow the same code paths.
61 */
62
63var warningWithoutStack = function () {};
64
65{
66 warningWithoutStack = function (condition, format) {
67 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
68 args[_key - 2] = arguments[_key];
69 }
70
71 if (format === undefined) {
72 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
73 }
74 if (args.length > 8) {
75 // Check before the condition to catch violations early.
76 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
77 }
78 if (condition) {
79 return;
80 }
81 if (typeof console !== 'undefined') {
82 var argsWithFormat = args.map(function (item) {
83 return '' + item;
84 });
85 argsWithFormat.unshift('Warning: ' + format);
86
87 // We intentionally don't use spread (or .apply) directly because it
88 // breaks IE9: https://github.com/facebook/react/issues/13610
89 Function.prototype.apply.call(console.error, console, argsWithFormat);
90 }
91 try {
92 // --- Welcome to debugging React ---
93 // This error was thrown as a convenience so that you can use this stack
94 // to find the callsite that caused this warning to fire.
95 var argIndex = 0;
96 var message = 'Warning: ' + format.replace(/%s/g, function () {
97 return args[argIndex++];
98 });
99 throw new Error(message);
100 } catch (x) {}
101 };
102}
103
104var warningWithoutStack$1 = warningWithoutStack;
105
106/**
107 * `ReactInstanceMap` maintains a mapping from a public facing stateful
108 * instance (key) and the internal representation (value). This allows public
109 * methods to accept the user facing instance as an argument and map them back
110 * to internal methods.
111 *
112 * Note that this module is currently shared and assumed to be stateless.
113 * If this becomes an actual Map, that will break.
114 */
115
116/**
117 * This API should be called `delete` but we'd have to make sure to always
118 * transform these to strings for IE support. When this transform is fully
119 * supported we can rename it.
120 */
121
122
123function get(key) {
124 return key._reactInternalFiber;
125}
126
127
128
129function set(key, value) {
130 key._reactInternalFiber = value;
131}
132
133var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
134
135// Prevent newer renderers from RTE when used with older react package versions.
136// Current owner and dispatcher used to share the same ref,
137// but PR #14548 split them out to better support the react-debug-tools package.
138if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
139 ReactSharedInternals.ReactCurrentDispatcher = {
140 current: null
141 };
142}
143
144// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
145// nor polyfill, then a plain number is used for performance.
146var hasSymbol = typeof Symbol === 'function' && Symbol.for;
147
148var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
149var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
150var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
151var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
152var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
153var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
154var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
155
156var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
157var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
158var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
159var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
160var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
161var REACT_EVENT_COMPONENT_TYPE = hasSymbol ? Symbol.for('react.event_component') : 0xead5;
162var REACT_EVENT_TARGET_TYPE = hasSymbol ? Symbol.for('react.event_target') : 0xead6;
163
164// React event targets
165var REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol ? Symbol.for('react.event_target.touch_hit') : 0xead7;
166
167var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
168var FAUX_ITERATOR_SYMBOL = '@@iterator';
169
170function getIteratorFn(maybeIterable) {
171 if (maybeIterable === null || typeof maybeIterable !== 'object') {
172 return null;
173 }
174 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
175 if (typeof maybeIterator === 'function') {
176 return maybeIterator;
177 }
178 return null;
179}
180
181var Pending = 0;
182var Resolved = 1;
183var Rejected = 2;
184
185function refineResolvedLazyComponent(lazyComponent) {
186 return lazyComponent._status === Resolved ? lazyComponent._result : null;
187}
188
189function getWrappedName(outerType, innerType, wrapperName) {
190 var functionName = innerType.displayName || innerType.name || '';
191 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
192}
193
194function getComponentName(type) {
195 if (type == null) {
196 // Host root, text node or just invalid type.
197 return null;
198 }
199 {
200 if (typeof type.tag === 'number') {
201 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
202 }
203 }
204 if (typeof type === 'function') {
205 return type.displayName || type.name || null;
206 }
207 if (typeof type === 'string') {
208 return type;
209 }
210 switch (type) {
211 case REACT_CONCURRENT_MODE_TYPE:
212 return 'ConcurrentMode';
213 case REACT_FRAGMENT_TYPE:
214 return 'Fragment';
215 case REACT_PORTAL_TYPE:
216 return 'Portal';
217 case REACT_PROFILER_TYPE:
218 return 'Profiler';
219 case REACT_STRICT_MODE_TYPE:
220 return 'StrictMode';
221 case REACT_SUSPENSE_TYPE:
222 return 'Suspense';
223 }
224 if (typeof type === 'object') {
225 switch (type.$$typeof) {
226 case REACT_CONTEXT_TYPE:
227 return 'Context.Consumer';
228 case REACT_PROVIDER_TYPE:
229 return 'Context.Provider';
230 case REACT_FORWARD_REF_TYPE:
231 return getWrappedName(type, type.render, 'ForwardRef');
232 case REACT_MEMO_TYPE:
233 return getComponentName(type.type);
234 case REACT_LAZY_TYPE:
235 {
236 var thenable = type;
237 var resolvedThenable = refineResolvedLazyComponent(thenable);
238 if (resolvedThenable) {
239 return getComponentName(resolvedThenable);
240 }
241 break;
242 }
243 case REACT_EVENT_COMPONENT_TYPE:
244 {
245 var eventComponent = type;
246 var displayName = eventComponent.displayName;
247 if (displayName !== undefined) {
248 return displayName;
249 }
250 break;
251 }
252 case REACT_EVENT_TARGET_TYPE:
253 {
254 var eventTarget = type;
255 if (eventTarget.type === REACT_EVENT_TARGET_TOUCH_HIT) {
256 return 'TouchHitTarget';
257 }
258 var _displayName = eventTarget.displayName;
259 if (_displayName !== undefined) {
260 return _displayName;
261 }
262 }
263 }
264 }
265 return null;
266}
267
268var FunctionComponent = 0;
269var ClassComponent = 1;
270var IndeterminateComponent = 2; // Before we know whether it is function or class
271var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
272var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
273var HostComponent = 5;
274var HostText = 6;
275var Fragment = 7;
276var Mode$1 = 8;
277var ContextConsumer = 9;
278var ContextProvider = 10;
279var ForwardRef = 11;
280var Profiler = 12;
281var SuspenseComponent = 13;
282var MemoComponent = 14;
283var SimpleMemoComponent = 15;
284var LazyComponent = 16;
285var IncompleteClassComponent = 17;
286var DehydratedSuspenseComponent = 18;
287var EventComponent = 19;
288var EventTarget = 20;
289
290// Don't change these two values. They're used by React Dev Tools.
291var NoEffect = /* */0;
292var PerformedWork = /* */1;
293
294// You can change the rest (and add more).
295var Placement = /* */2;
296var Update = /* */4;
297var PlacementAndUpdate = /* */6;
298var Deletion = /* */8;
299var ContentReset = /* */16;
300var Callback = /* */32;
301var DidCapture = /* */64;
302var Ref = /* */128;
303var Snapshot = /* */256;
304var Passive = /* */512;
305
306// Passive & Update & Callback & Ref & Snapshot
307var LifecycleEffectMask = /* */932;
308
309// Union of all host effects
310var HostEffectMask = /* */1023;
311
312var Incomplete = /* */1024;
313var ShouldCapture = /* */2048;
314
315var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
316
317var MOUNTING = 1;
318var MOUNTED = 2;
319var UNMOUNTED = 3;
320
321function isFiberMountedImpl(fiber) {
322 var node = fiber;
323 if (!fiber.alternate) {
324 // If there is no alternate, this might be a new tree that isn't inserted
325 // yet. If it is, then it will have a pending insertion effect on it.
326 if ((node.effectTag & Placement) !== NoEffect) {
327 return MOUNTING;
328 }
329 while (node.return) {
330 node = node.return;
331 if ((node.effectTag & Placement) !== NoEffect) {
332 return MOUNTING;
333 }
334 }
335 } else {
336 while (node.return) {
337 node = node.return;
338 }
339 }
340 if (node.tag === HostRoot) {
341 // TODO: Check if this was a nested HostRoot when used with
342 // renderContainerIntoSubtree.
343 return MOUNTED;
344 }
345 // If we didn't hit the root, that means that we're in an disconnected tree
346 // that has been unmounted.
347 return UNMOUNTED;
348}
349
350function isFiberMounted(fiber) {
351 return isFiberMountedImpl(fiber) === MOUNTED;
352}
353
354function isMounted(component) {
355 {
356 var owner = ReactCurrentOwner.current;
357 if (owner !== null && owner.tag === ClassComponent) {
358 var ownerFiber = owner;
359 var instance = ownerFiber.stateNode;
360 !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component') : void 0;
361 instance._warnedAboutRefsInRender = true;
362 }
363 }
364
365 var fiber = get(component);
366 if (!fiber) {
367 return false;
368 }
369 return isFiberMountedImpl(fiber) === MOUNTED;
370}
371
372function assertIsMounted(fiber) {
373 (function () {
374 if (!(isFiberMountedImpl(fiber) === MOUNTED)) {
375 {
376 throw ReactError('Unable to find node on an unmounted component.');
377 }
378 }
379 })();
380}
381
382function findCurrentFiberUsingSlowPath(fiber) {
383 var alternate = fiber.alternate;
384 if (!alternate) {
385 // If there is no alternate, then we only need to check if it is mounted.
386 var state = isFiberMountedImpl(fiber);
387 (function () {
388 if (!(state !== UNMOUNTED)) {
389 {
390 throw ReactError('Unable to find node on an unmounted component.');
391 }
392 }
393 })();
394 if (state === MOUNTING) {
395 return null;
396 }
397 return fiber;
398 }
399 // If we have two possible branches, we'll walk backwards up to the root
400 // to see what path the root points to. On the way we may hit one of the
401 // special cases and we'll deal with them.
402 var a = fiber;
403 var b = alternate;
404 while (true) {
405 var parentA = a.return;
406 var parentB = parentA ? parentA.alternate : null;
407 if (!parentA || !parentB) {
408 // We're at the root.
409 break;
410 }
411
412 // If both copies of the parent fiber point to the same child, we can
413 // assume that the child is current. This happens when we bailout on low
414 // priority: the bailed out fiber's child reuses the current child.
415 if (parentA.child === parentB.child) {
416 var child = parentA.child;
417 while (child) {
418 if (child === a) {
419 // We've determined that A is the current branch.
420 assertIsMounted(parentA);
421 return fiber;
422 }
423 if (child === b) {
424 // We've determined that B is the current branch.
425 assertIsMounted(parentA);
426 return alternate;
427 }
428 child = child.sibling;
429 }
430 // We should never have an alternate for any mounting node. So the only
431 // way this could possibly happen is if this was unmounted, if at all.
432 (function () {
433 {
434 {
435 throw ReactError('Unable to find node on an unmounted component.');
436 }
437 }
438 })();
439 }
440
441 if (a.return !== b.return) {
442 // The return pointer of A and the return pointer of B point to different
443 // fibers. We assume that return pointers never criss-cross, so A must
444 // belong to the child set of A.return, and B must belong to the child
445 // set of B.return.
446 a = parentA;
447 b = parentB;
448 } else {
449 // The return pointers point to the same fiber. We'll have to use the
450 // default, slow path: scan the child sets of each parent alternate to see
451 // which child belongs to which set.
452 //
453 // Search parent A's child set
454 var didFindChild = false;
455 var _child = parentA.child;
456 while (_child) {
457 if (_child === a) {
458 didFindChild = true;
459 a = parentA;
460 b = parentB;
461 break;
462 }
463 if (_child === b) {
464 didFindChild = true;
465 b = parentA;
466 a = parentB;
467 break;
468 }
469 _child = _child.sibling;
470 }
471 if (!didFindChild) {
472 // Search parent B's child set
473 _child = parentB.child;
474 while (_child) {
475 if (_child === a) {
476 didFindChild = true;
477 a = parentB;
478 b = parentA;
479 break;
480 }
481 if (_child === b) {
482 didFindChild = true;
483 b = parentB;
484 a = parentA;
485 break;
486 }
487 _child = _child.sibling;
488 }
489 (function () {
490 if (!didFindChild) {
491 {
492 throw ReactError('Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.');
493 }
494 }
495 })();
496 }
497 }
498
499 (function () {
500 if (!(a.alternate === b)) {
501 {
502 throw ReactError('Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.');
503 }
504 }
505 })();
506 }
507 // If the root is not a host container, we're in a disconnected tree. I.e.
508 // unmounted.
509 (function () {
510 if (!(a.tag === HostRoot)) {
511 {
512 throw ReactError('Unable to find node on an unmounted component.');
513 }
514 }
515 })();
516 if (a.stateNode.current === a) {
517 // We've determined that A is the current branch.
518 return fiber;
519 }
520 // Otherwise B has to be current branch.
521 return alternate;
522}
523
524function findCurrentHostFiber(parent) {
525 var currentParent = findCurrentFiberUsingSlowPath(parent);
526 if (!currentParent) {
527 return null;
528 }
529
530 // Next we'll drill down this component to find the first HostComponent/Text.
531 var node = currentParent;
532 while (true) {
533 if (node.tag === HostComponent || node.tag === HostText) {
534 return node;
535 } else if (node.child) {
536 node.child.return = node;
537 node = node.child;
538 continue;
539 }
540 if (node === currentParent) {
541 return null;
542 }
543 while (!node.sibling) {
544 if (!node.return || node.return === currentParent) {
545 return null;
546 }
547 node = node.return;
548 }
549 node.sibling.return = node.return;
550 node = node.sibling;
551 }
552 // Flow needs the return null here, but ESLint complains about it.
553 // eslint-disable-next-line no-unreachable
554 return null;
555}
556
557var TYPES = {
558 CLIPPING_RECTANGLE: 'ClippingRectangle',
559 GROUP: 'Group',
560 SHAPE: 'Shape',
561 TEXT: 'Text'
562};
563
564var EVENT_TYPES = {
565 onClick: 'click',
566 onMouseMove: 'mousemove',
567 onMouseOver: 'mouseover',
568 onMouseOut: 'mouseout',
569 onMouseUp: 'mouseup',
570 onMouseDown: 'mousedown'
571};
572
573function childrenAsString(children) {
574 if (!children) {
575 return '';
576 } else if (typeof children === 'string') {
577 return children;
578 } else if (children.length) {
579 return children.join('');
580 } else {
581 return '';
582 }
583}
584
585// Renderers that don't support persistence
586// can re-export everything from this module.
587
588function shim() {
589 (function () {
590 {
591 {
592 throw ReactError('The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.');
593 }
594 }
595 })();
596}
597
598// Persistence (when unsupported)
599var supportsPersistence = false;
600var cloneInstance = shim;
601var createContainerChildSet = shim;
602var appendChildToContainerChildSet = shim;
603var finalizeContainerChildren = shim;
604var replaceContainerChildren = shim;
605var cloneHiddenInstance = shim;
606var cloneHiddenTextInstance = shim;
607
608// Renderers that don't support hydration
609// can re-export everything from this module.
610
611function shim$1() {
612 (function () {
613 {
614 {
615 throw ReactError('The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.');
616 }
617 }
618 })();
619}
620
621// Hydration (when unsupported)
622
623var supportsHydration = false;
624var canHydrateInstance = shim$1;
625var canHydrateTextInstance = shim$1;
626var canHydrateSuspenseInstance = shim$1;
627var isSuspenseInstancePending = shim$1;
628var isSuspenseInstanceFallback = shim$1;
629var registerSuspenseInstanceRetry = shim$1;
630var getNextHydratableSibling = shim$1;
631var getFirstHydratableChild = shim$1;
632var hydrateInstance = shim$1;
633var hydrateTextInstance = shim$1;
634var getNextHydratableInstanceAfterSuspenseInstance = shim$1;
635var clearSuspenseBoundary = shim$1;
636var clearSuspenseBoundaryFromContainer = shim$1;
637var didNotMatchHydratedContainerTextInstance = shim$1;
638var didNotMatchHydratedTextInstance = shim$1;
639var didNotHydrateContainerInstance = shim$1;
640var didNotHydrateInstance = shim$1;
641var didNotFindHydratableContainerInstance = shim$1;
642var didNotFindHydratableContainerTextInstance = shim$1;
643var didNotFindHydratableContainerSuspenseInstance = shim$1;
644var didNotFindHydratableInstance = shim$1;
645var didNotFindHydratableTextInstance = shim$1;
646var didNotFindHydratableSuspenseInstance = shim$1;
647
648var pooledTransform = new Transform();
649
650var NO_CONTEXT = {};
651var UPDATE_SIGNAL = {};
652{
653 Object.freeze(NO_CONTEXT);
654 Object.freeze(UPDATE_SIGNAL);
655}
656
657/** Helper Methods */
658
659function addEventListeners(instance, type, listener) {
660 // We need to explicitly unregister before unmount.
661 // For this reason we need to track subscriptions.
662 if (!instance._listeners) {
663 instance._listeners = {};
664 instance._subscriptions = {};
665 }
666
667 instance._listeners[type] = listener;
668
669 if (listener) {
670 if (!instance._subscriptions[type]) {
671 instance._subscriptions[type] = instance.subscribe(type, createEventHandler(instance), instance);
672 }
673 } else {
674 if (instance._subscriptions[type]) {
675 instance._subscriptions[type]();
676 delete instance._subscriptions[type];
677 }
678 }
679}
680
681function createEventHandler(instance) {
682 return function handleEvent(event) {
683 var listener = instance._listeners[event.type];
684
685 if (!listener) {
686 // Noop
687 } else if (typeof listener === 'function') {
688 listener.call(instance, event);
689 } else if (listener.handleEvent) {
690 listener.handleEvent(event);
691 }
692 };
693}
694
695function destroyEventListeners(instance) {
696 if (instance._subscriptions) {
697 for (var type in instance._subscriptions) {
698 instance._subscriptions[type]();
699 }
700 }
701
702 instance._subscriptions = null;
703 instance._listeners = null;
704}
705
706function getScaleX(props) {
707 if (props.scaleX != null) {
708 return props.scaleX;
709 } else if (props.scale != null) {
710 return props.scale;
711 } else {
712 return 1;
713 }
714}
715
716function getScaleY(props) {
717 if (props.scaleY != null) {
718 return props.scaleY;
719 } else if (props.scale != null) {
720 return props.scale;
721 } else {
722 return 1;
723 }
724}
725
726function isSameFont(oldFont, newFont) {
727 if (oldFont === newFont) {
728 return true;
729 } else if (typeof newFont === 'string' || typeof oldFont === 'string') {
730 return false;
731 } else {
732 return newFont.fontSize === oldFont.fontSize && newFont.fontStyle === oldFont.fontStyle && newFont.fontVariant === oldFont.fontVariant && newFont.fontWeight === oldFont.fontWeight && newFont.fontFamily === oldFont.fontFamily;
733 }
734}
735
736/** Render Methods */
737
738function applyClippingRectangleProps(instance, props) {
739 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
740
741 applyNodeProps(instance, props, prevProps);
742
743 instance.width = props.width;
744 instance.height = props.height;
745}
746
747function applyGroupProps(instance, props) {
748 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
749
750 applyNodeProps(instance, props, prevProps);
751
752 instance.width = props.width;
753 instance.height = props.height;
754}
755
756function applyNodeProps(instance, props) {
757 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
758
759 var scaleX = getScaleX(props);
760 var scaleY = getScaleY(props);
761
762 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);
763
764 if (props.transform != null) {
765 pooledTransform.transform(props.transform);
766 }
767
768 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) {
769 instance.transformTo(pooledTransform);
770 }
771
772 if (props.cursor !== prevProps.cursor || props.title !== prevProps.title) {
773 instance.indicate(props.cursor, props.title);
774 }
775
776 if (instance.blend && props.opacity !== prevProps.opacity) {
777 instance.blend(props.opacity == null ? 1 : props.opacity);
778 }
779
780 if (props.visible !== prevProps.visible) {
781 if (props.visible == null || props.visible) {
782 instance.show();
783 } else {
784 instance.hide();
785 }
786 }
787
788 for (var type in EVENT_TYPES) {
789 addEventListeners(instance, EVENT_TYPES[type], props[type]);
790 }
791}
792
793function applyRenderableNodeProps(instance, props) {
794 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
795
796 applyNodeProps(instance, props, prevProps);
797
798 if (prevProps.fill !== props.fill) {
799 if (props.fill && props.fill.applyFill) {
800 props.fill.applyFill(instance);
801 } else {
802 instance.fill(props.fill);
803 }
804 }
805 if (prevProps.stroke !== props.stroke || prevProps.strokeWidth !== props.strokeWidth || prevProps.strokeCap !== props.strokeCap || prevProps.strokeJoin !== props.strokeJoin ||
806 // TODO: Consider deep check of stokeDash; may benefit VML in IE.
807 prevProps.strokeDash !== props.strokeDash) {
808 instance.stroke(props.stroke, props.strokeWidth, props.strokeCap, props.strokeJoin, props.strokeDash);
809 }
810}
811
812function applyShapeProps(instance, props) {
813 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
814
815 applyRenderableNodeProps(instance, props, prevProps);
816
817 var path = props.d || childrenAsString(props.children);
818
819 var prevDelta = instance._prevDelta;
820 var prevPath = instance._prevPath;
821
822 if (path !== prevPath || path.delta !== prevDelta || prevProps.height !== props.height || prevProps.width !== props.width) {
823 instance.draw(path, props.width, props.height);
824
825 instance._prevDelta = path.delta;
826 instance._prevPath = path;
827 }
828}
829
830function applyTextProps(instance, props) {
831 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
832
833 applyRenderableNodeProps(instance, props, prevProps);
834
835 var string = props.children;
836
837 if (instance._currentString !== string || !isSameFont(props.font, prevProps.font) || props.alignment !== prevProps.alignment || props.path !== prevProps.path) {
838 instance.draw(string, props.font, props.alignment, props.path);
839
840 instance._currentString = string;
841 }
842}
843
844function appendInitialChild(parentInstance, child) {
845 if (typeof child === 'string') {
846 // Noop for string children of Text (eg <Text>{'foo'}{'bar'}</Text>)
847 (function () {
848 {
849 {
850 throw ReactError('Text children should already be flattened.');
851 }
852 }
853 })();
854 return;
855 }
856
857 child.inject(parentInstance);
858}
859
860function createInstance(type, props, internalInstanceHandle) {
861 var instance = void 0;
862
863 switch (type) {
864 case TYPES.CLIPPING_RECTANGLE:
865 instance = Mode.ClippingRectangle();
866 instance._applyProps = applyClippingRectangleProps;
867 break;
868 case TYPES.GROUP:
869 instance = Mode.Group();
870 instance._applyProps = applyGroupProps;
871 break;
872 case TYPES.SHAPE:
873 instance = Mode.Shape();
874 instance._applyProps = applyShapeProps;
875 break;
876 case TYPES.TEXT:
877 instance = Mode.Text(props.children, props.font, props.alignment, props.path);
878 instance._applyProps = applyTextProps;
879 break;
880 }
881
882 (function () {
883 if (!instance) {
884 {
885 throw ReactError('ReactART does not support the type "' + type + '"');
886 }
887 }
888 })();
889
890 instance._applyProps(instance, props);
891
892 return instance;
893}
894
895function createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
896 return text;
897}
898
899function finalizeInitialChildren(domElement, type, props) {
900 return false;
901}
902
903function getPublicInstance(instance) {
904 return instance;
905}
906
907function prepareForCommit() {
908 // Noop
909}
910
911function prepareUpdate(domElement, type, oldProps, newProps) {
912 return UPDATE_SIGNAL;
913}
914
915function resetAfterCommit() {
916 // Noop
917}
918
919function resetTextContent(domElement) {
920 // Noop
921}
922
923function shouldDeprioritizeSubtree(type, props) {
924 return false;
925}
926
927function getRootHostContext() {
928 return NO_CONTEXT;
929}
930
931function getChildHostContext() {
932 return NO_CONTEXT;
933}
934
935function getChildHostContextForEventComponent() {
936 return NO_CONTEXT;
937}
938
939function getChildHostContextForEventTarget() {
940 return NO_CONTEXT;
941}
942
943var scheduleTimeout = setTimeout;
944var cancelTimeout = clearTimeout;
945var noTimeout = -1;
946
947function shouldSetTextContent(type, props) {
948 return typeof props.children === 'string' || typeof props.children === 'number';
949}
950
951// The ART renderer is secondary to the React DOM renderer.
952var isPrimaryRenderer = false;
953
954var supportsMutation = true;
955
956function appendChild(parentInstance, child) {
957 if (child.parentNode === parentInstance) {
958 child.eject();
959 }
960 child.inject(parentInstance);
961}
962
963function appendChildToContainer(parentInstance, child) {
964 if (child.parentNode === parentInstance) {
965 child.eject();
966 }
967 child.inject(parentInstance);
968}
969
970function insertBefore(parentInstance, child, beforeChild) {
971 (function () {
972 if (!(child !== beforeChild)) {
973 {
974 throw ReactError('ReactART: Can not insert node before itself');
975 }
976 }
977 })();
978 child.injectBefore(beforeChild);
979}
980
981function insertInContainerBefore(parentInstance, child, beforeChild) {
982 (function () {
983 if (!(child !== beforeChild)) {
984 {
985 throw ReactError('ReactART: Can not insert node before itself');
986 }
987 }
988 })();
989 child.injectBefore(beforeChild);
990}
991
992function removeChild(parentInstance, child) {
993 destroyEventListeners(child);
994 child.eject();
995}
996
997function removeChildFromContainer(parentInstance, child) {
998 destroyEventListeners(child);
999 child.eject();
1000}
1001
1002
1003
1004
1005
1006function commitUpdate(instance, updatePayload, type, oldProps, newProps) {
1007 instance._applyProps(instance, newProps, oldProps);
1008}
1009
1010function hideInstance(instance) {
1011 instance.hide();
1012}
1013
1014
1015
1016function unhideInstance(instance, props) {
1017 if (props.visible == null || props.visible) {
1018 instance.show();
1019 }
1020}
1021
1022function unhideTextInstance(textInstance, text) {
1023 // Noop
1024}
1025
1026var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
1027
1028var describeComponentFrame = function (name, source, ownerName) {
1029 var sourceInfo = '';
1030 if (source) {
1031 var path = source.fileName;
1032 var fileName = path.replace(BEFORE_SLASH_RE, '');
1033 {
1034 // In DEV, include code for a common special case:
1035 // prefer "folder/index.js" instead of just "index.js".
1036 if (/^index\./.test(fileName)) {
1037 var match = path.match(BEFORE_SLASH_RE);
1038 if (match) {
1039 var pathBeforeSlash = match[1];
1040 if (pathBeforeSlash) {
1041 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
1042 fileName = folderName + '/' + fileName;
1043 }
1044 }
1045 }
1046 }
1047 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
1048 } else if (ownerName) {
1049 sourceInfo = ' (created by ' + ownerName + ')';
1050 }
1051 return '\n in ' + (name || 'Unknown') + sourceInfo;
1052};
1053
1054var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1055
1056function describeFiber(fiber) {
1057 switch (fiber.tag) {
1058 case HostRoot:
1059 case HostPortal:
1060 case HostText:
1061 case Fragment:
1062 case ContextProvider:
1063 case ContextConsumer:
1064 return '';
1065 default:
1066 var owner = fiber._debugOwner;
1067 var source = fiber._debugSource;
1068 var name = getComponentName(fiber.type);
1069 var ownerName = null;
1070 if (owner) {
1071 ownerName = getComponentName(owner.type);
1072 }
1073 return describeComponentFrame(name, source, ownerName);
1074 }
1075}
1076
1077function getStackByFiberInDevAndProd(workInProgress) {
1078 var info = '';
1079 var node = workInProgress;
1080 do {
1081 info += describeFiber(node);
1082 node = node.return;
1083 } while (node);
1084 return info;
1085}
1086
1087var current = null;
1088var phase = null;
1089
1090function getCurrentFiberOwnerNameInDevOrNull() {
1091 {
1092 if (current === null) {
1093 return null;
1094 }
1095 var owner = current._debugOwner;
1096 if (owner !== null && typeof owner !== 'undefined') {
1097 return getComponentName(owner.type);
1098 }
1099 }
1100 return null;
1101}
1102
1103function getCurrentFiberStackInDev() {
1104 {
1105 if (current === null) {
1106 return '';
1107 }
1108 // Safe because if current fiber exists, we are reconciling,
1109 // and it is guaranteed to be the work-in-progress version.
1110 return getStackByFiberInDevAndProd(current);
1111 }
1112 return '';
1113}
1114
1115function resetCurrentFiber() {
1116 {
1117 ReactDebugCurrentFrame.getCurrentStack = null;
1118 current = null;
1119 phase = null;
1120 }
1121}
1122
1123function setCurrentFiber(fiber) {
1124 {
1125 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
1126 current = fiber;
1127 phase = null;
1128 }
1129}
1130
1131function setCurrentPhase(lifeCyclePhase) {
1132 {
1133 phase = lifeCyclePhase;
1134 }
1135}
1136
1137var enableUserTimingAPI = true;
1138
1139// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
1140var debugRenderPhaseSideEffects = false;
1141
1142// In some cases, StrictMode should also double-render lifecycles.
1143// This can be confusing for tests though,
1144// And it can be bad for performance in production.
1145// This feature flag can be used to control the behavior:
1146var debugRenderPhaseSideEffectsForStrictMode = true;
1147
1148// To preserve the "Pause on caught exceptions" behavior of the debugger, we
1149// replay the begin phase of a failed component inside invokeGuardedCallback.
1150var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
1151
1152// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
1153var warnAboutDeprecatedLifecycles = true;
1154
1155// Gather advanced timing metrics for Profiler subtrees.
1156var enableProfilerTimer = true;
1157
1158// Trace which interactions trigger each commit.
1159var enableSchedulerTracing = true;
1160
1161// Only used in www builds.
1162var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
1163
1164// Only used in www builds.
1165
1166
1167// Only used in www builds.
1168
1169
1170// Disable javascript: URL strings in href for XSS protection.
1171
1172
1173// Disables yielding during render in Concurrent Mode. Used for debugging only.
1174var disableYielding = false;
1175
1176// React Fire: prevent the value and checked attributes from syncing
1177// with their related DOM properties
1178
1179
1180// These APIs will no longer be "unstable" in the upcoming 16.7 release,
1181// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
1182
1183
1184
1185
1186// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
1187// This is a flag so we can fix warnings in RN core before turning it on
1188
1189
1190// Experimental React Events support. Only used in www builds for now.
1191var enableEventAPI = false;
1192
1193// Enables rewritten version of ReactFiberScheduler. Added in case we need to
1194// quickly revert it.
1195var enableNewScheduler = false;
1196
1197// Prefix measurements so that it's possible to filter them.
1198// Longer prefixes are hard to read in DevTools.
1199var reactEmoji = '\u269B';
1200var warningEmoji = '\u26D4';
1201var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
1202
1203// Keep track of current fiber so that we know the path to unwind on pause.
1204// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
1205var currentFiber = null;
1206// If we're in the middle of user code, which fiber and method is it?
1207// Reusing `currentFiber` would be confusing for this because user code fiber
1208// can change during commit phase too, but we don't need to unwind it (since
1209// lifecycles in the commit phase don't resemble a tree).
1210var currentPhase = null;
1211var currentPhaseFiber = null;
1212// Did lifecycle hook schedule an update? This is often a performance problem,
1213// so we will keep track of it, and include it in the report.
1214// Track commits caused by cascading updates.
1215var isCommitting = false;
1216var hasScheduledUpdateInCurrentCommit = false;
1217var hasScheduledUpdateInCurrentPhase = false;
1218var commitCountInCurrentWorkLoop = 0;
1219var effectCountInCurrentCommit = 0;
1220var isWaitingForCallback = false;
1221// During commits, we only show a measurement once per method name
1222// to avoid stretch the commit phase with measurement overhead.
1223var labelsInCurrentCommit = new Set();
1224
1225var formatMarkName = function (markName) {
1226 return reactEmoji + ' ' + markName;
1227};
1228
1229var formatLabel = function (label, warning) {
1230 var prefix = warning ? warningEmoji + ' ' : reactEmoji + ' ';
1231 var suffix = warning ? ' Warning: ' + warning : '';
1232 return '' + prefix + label + suffix;
1233};
1234
1235var beginMark = function (markName) {
1236 performance.mark(formatMarkName(markName));
1237};
1238
1239var clearMark = function (markName) {
1240 performance.clearMarks(formatMarkName(markName));
1241};
1242
1243var endMark = function (label, markName, warning) {
1244 var formattedMarkName = formatMarkName(markName);
1245 var formattedLabel = formatLabel(label, warning);
1246 try {
1247 performance.measure(formattedLabel, formattedMarkName);
1248 } catch (err) {}
1249 // If previous mark was missing for some reason, this will throw.
1250 // This could only happen if React crashed in an unexpected place earlier.
1251 // Don't pile on with more errors.
1252
1253 // Clear marks immediately to avoid growing buffer.
1254 performance.clearMarks(formattedMarkName);
1255 performance.clearMeasures(formattedLabel);
1256};
1257
1258var getFiberMarkName = function (label, debugID) {
1259 return label + ' (#' + debugID + ')';
1260};
1261
1262var getFiberLabel = function (componentName, isMounted, phase) {
1263 if (phase === null) {
1264 // These are composite component total time measurements.
1265 return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']';
1266 } else {
1267 // Composite component methods.
1268 return componentName + '.' + phase;
1269 }
1270};
1271
1272var beginFiberMark = function (fiber, phase) {
1273 var componentName = getComponentName(fiber.type) || 'Unknown';
1274 var debugID = fiber._debugID;
1275 var isMounted = fiber.alternate !== null;
1276 var label = getFiberLabel(componentName, isMounted, phase);
1277
1278 if (isCommitting && labelsInCurrentCommit.has(label)) {
1279 // During the commit phase, we don't show duplicate labels because
1280 // there is a fixed overhead for every measurement, and we don't
1281 // want to stretch the commit phase beyond necessary.
1282 return false;
1283 }
1284 labelsInCurrentCommit.add(label);
1285
1286 var markName = getFiberMarkName(label, debugID);
1287 beginMark(markName);
1288 return true;
1289};
1290
1291var clearFiberMark = function (fiber, phase) {
1292 var componentName = getComponentName(fiber.type) || 'Unknown';
1293 var debugID = fiber._debugID;
1294 var isMounted = fiber.alternate !== null;
1295 var label = getFiberLabel(componentName, isMounted, phase);
1296 var markName = getFiberMarkName(label, debugID);
1297 clearMark(markName);
1298};
1299
1300var endFiberMark = function (fiber, phase, warning) {
1301 var componentName = getComponentName(fiber.type) || 'Unknown';
1302 var debugID = fiber._debugID;
1303 var isMounted = fiber.alternate !== null;
1304 var label = getFiberLabel(componentName, isMounted, phase);
1305 var markName = getFiberMarkName(label, debugID);
1306 endMark(label, markName, warning);
1307};
1308
1309var shouldIgnoreFiber = function (fiber) {
1310 // Host components should be skipped in the timeline.
1311 // We could check typeof fiber.type, but does this work with RN?
1312 switch (fiber.tag) {
1313 case HostRoot:
1314 case HostComponent:
1315 case HostText:
1316 case HostPortal:
1317 case Fragment:
1318 case ContextProvider:
1319 case ContextConsumer:
1320 case Mode$1:
1321 return true;
1322 default:
1323 return false;
1324 }
1325};
1326
1327var clearPendingPhaseMeasurement = function () {
1328 if (currentPhase !== null && currentPhaseFiber !== null) {
1329 clearFiberMark(currentPhaseFiber, currentPhase);
1330 }
1331 currentPhaseFiber = null;
1332 currentPhase = null;
1333 hasScheduledUpdateInCurrentPhase = false;
1334};
1335
1336var pauseTimers = function () {
1337 // Stops all currently active measurements so that they can be resumed
1338 // if we continue in a later deferred loop from the same unit of work.
1339 var fiber = currentFiber;
1340 while (fiber) {
1341 if (fiber._debugIsCurrentlyTiming) {
1342 endFiberMark(fiber, null, null);
1343 }
1344 fiber = fiber.return;
1345 }
1346};
1347
1348var resumeTimersRecursively = function (fiber) {
1349 if (fiber.return !== null) {
1350 resumeTimersRecursively(fiber.return);
1351 }
1352 if (fiber._debugIsCurrentlyTiming) {
1353 beginFiberMark(fiber, null);
1354 }
1355};
1356
1357var resumeTimers = function () {
1358 // Resumes all measurements that were active during the last deferred loop.
1359 if (currentFiber !== null) {
1360 resumeTimersRecursively(currentFiber);
1361 }
1362};
1363
1364function recordEffect() {
1365 if (enableUserTimingAPI) {
1366 effectCountInCurrentCommit++;
1367 }
1368}
1369
1370function recordScheduleUpdate() {
1371 if (enableUserTimingAPI) {
1372 if (isCommitting) {
1373 hasScheduledUpdateInCurrentCommit = true;
1374 }
1375 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
1376 hasScheduledUpdateInCurrentPhase = true;
1377 }
1378 }
1379}
1380
1381function startRequestCallbackTimer() {
1382 if (enableUserTimingAPI) {
1383 if (supportsUserTiming && !isWaitingForCallback) {
1384 isWaitingForCallback = true;
1385 beginMark('(Waiting for async callback...)');
1386 }
1387 }
1388}
1389
1390function stopRequestCallbackTimer(didExpire, expirationTime) {
1391 if (enableUserTimingAPI) {
1392 if (supportsUserTiming) {
1393 isWaitingForCallback = false;
1394 var warning = didExpire ? 'React was blocked by main thread' : null;
1395 endMark('(Waiting for async callback... will force flush in ' + expirationTime + ' ms)', '(Waiting for async callback...)', warning);
1396 }
1397 }
1398}
1399
1400function startWorkTimer(fiber) {
1401 if (enableUserTimingAPI) {
1402 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1403 return;
1404 }
1405 // If we pause, this is the fiber to unwind from.
1406 currentFiber = fiber;
1407 if (!beginFiberMark(fiber, null)) {
1408 return;
1409 }
1410 fiber._debugIsCurrentlyTiming = true;
1411 }
1412}
1413
1414function cancelWorkTimer(fiber) {
1415 if (enableUserTimingAPI) {
1416 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1417 return;
1418 }
1419 // Remember we shouldn't complete measurement for this fiber.
1420 // Otherwise flamechart will be deep even for small updates.
1421 fiber._debugIsCurrentlyTiming = false;
1422 clearFiberMark(fiber, null);
1423 }
1424}
1425
1426function stopWorkTimer(fiber) {
1427 if (enableUserTimingAPI) {
1428 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1429 return;
1430 }
1431 // If we pause, its parent is the fiber to unwind from.
1432 currentFiber = fiber.return;
1433 if (!fiber._debugIsCurrentlyTiming) {
1434 return;
1435 }
1436 fiber._debugIsCurrentlyTiming = false;
1437 endFiberMark(fiber, null, null);
1438 }
1439}
1440
1441function stopFailedWorkTimer(fiber) {
1442 if (enableUserTimingAPI) {
1443 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1444 return;
1445 }
1446 // If we pause, its parent is the fiber to unwind from.
1447 currentFiber = fiber.return;
1448 if (!fiber._debugIsCurrentlyTiming) {
1449 return;
1450 }
1451 fiber._debugIsCurrentlyTiming = false;
1452 var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1453 endFiberMark(fiber, null, warning);
1454 }
1455}
1456
1457function startPhaseTimer(fiber, phase) {
1458 if (enableUserTimingAPI) {
1459 if (!supportsUserTiming) {
1460 return;
1461 }
1462 clearPendingPhaseMeasurement();
1463 if (!beginFiberMark(fiber, phase)) {
1464 return;
1465 }
1466 currentPhaseFiber = fiber;
1467 currentPhase = phase;
1468 }
1469}
1470
1471function stopPhaseTimer() {
1472 if (enableUserTimingAPI) {
1473 if (!supportsUserTiming) {
1474 return;
1475 }
1476 if (currentPhase !== null && currentPhaseFiber !== null) {
1477 var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
1478 endFiberMark(currentPhaseFiber, currentPhase, warning);
1479 }
1480 currentPhase = null;
1481 currentPhaseFiber = null;
1482 }
1483}
1484
1485function startWorkLoopTimer(nextUnitOfWork) {
1486 if (enableUserTimingAPI) {
1487 currentFiber = nextUnitOfWork;
1488 if (!supportsUserTiming) {
1489 return;
1490 }
1491 commitCountInCurrentWorkLoop = 0;
1492 // This is top level call.
1493 // Any other measurements are performed within.
1494 beginMark('(React Tree Reconciliation)');
1495 // Resume any measurements that were in progress during the last loop.
1496 resumeTimers();
1497 }
1498}
1499
1500function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
1501 if (enableUserTimingAPI) {
1502 if (!supportsUserTiming) {
1503 return;
1504 }
1505 var warning = null;
1506 if (interruptedBy !== null) {
1507 if (interruptedBy.tag === HostRoot) {
1508 warning = 'A top-level update interrupted the previous render';
1509 } else {
1510 var componentName = getComponentName(interruptedBy.type) || 'Unknown';
1511 warning = 'An update to ' + componentName + ' interrupted the previous render';
1512 }
1513 } else if (commitCountInCurrentWorkLoop > 1) {
1514 warning = 'There were cascading updates';
1515 }
1516 commitCountInCurrentWorkLoop = 0;
1517 var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
1518 // Pause any measurements until the next loop.
1519 pauseTimers();
1520 endMark(label, '(React Tree Reconciliation)', warning);
1521 }
1522}
1523
1524function startCommitTimer() {
1525 if (enableUserTimingAPI) {
1526 if (!supportsUserTiming) {
1527 return;
1528 }
1529 isCommitting = true;
1530 hasScheduledUpdateInCurrentCommit = false;
1531 labelsInCurrentCommit.clear();
1532 beginMark('(Committing Changes)');
1533 }
1534}
1535
1536function stopCommitTimer() {
1537 if (enableUserTimingAPI) {
1538 if (!supportsUserTiming) {
1539 return;
1540 }
1541
1542 var warning = null;
1543 if (hasScheduledUpdateInCurrentCommit) {
1544 warning = 'Lifecycle hook scheduled a cascading update';
1545 } else if (commitCountInCurrentWorkLoop > 0) {
1546 warning = 'Caused by a cascading update in earlier commit';
1547 }
1548 hasScheduledUpdateInCurrentCommit = false;
1549 commitCountInCurrentWorkLoop++;
1550 isCommitting = false;
1551 labelsInCurrentCommit.clear();
1552
1553 endMark('(Committing Changes)', '(Committing Changes)', warning);
1554 }
1555}
1556
1557function startCommitSnapshotEffectsTimer() {
1558 if (enableUserTimingAPI) {
1559 if (!supportsUserTiming) {
1560 return;
1561 }
1562 effectCountInCurrentCommit = 0;
1563 beginMark('(Committing Snapshot Effects)');
1564 }
1565}
1566
1567function stopCommitSnapshotEffectsTimer() {
1568 if (enableUserTimingAPI) {
1569 if (!supportsUserTiming) {
1570 return;
1571 }
1572 var count = effectCountInCurrentCommit;
1573 effectCountInCurrentCommit = 0;
1574 endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null);
1575 }
1576}
1577
1578function startCommitHostEffectsTimer() {
1579 if (enableUserTimingAPI) {
1580 if (!supportsUserTiming) {
1581 return;
1582 }
1583 effectCountInCurrentCommit = 0;
1584 beginMark('(Committing Host Effects)');
1585 }
1586}
1587
1588function stopCommitHostEffectsTimer() {
1589 if (enableUserTimingAPI) {
1590 if (!supportsUserTiming) {
1591 return;
1592 }
1593 var count = effectCountInCurrentCommit;
1594 effectCountInCurrentCommit = 0;
1595 endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null);
1596 }
1597}
1598
1599function startCommitLifeCyclesTimer() {
1600 if (enableUserTimingAPI) {
1601 if (!supportsUserTiming) {
1602 return;
1603 }
1604 effectCountInCurrentCommit = 0;
1605 beginMark('(Calling Lifecycle Methods)');
1606 }
1607}
1608
1609function stopCommitLifeCyclesTimer() {
1610 if (enableUserTimingAPI) {
1611 if (!supportsUserTiming) {
1612 return;
1613 }
1614 var count = effectCountInCurrentCommit;
1615 effectCountInCurrentCommit = 0;
1616 endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null);
1617 }
1618}
1619
1620var valueStack = [];
1621
1622var fiberStack = void 0;
1623
1624{
1625 fiberStack = [];
1626}
1627
1628var index = -1;
1629
1630function createCursor(defaultValue) {
1631 return {
1632 current: defaultValue
1633 };
1634}
1635
1636function pop(cursor, fiber) {
1637 if (index < 0) {
1638 {
1639 warningWithoutStack$1(false, 'Unexpected pop.');
1640 }
1641 return;
1642 }
1643
1644 {
1645 if (fiber !== fiberStack[index]) {
1646 warningWithoutStack$1(false, 'Unexpected Fiber popped.');
1647 }
1648 }
1649
1650 cursor.current = valueStack[index];
1651
1652 valueStack[index] = null;
1653
1654 {
1655 fiberStack[index] = null;
1656 }
1657
1658 index--;
1659}
1660
1661function push(cursor, value, fiber) {
1662 index++;
1663
1664 valueStack[index] = cursor.current;
1665
1666 {
1667 fiberStack[index] = fiber;
1668 }
1669
1670 cursor.current = value;
1671}
1672
1673function checkThatStackIsEmpty() {
1674 {
1675 if (index !== -1) {
1676 warningWithoutStack$1(false, 'Expected an empty stack. Something was not reset properly.');
1677 }
1678 }
1679}
1680
1681function resetStackAfterFatalErrorInDev() {
1682 {
1683 index = -1;
1684 valueStack.length = 0;
1685 fiberStack.length = 0;
1686 }
1687}
1688
1689var warnedAboutMissingGetChildContext = void 0;
1690
1691{
1692 warnedAboutMissingGetChildContext = {};
1693}
1694
1695var emptyContextObject = {};
1696{
1697 Object.freeze(emptyContextObject);
1698}
1699
1700// A cursor to the current merged context object on the stack.
1701var contextStackCursor = createCursor(emptyContextObject);
1702// A cursor to a boolean indicating whether the context has changed.
1703var didPerformWorkStackCursor = createCursor(false);
1704// Keep track of the previous context object that was on the stack.
1705// We use this to get access to the parent context after we have already
1706// pushed the next context provider, and now need to merge their contexts.
1707var previousContext = emptyContextObject;
1708
1709function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
1710 if (didPushOwnContextIfProvider && isContextProvider(Component)) {
1711 // If the fiber is a context provider itself, when we read its context
1712 // we may have already pushed its own child context on the stack. A context
1713 // provider should not "see" its own child context. Therefore we read the
1714 // previous (parent) context instead for a context provider.
1715 return previousContext;
1716 }
1717 return contextStackCursor.current;
1718}
1719
1720function cacheContext(workInProgress, unmaskedContext, maskedContext) {
1721 var instance = workInProgress.stateNode;
1722 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
1723 instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
1724}
1725
1726function getMaskedContext(workInProgress, unmaskedContext) {
1727 var type = workInProgress.type;
1728 var contextTypes = type.contextTypes;
1729 if (!contextTypes) {
1730 return emptyContextObject;
1731 }
1732
1733 // Avoid recreating masked context unless unmasked context has changed.
1734 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
1735 // This may trigger infinite loops if componentWillReceiveProps calls setState.
1736 var instance = workInProgress.stateNode;
1737 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
1738 return instance.__reactInternalMemoizedMaskedChildContext;
1739 }
1740
1741 var context = {};
1742 for (var key in contextTypes) {
1743 context[key] = unmaskedContext[key];
1744 }
1745
1746 {
1747 var name = getComponentName(type) || 'Unknown';
1748 checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
1749 }
1750
1751 // Cache unmasked context so we can avoid recreating masked context unless necessary.
1752 // Context is created before the class component is instantiated so check for instance.
1753 if (instance) {
1754 cacheContext(workInProgress, unmaskedContext, context);
1755 }
1756
1757 return context;
1758}
1759
1760function hasContextChanged() {
1761 return didPerformWorkStackCursor.current;
1762}
1763
1764function isContextProvider(type) {
1765 var childContextTypes = type.childContextTypes;
1766 return childContextTypes !== null && childContextTypes !== undefined;
1767}
1768
1769function popContext(fiber) {
1770 pop(didPerformWorkStackCursor, fiber);
1771 pop(contextStackCursor, fiber);
1772}
1773
1774function popTopLevelContextObject(fiber) {
1775 pop(didPerformWorkStackCursor, fiber);
1776 pop(contextStackCursor, fiber);
1777}
1778
1779function pushTopLevelContextObject(fiber, context, didChange) {
1780 (function () {
1781 if (!(contextStackCursor.current === emptyContextObject)) {
1782 {
1783 throw ReactError('Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.');
1784 }
1785 }
1786 })();
1787
1788 push(contextStackCursor, context, fiber);
1789 push(didPerformWorkStackCursor, didChange, fiber);
1790}
1791
1792function processChildContext(fiber, type, parentContext) {
1793 var instance = fiber.stateNode;
1794 var childContextTypes = type.childContextTypes;
1795
1796 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
1797 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
1798 if (typeof instance.getChildContext !== 'function') {
1799 {
1800 var componentName = getComponentName(type) || 'Unknown';
1801
1802 if (!warnedAboutMissingGetChildContext[componentName]) {
1803 warnedAboutMissingGetChildContext[componentName] = true;
1804 warningWithoutStack$1(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
1805 }
1806 }
1807 return parentContext;
1808 }
1809
1810 var childContext = void 0;
1811 {
1812 setCurrentPhase('getChildContext');
1813 }
1814 startPhaseTimer(fiber, 'getChildContext');
1815 childContext = instance.getChildContext();
1816 stopPhaseTimer();
1817 {
1818 setCurrentPhase(null);
1819 }
1820 for (var contextKey in childContext) {
1821 (function () {
1822 if (!(contextKey in childContextTypes)) {
1823 {
1824 throw ReactError((getComponentName(type) || 'Unknown') + '.getChildContext(): key "' + contextKey + '" is not defined in childContextTypes.');
1825 }
1826 }
1827 })();
1828 }
1829 {
1830 var name = getComponentName(type) || 'Unknown';
1831 checkPropTypes(childContextTypes, childContext, 'child context', name,
1832 // In practice, there is one case in which we won't get a stack. It's when
1833 // somebody calls unstable_renderSubtreeIntoContainer() and we process
1834 // context from the parent component instance. The stack will be missing
1835 // because it's outside of the reconciliation, and so the pointer has not
1836 // been set. This is rare and doesn't matter. We'll also remove that API.
1837 getCurrentFiberStackInDev);
1838 }
1839
1840 return _assign({}, parentContext, childContext);
1841}
1842
1843function pushContextProvider(workInProgress) {
1844 var instance = workInProgress.stateNode;
1845 // We push the context as early as possible to ensure stack integrity.
1846 // If the instance does not exist yet, we will push null at first,
1847 // and replace it on the stack later when invalidating the context.
1848 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
1849
1850 // Remember the parent context so we can merge with it later.
1851 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
1852 previousContext = contextStackCursor.current;
1853 push(contextStackCursor, memoizedMergedChildContext, workInProgress);
1854 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
1855
1856 return true;
1857}
1858
1859function invalidateContextProvider(workInProgress, type, didChange) {
1860 var instance = workInProgress.stateNode;
1861 (function () {
1862 if (!instance) {
1863 {
1864 throw ReactError('Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.');
1865 }
1866 }
1867 })();
1868
1869 if (didChange) {
1870 // Merge parent and own context.
1871 // Skip this if we're not updating due to sCU.
1872 // This avoids unnecessarily recomputing memoized values.
1873 var mergedContext = processChildContext(workInProgress, type, previousContext);
1874 instance.__reactInternalMemoizedMergedChildContext = mergedContext;
1875
1876 // Replace the old (or empty) context with the new one.
1877 // It is important to unwind the context in the reverse order.
1878 pop(didPerformWorkStackCursor, workInProgress);
1879 pop(contextStackCursor, workInProgress);
1880 // Now push the new context and mark that it has changed.
1881 push(contextStackCursor, mergedContext, workInProgress);
1882 push(didPerformWorkStackCursor, didChange, workInProgress);
1883 } else {
1884 pop(didPerformWorkStackCursor, workInProgress);
1885 push(didPerformWorkStackCursor, didChange, workInProgress);
1886 }
1887}
1888
1889function findCurrentUnmaskedContext(fiber) {
1890 // Currently this is only used with renderSubtreeIntoContainer; not sure if it
1891 // makes sense elsewhere
1892 (function () {
1893 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
1894 {
1895 throw ReactError('Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.');
1896 }
1897 }
1898 })();
1899
1900 var node = fiber;
1901 do {
1902 switch (node.tag) {
1903 case HostRoot:
1904 return node.stateNode.context;
1905 case ClassComponent:
1906 {
1907 var Component = node.type;
1908 if (isContextProvider(Component)) {
1909 return node.stateNode.__reactInternalMemoizedMergedChildContext;
1910 }
1911 break;
1912 }
1913 }
1914 node = node.return;
1915 } while (node !== null);
1916 (function () {
1917 {
1918 {
1919 throw ReactError('Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.');
1920 }
1921 }
1922 })();
1923}
1924
1925var onCommitFiberRoot = null;
1926var onCommitFiberUnmount = null;
1927var hasLoggedError = false;
1928
1929function catchErrors(fn) {
1930 return function (arg) {
1931 try {
1932 return fn(arg);
1933 } catch (err) {
1934 if (true && !hasLoggedError) {
1935 hasLoggedError = true;
1936 warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
1937 }
1938 }
1939 };
1940}
1941
1942var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
1943
1944function injectInternals(internals) {
1945 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
1946 // No DevTools
1947 return false;
1948 }
1949 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
1950 if (hook.isDisabled) {
1951 // This isn't a real property on the hook, but it can be set to opt out
1952 // of DevTools integration and associated warnings and logs.
1953 // https://github.com/facebook/react/issues/3877
1954 return true;
1955 }
1956 if (!hook.supportsFiber) {
1957 {
1958 warningWithoutStack$1(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
1959 }
1960 // DevTools exists, even though it doesn't support Fiber.
1961 return true;
1962 }
1963 try {
1964 var rendererID = hook.inject(internals);
1965 // We have successfully injected, so now it is safe to set up hooks.
1966 onCommitFiberRoot = catchErrors(function (root) {
1967 return hook.onCommitFiberRoot(rendererID, root);
1968 });
1969 onCommitFiberUnmount = catchErrors(function (fiber) {
1970 return hook.onCommitFiberUnmount(rendererID, fiber);
1971 });
1972 } catch (err) {
1973 // Catch all errors because it is unsafe to throw during initialization.
1974 {
1975 warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
1976 }
1977 }
1978 // DevTools exists
1979 return true;
1980}
1981
1982function onCommitRoot(root) {
1983 if (typeof onCommitFiberRoot === 'function') {
1984 onCommitFiberRoot(root);
1985 }
1986}
1987
1988function onCommitUnmount(fiber) {
1989 if (typeof onCommitFiberUnmount === 'function') {
1990 onCommitFiberUnmount(fiber);
1991 }
1992}
1993
1994// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
1995// Math.pow(2, 30) - 1
1996// 0b111111111111111111111111111111
1997var maxSigned31BitInt = 1073741823;
1998
1999// Intentionally not named imports because Rollup would use dynamic dispatch for
2000// CommonJS interop named imports.
2001var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority;
2002var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback;
2003var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback;
2004var Scheduler_shouldYield = Scheduler.unstable_shouldYield;
2005var Scheduler_now = Scheduler.unstable_now;
2006var Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
2007var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority;
2008var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
2009var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority;
2010var Scheduler_LowPriority = Scheduler.unstable_LowPriority;
2011var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
2012
2013
2014var fakeCallbackNode = {};
2015
2016// Except for NoPriority, these correspond to Scheduler priorities. We use
2017// ascending numbers so we can compare them like numbers. They start at 90 to
2018// avoid clashing with Scheduler's priorities.
2019var ImmediatePriority = 99;
2020var UserBlockingPriority = 98;
2021var NormalPriority = 97;
2022var LowPriority = 96;
2023var IdlePriority = 95;
2024// NoPriority is the absence of priority. Also React-only.
2025
2026
2027var now$1 = Scheduler_now;
2028var shouldYield$1 = disableYielding ? function () {
2029 return false;
2030} // Never yield when `disableYielding` is on
2031: Scheduler_shouldYield;
2032
2033var immediateQueue = null;
2034var immediateQueueCallbackNode = null;
2035var isFlushingImmediate = false;
2036
2037function getCurrentPriorityLevel() {
2038 switch (Scheduler_getCurrentPriorityLevel()) {
2039 case Scheduler_ImmediatePriority:
2040 return ImmediatePriority;
2041 case Scheduler_UserBlockingPriority:
2042 return UserBlockingPriority;
2043 case Scheduler_NormalPriority:
2044 return NormalPriority;
2045 case Scheduler_LowPriority:
2046 return LowPriority;
2047 case Scheduler_IdlePriority:
2048 return IdlePriority;
2049 default:
2050 (function () {
2051 {
2052 {
2053 throw ReactError('Unknown priority level.');
2054 }
2055 }
2056 })();
2057 }
2058}
2059
2060function reactPriorityToSchedulerPriority(reactPriorityLevel) {
2061 switch (reactPriorityLevel) {
2062 case ImmediatePriority:
2063 return Scheduler_ImmediatePriority;
2064 case UserBlockingPriority:
2065 return Scheduler_UserBlockingPriority;
2066 case NormalPriority:
2067 return Scheduler_NormalPriority;
2068 case LowPriority:
2069 return Scheduler_LowPriority;
2070 case IdlePriority:
2071 return Scheduler_IdlePriority;
2072 default:
2073 (function () {
2074 {
2075 {
2076 throw ReactError('Unknown priority level.');
2077 }
2078 }
2079 })();
2080 }
2081}
2082
2083function runWithPriority(reactPriorityLevel, fn) {
2084 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
2085 return Scheduler_runWithPriority(priorityLevel, fn);
2086}
2087
2088function scheduleCallback(reactPriorityLevel, callback, options) {
2089 if (reactPriorityLevel === ImmediatePriority) {
2090 // Push this callback into an internal queue. We'll flush these either in
2091 // the next tick, or earlier if something calls `flushImmediateQueue`.
2092 if (immediateQueue === null) {
2093 immediateQueue = [callback];
2094 // Flush the queue in the next tick, at the earliest.
2095 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushImmediateQueueImpl);
2096 } else {
2097 // Push onto existing queue. Don't need to schedule a callback because
2098 // we already scheduled one when we created the queue.
2099 immediateQueue.push(callback);
2100 }
2101 return fakeCallbackNode;
2102 }
2103 // Otherwise pass through to Scheduler.
2104 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
2105 return Scheduler_scheduleCallback(priorityLevel, callback, options);
2106}
2107
2108function cancelCallback(callbackNode) {
2109 if (callbackNode !== fakeCallbackNode) {
2110 Scheduler_cancelCallback(callbackNode);
2111 }
2112}
2113
2114function flushImmediateQueue() {
2115 if (immediateQueueCallbackNode !== null) {
2116 Scheduler_cancelCallback(immediateQueueCallbackNode);
2117 }
2118 flushImmediateQueueImpl();
2119}
2120
2121function flushImmediateQueueImpl() {
2122 if (!isFlushingImmediate && immediateQueue !== null) {
2123 // Prevent re-entrancy.
2124 isFlushingImmediate = true;
2125 var i = 0;
2126 try {
2127 var _isSync = true;
2128 for (; i < immediateQueue.length; i++) {
2129 var callback = immediateQueue[i];
2130 do {
2131 callback = callback(_isSync);
2132 } while (callback !== null);
2133 }
2134 immediateQueue = null;
2135 } catch (error) {
2136 // If something throws, leave the remaining callbacks on the queue.
2137 if (immediateQueue !== null) {
2138 immediateQueue = immediateQueue.slice(i + 1);
2139 }
2140 // Resume flushing in the next tick
2141 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushImmediateQueue);
2142 throw error;
2143 } finally {
2144 isFlushingImmediate = false;
2145 }
2146 }
2147}
2148
2149var NoWork = 0;
2150var Never = 1;
2151var Sync = maxSigned31BitInt;
2152
2153var UNIT_SIZE = 10;
2154var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1;
2155
2156// 1 unit of expiration time represents 10ms.
2157function msToExpirationTime(ms) {
2158 // Always add an offset so that we don't clash with the magic number for NoWork.
2159 return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
2160}
2161
2162function expirationTimeToMs(expirationTime) {
2163 return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
2164}
2165
2166function ceiling(num, precision) {
2167 return ((num / precision | 0) + 1) * precision;
2168}
2169
2170function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
2171 return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
2172}
2173
2174// TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
2175// the names to reflect.
2176var LOW_PRIORITY_EXPIRATION = 5000;
2177var LOW_PRIORITY_BATCH_SIZE = 250;
2178
2179function computeAsyncExpiration(currentTime) {
2180 return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
2181}
2182
2183// We intentionally set a higher expiration time for interactive updates in
2184// dev than in production.
2185//
2186// If the main thread is being blocked so long that you hit the expiration,
2187// it's a problem that could be solved with better scheduling.
2188//
2189// People will be more likely to notice this and fix it with the long
2190// expiration time in development.
2191//
2192// In production we opt for better UX at the risk of masking scheduling
2193// problems, by expiring fast.
2194var HIGH_PRIORITY_EXPIRATION = 500;
2195var HIGH_PRIORITY_BATCH_SIZE = 100;
2196
2197function computeInteractiveExpiration(currentTime) {
2198 return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
2199}
2200
2201function inferPriorityFromExpirationTime(currentTime, expirationTime) {
2202 if (expirationTime === Sync) {
2203 return ImmediatePriority;
2204 }
2205 if (expirationTime === Never) {
2206 return IdlePriority;
2207 }
2208 var msUntil = msToExpirationTime(expirationTime) - msToExpirationTime(currentTime);
2209 if (msUntil <= 0) {
2210 return ImmediatePriority;
2211 }
2212 if (msUntil <= HIGH_PRIORITY_EXPIRATION) {
2213 return UserBlockingPriority;
2214 }
2215 if (msUntil <= LOW_PRIORITY_EXPIRATION) {
2216 return NormalPriority;
2217 }
2218
2219 // TODO: Handle LowPriority
2220
2221 // Assume anything lower has idle priority
2222 return IdlePriority;
2223}
2224
2225var NoContext = 0;
2226var ConcurrentMode = 1;
2227var StrictMode = 2;
2228var ProfileMode = 4;
2229
2230var hasBadMapPolyfill = void 0;
2231
2232{
2233 hasBadMapPolyfill = false;
2234 try {
2235 var nonExtensibleObject = Object.preventExtensions({});
2236 var testMap = new Map([[nonExtensibleObject, null]]);
2237 var testSet = new Set([nonExtensibleObject]);
2238 // This is necessary for Rollup to not consider these unused.
2239 // https://github.com/rollup/rollup/issues/1771
2240 // TODO: we can remove these if Rollup fixes the bug.
2241 testMap.set(0, 0);
2242 testSet.add(0);
2243 } catch (e) {
2244 // TODO: Consider warning about bad polyfills
2245 hasBadMapPolyfill = true;
2246 }
2247}
2248
2249// A Fiber is work on a Component that needs to be done or was done. There can
2250// be more than one per component.
2251
2252
2253var debugCounter = void 0;
2254
2255{
2256 debugCounter = 1;
2257}
2258
2259function FiberNode(tag, pendingProps, key, mode) {
2260 // Instance
2261 this.tag = tag;
2262 this.key = key;
2263 this.elementType = null;
2264 this.type = null;
2265 this.stateNode = null;
2266
2267 // Fiber
2268 this.return = null;
2269 this.child = null;
2270 this.sibling = null;
2271 this.index = 0;
2272
2273 this.ref = null;
2274
2275 this.pendingProps = pendingProps;
2276 this.memoizedProps = null;
2277 this.updateQueue = null;
2278 this.memoizedState = null;
2279 this.contextDependencies = null;
2280
2281 this.mode = mode;
2282
2283 // Effects
2284 this.effectTag = NoEffect;
2285 this.nextEffect = null;
2286
2287 this.firstEffect = null;
2288 this.lastEffect = null;
2289
2290 this.expirationTime = NoWork;
2291 this.childExpirationTime = NoWork;
2292
2293 this.alternate = null;
2294
2295 if (enableProfilerTimer) {
2296 // Note: The following is done to avoid a v8 performance cliff.
2297 //
2298 // Initializing the fields below to smis and later updating them with
2299 // double values will cause Fibers to end up having separate shapes.
2300 // This behavior/bug has something to do with Object.preventExtension().
2301 // Fortunately this only impacts DEV builds.
2302 // Unfortunately it makes React unusably slow for some applications.
2303 // To work around this, initialize the fields below with doubles.
2304 //
2305 // Learn more about this here:
2306 // https://github.com/facebook/react/issues/14365
2307 // https://bugs.chromium.org/p/v8/issues/detail?id=8538
2308 this.actualDuration = Number.NaN;
2309 this.actualStartTime = Number.NaN;
2310 this.selfBaseDuration = Number.NaN;
2311 this.treeBaseDuration = Number.NaN;
2312
2313 // It's okay to replace the initial doubles with smis after initialization.
2314 // This won't trigger the performance cliff mentioned above,
2315 // and it simplifies other profiler code (including DevTools).
2316 this.actualDuration = 0;
2317 this.actualStartTime = -1;
2318 this.selfBaseDuration = 0;
2319 this.treeBaseDuration = 0;
2320 }
2321
2322 {
2323 this._debugID = debugCounter++;
2324 this._debugSource = null;
2325 this._debugOwner = null;
2326 this._debugIsCurrentlyTiming = false;
2327 this._debugHookTypes = null;
2328 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
2329 Object.preventExtensions(this);
2330 }
2331 }
2332}
2333
2334// This is a constructor function, rather than a POJO constructor, still
2335// please ensure we do the following:
2336// 1) Nobody should add any instance methods on this. Instance methods can be
2337// more difficult to predict when they get optimized and they are almost
2338// never inlined properly in static compilers.
2339// 2) Nobody should rely on `instanceof Fiber` for type testing. We should
2340// always know when it is a fiber.
2341// 3) We might want to experiment with using numeric keys since they are easier
2342// to optimize in a non-JIT environment.
2343// 4) We can easily go from a constructor to a createFiber object literal if that
2344// is faster.
2345// 5) It should be easy to port this to a C struct and keep a C implementation
2346// compatible.
2347var createFiber = function (tag, pendingProps, key, mode) {
2348 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
2349 return new FiberNode(tag, pendingProps, key, mode);
2350};
2351
2352function shouldConstruct(Component) {
2353 var prototype = Component.prototype;
2354 return !!(prototype && prototype.isReactComponent);
2355}
2356
2357function isSimpleFunctionComponent(type) {
2358 return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
2359}
2360
2361function resolveLazyComponentTag(Component) {
2362 if (typeof Component === 'function') {
2363 return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
2364 } else if (Component !== undefined && Component !== null) {
2365 var $$typeof = Component.$$typeof;
2366 if ($$typeof === REACT_FORWARD_REF_TYPE) {
2367 return ForwardRef;
2368 }
2369 if ($$typeof === REACT_MEMO_TYPE) {
2370 return MemoComponent;
2371 }
2372 }
2373 return IndeterminateComponent;
2374}
2375
2376// This is used to create an alternate fiber to do work on.
2377function createWorkInProgress(current, pendingProps, expirationTime) {
2378 var workInProgress = current.alternate;
2379 if (workInProgress === null) {
2380 // We use a double buffering pooling technique because we know that we'll
2381 // only ever need at most two versions of a tree. We pool the "other" unused
2382 // node that we're free to reuse. This is lazily created to avoid allocating
2383 // extra objects for things that are never updated. It also allow us to
2384 // reclaim the extra memory if needed.
2385 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
2386 workInProgress.elementType = current.elementType;
2387 workInProgress.type = current.type;
2388 workInProgress.stateNode = current.stateNode;
2389
2390 {
2391 // DEV-only fields
2392 workInProgress._debugID = current._debugID;
2393 workInProgress._debugSource = current._debugSource;
2394 workInProgress._debugOwner = current._debugOwner;
2395 workInProgress._debugHookTypes = current._debugHookTypes;
2396 }
2397
2398 workInProgress.alternate = current;
2399 current.alternate = workInProgress;
2400 } else {
2401 workInProgress.pendingProps = pendingProps;
2402
2403 // We already have an alternate.
2404 // Reset the effect tag.
2405 workInProgress.effectTag = NoEffect;
2406
2407 // The effect list is no longer valid.
2408 workInProgress.nextEffect = null;
2409 workInProgress.firstEffect = null;
2410 workInProgress.lastEffect = null;
2411
2412 if (enableProfilerTimer) {
2413 // We intentionally reset, rather than copy, actualDuration & actualStartTime.
2414 // This prevents time from endlessly accumulating in new commits.
2415 // This has the downside of resetting values for different priority renders,
2416 // But works for yielding (the common case) and should support resuming.
2417 workInProgress.actualDuration = 0;
2418 workInProgress.actualStartTime = -1;
2419 }
2420 }
2421
2422 workInProgress.childExpirationTime = current.childExpirationTime;
2423 workInProgress.expirationTime = current.expirationTime;
2424
2425 workInProgress.child = current.child;
2426 workInProgress.memoizedProps = current.memoizedProps;
2427 workInProgress.memoizedState = current.memoizedState;
2428 workInProgress.updateQueue = current.updateQueue;
2429 workInProgress.contextDependencies = current.contextDependencies;
2430
2431 // These will be overridden during the parent's reconciliation
2432 workInProgress.sibling = current.sibling;
2433 workInProgress.index = current.index;
2434 workInProgress.ref = current.ref;
2435
2436 if (enableProfilerTimer) {
2437 workInProgress.selfBaseDuration = current.selfBaseDuration;
2438 workInProgress.treeBaseDuration = current.treeBaseDuration;
2439 }
2440
2441 return workInProgress;
2442}
2443
2444function createHostRootFiber(isConcurrent) {
2445 var mode = isConcurrent ? ConcurrentMode | StrictMode : NoContext;
2446
2447 if (enableProfilerTimer && isDevToolsPresent) {
2448 // Always collect profile timings when DevTools are present.
2449 // This enables DevTools to start capturing timing at any point–
2450 // Without some nodes in the tree having empty base times.
2451 mode |= ProfileMode;
2452 }
2453
2454 return createFiber(HostRoot, null, null, mode);
2455}
2456
2457function createFiberFromTypeAndProps(type, // React$ElementType
2458key, pendingProps, owner, mode, expirationTime) {
2459 var fiber = void 0;
2460
2461 var fiberTag = IndeterminateComponent;
2462 // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
2463 var resolvedType = type;
2464 if (typeof type === 'function') {
2465 if (shouldConstruct(type)) {
2466 fiberTag = ClassComponent;
2467 }
2468 } else if (typeof type === 'string') {
2469 fiberTag = HostComponent;
2470 } else {
2471 getTag: switch (type) {
2472 case REACT_FRAGMENT_TYPE:
2473 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
2474 case REACT_CONCURRENT_MODE_TYPE:
2475 return createFiberFromMode(pendingProps, mode | ConcurrentMode | StrictMode, expirationTime, key);
2476 case REACT_STRICT_MODE_TYPE:
2477 return createFiberFromMode(pendingProps, mode | StrictMode, expirationTime, key);
2478 case REACT_PROFILER_TYPE:
2479 return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
2480 case REACT_SUSPENSE_TYPE:
2481 return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
2482 default:
2483 {
2484 if (typeof type === 'object' && type !== null) {
2485 switch (type.$$typeof) {
2486 case REACT_PROVIDER_TYPE:
2487 fiberTag = ContextProvider;
2488 break getTag;
2489 case REACT_CONTEXT_TYPE:
2490 // This is a consumer
2491 fiberTag = ContextConsumer;
2492 break getTag;
2493 case REACT_FORWARD_REF_TYPE:
2494 fiberTag = ForwardRef;
2495 break getTag;
2496 case REACT_MEMO_TYPE:
2497 fiberTag = MemoComponent;
2498 break getTag;
2499 case REACT_LAZY_TYPE:
2500 fiberTag = LazyComponent;
2501 resolvedType = null;
2502 break getTag;
2503 case REACT_EVENT_COMPONENT_TYPE:
2504 if (enableEventAPI) {
2505 return createFiberFromEventComponent(type, pendingProps, mode, expirationTime, key);
2506 }
2507 break;
2508 case REACT_EVENT_TARGET_TYPE:
2509 if (enableEventAPI) {
2510 return createFiberFromEventTarget(type, pendingProps, mode, expirationTime, key);
2511 }
2512 break;
2513 }
2514 }
2515 var info = '';
2516 {
2517 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2518 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.';
2519 }
2520 var ownerName = owner ? getComponentName(owner.type) : null;
2521 if (ownerName) {
2522 info += '\n\nCheck the render method of `' + ownerName + '`.';
2523 }
2524 }
2525 (function () {
2526 {
2527 {
2528 throw ReactError('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);
2529 }
2530 }
2531 })();
2532 }
2533 }
2534 }
2535
2536 fiber = createFiber(fiberTag, pendingProps, key, mode);
2537 fiber.elementType = type;
2538 fiber.type = resolvedType;
2539 fiber.expirationTime = expirationTime;
2540
2541 return fiber;
2542}
2543
2544function createFiberFromElement(element, mode, expirationTime) {
2545 var owner = null;
2546 {
2547 owner = element._owner;
2548 }
2549 var type = element.type;
2550 var key = element.key;
2551 var pendingProps = element.props;
2552 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
2553 {
2554 fiber._debugSource = element._source;
2555 fiber._debugOwner = element._owner;
2556 }
2557 return fiber;
2558}
2559
2560function createFiberFromFragment(elements, mode, expirationTime, key) {
2561 var fiber = createFiber(Fragment, elements, key, mode);
2562 fiber.expirationTime = expirationTime;
2563 return fiber;
2564}
2565
2566function createFiberFromEventComponent(eventComponent, pendingProps, mode, expirationTime, key) {
2567 var fiber = createFiber(EventComponent, pendingProps, key, mode);
2568 fiber.elementType = eventComponent;
2569 fiber.type = eventComponent;
2570 fiber.stateNode = {
2571 props: pendingProps,
2572 state: null
2573 };
2574 fiber.expirationTime = expirationTime;
2575 return fiber;
2576}
2577
2578function createFiberFromEventTarget(eventTarget, pendingProps, mode, expirationTime, key) {
2579 var fiber = createFiber(EventTarget, pendingProps, key, mode);
2580 fiber.elementType = eventTarget;
2581 fiber.type = eventTarget;
2582 fiber.expirationTime = expirationTime;
2583 return fiber;
2584}
2585
2586function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
2587 {
2588 if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
2589 warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
2590 }
2591 }
2592
2593 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
2594 // TODO: The Profiler fiber shouldn't have a type. It has a tag.
2595 fiber.elementType = REACT_PROFILER_TYPE;
2596 fiber.type = REACT_PROFILER_TYPE;
2597 fiber.expirationTime = expirationTime;
2598
2599 return fiber;
2600}
2601
2602function createFiberFromMode(pendingProps, mode, expirationTime, key) {
2603 var fiber = createFiber(Mode$1, pendingProps, key, mode);
2604
2605 // TODO: The Mode fiber shouldn't have a type. It has a tag.
2606 var type = (mode & ConcurrentMode) === NoContext ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE;
2607 fiber.elementType = type;
2608 fiber.type = type;
2609
2610 fiber.expirationTime = expirationTime;
2611 return fiber;
2612}
2613
2614function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
2615 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
2616
2617 // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
2618 var type = REACT_SUSPENSE_TYPE;
2619 fiber.elementType = type;
2620 fiber.type = type;
2621
2622 fiber.expirationTime = expirationTime;
2623 return fiber;
2624}
2625
2626function createFiberFromText(content, mode, expirationTime) {
2627 var fiber = createFiber(HostText, content, null, mode);
2628 fiber.expirationTime = expirationTime;
2629 return fiber;
2630}
2631
2632function createFiberFromHostInstanceForDeletion() {
2633 var fiber = createFiber(HostComponent, null, null, NoContext);
2634 // TODO: These should not need a type.
2635 fiber.elementType = 'DELETED';
2636 fiber.type = 'DELETED';
2637 return fiber;
2638}
2639
2640function createFiberFromPortal(portal, mode, expirationTime) {
2641 var pendingProps = portal.children !== null ? portal.children : [];
2642 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
2643 fiber.expirationTime = expirationTime;
2644 fiber.stateNode = {
2645 containerInfo: portal.containerInfo,
2646 pendingChildren: null, // Used by persistent updates
2647 implementation: portal.implementation
2648 };
2649 return fiber;
2650}
2651
2652// Used for stashing WIP properties to replay failed work in DEV.
2653function assignFiberPropertiesInDEV(target, source) {
2654 if (target === null) {
2655 // This Fiber's initial properties will always be overwritten.
2656 // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
2657 target = createFiber(IndeterminateComponent, null, null, NoContext);
2658 }
2659
2660 // This is intentionally written as a list of all properties.
2661 // We tried to use Object.assign() instead but this is called in
2662 // the hottest path, and Object.assign() was too slow:
2663 // https://github.com/facebook/react/issues/12502
2664 // This code is DEV-only so size is not a concern.
2665
2666 target.tag = source.tag;
2667 target.key = source.key;
2668 target.elementType = source.elementType;
2669 target.type = source.type;
2670 target.stateNode = source.stateNode;
2671 target.return = source.return;
2672 target.child = source.child;
2673 target.sibling = source.sibling;
2674 target.index = source.index;
2675 target.ref = source.ref;
2676 target.pendingProps = source.pendingProps;
2677 target.memoizedProps = source.memoizedProps;
2678 target.updateQueue = source.updateQueue;
2679 target.memoizedState = source.memoizedState;
2680 target.contextDependencies = source.contextDependencies;
2681 target.mode = source.mode;
2682 target.effectTag = source.effectTag;
2683 target.nextEffect = source.nextEffect;
2684 target.firstEffect = source.firstEffect;
2685 target.lastEffect = source.lastEffect;
2686 target.expirationTime = source.expirationTime;
2687 target.childExpirationTime = source.childExpirationTime;
2688 target.alternate = source.alternate;
2689 if (enableProfilerTimer) {
2690 target.actualDuration = source.actualDuration;
2691 target.actualStartTime = source.actualStartTime;
2692 target.selfBaseDuration = source.selfBaseDuration;
2693 target.treeBaseDuration = source.treeBaseDuration;
2694 }
2695 target._debugID = source._debugID;
2696 target._debugSource = source._debugSource;
2697 target._debugOwner = source._debugOwner;
2698 target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
2699 target._debugHookTypes = source._debugHookTypes;
2700 return target;
2701}
2702
2703// TODO: This should be lifted into the renderer.
2704
2705
2706// The following attributes are only used by interaction tracing builds.
2707// They enable interactions to be associated with their async work,
2708// And expose interaction metadata to the React DevTools Profiler plugin.
2709// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled.
2710
2711
2712// Exported FiberRoot type includes all properties,
2713// To avoid requiring potentially error-prone :any casts throughout the project.
2714// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true).
2715// The types are defined separately within this file to ensure they stay in sync.
2716// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
2717
2718
2719function FiberRootNode(containerInfo, hydrate) {
2720 this.current = null;
2721 this.containerInfo = containerInfo;
2722 this.pendingChildren = null;
2723 this.pingCache = null;
2724 this.pendingCommitExpirationTime = NoWork;
2725 this.finishedWork = null;
2726 this.timeoutHandle = noTimeout;
2727 this.context = null;
2728 this.pendingContext = null;
2729 this.hydrate = hydrate;
2730 this.firstBatch = null;
2731
2732 if (enableNewScheduler) {
2733 this.callbackNode = null;
2734 this.callbackExpirationTime = NoWork;
2735 this.firstPendingTime = NoWork;
2736 this.lastPendingTime = NoWork;
2737 this.pingTime = NoWork;
2738 } else {
2739 this.earliestPendingTime = NoWork;
2740 this.latestPendingTime = NoWork;
2741 this.earliestSuspendedTime = NoWork;
2742 this.latestSuspendedTime = NoWork;
2743 this.latestPingedTime = NoWork;
2744 this.didError = false;
2745 this.nextExpirationTimeToWorkOn = NoWork;
2746 this.expirationTime = NoWork;
2747 this.nextScheduledRoot = null;
2748 }
2749
2750 if (enableSchedulerTracing) {
2751 this.interactionThreadID = tracing.unstable_getThreadID();
2752 this.memoizedInteractions = new Set();
2753 this.pendingInteractionMap = new Map();
2754 }
2755}
2756
2757function createFiberRoot(containerInfo, isConcurrent, hydrate) {
2758 var root = new FiberRootNode(containerInfo, hydrate);
2759
2760 // Cyclic construction. This cheats the type system right now because
2761 // stateNode is any.
2762 var uninitializedFiber = createHostRootFiber(isConcurrent);
2763 root.current = uninitializedFiber;
2764 uninitializedFiber.stateNode = root;
2765
2766 return root;
2767}
2768
2769var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
2770 var funcArgs = Array.prototype.slice.call(arguments, 3);
2771 try {
2772 func.apply(context, funcArgs);
2773 } catch (error) {
2774 this.onError(error);
2775 }
2776};
2777
2778{
2779 // In DEV mode, we swap out invokeGuardedCallback for a special version
2780 // that plays more nicely with the browser's DevTools. The idea is to preserve
2781 // "Pause on exceptions" behavior. Because React wraps all user-provided
2782 // functions in invokeGuardedCallback, and the production version of
2783 // invokeGuardedCallback uses a try-catch, all user exceptions are treated
2784 // like caught exceptions, and the DevTools won't pause unless the developer
2785 // takes the extra step of enabling pause on caught exceptions. This is
2786 // unintuitive, though, because even though React has caught the error, from
2787 // the developer's perspective, the error is uncaught.
2788 //
2789 // To preserve the expected "Pause on exceptions" behavior, we don't use a
2790 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
2791 // DOM node, and call the user-provided callback from inside an event handler
2792 // for that fake event. If the callback throws, the error is "captured" using
2793 // a global event handler. But because the error happens in a different
2794 // event loop context, it does not interrupt the normal program flow.
2795 // Effectively, this gives us try-catch behavior without actually using
2796 // try-catch. Neat!
2797
2798 // Check that the browser supports the APIs we need to implement our special
2799 // DEV version of invokeGuardedCallback
2800 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
2801 var fakeNode = document.createElement('react');
2802
2803 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
2804 // If document doesn't exist we know for sure we will crash in this method
2805 // when we call document.createEvent(). However this can cause confusing
2806 // errors: https://github.com/facebookincubator/create-react-app/issues/3482
2807 // So we preemptively throw with a better message instead.
2808 (function () {
2809 if (!(typeof document !== 'undefined')) {
2810 {
2811 throw ReactError('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.');
2812 }
2813 }
2814 })();
2815 var evt = document.createEvent('Event');
2816
2817 // Keeps track of whether the user-provided callback threw an error. We
2818 // set this to true at the beginning, then set it to false right after
2819 // calling the function. If the function errors, `didError` will never be
2820 // set to false. This strategy works even if the browser is flaky and
2821 // fails to call our global error handler, because it doesn't rely on
2822 // the error event at all.
2823 var didError = true;
2824
2825 // Keeps track of the value of window.event so that we can reset it
2826 // during the callback to let user code access window.event in the
2827 // browsers that support it.
2828 var windowEvent = window.event;
2829
2830 // Keeps track of the descriptor of window.event to restore it after event
2831 // dispatching: https://github.com/facebook/react/issues/13688
2832 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
2833
2834 // Create an event handler for our fake event. We will synchronously
2835 // dispatch our fake event using `dispatchEvent`. Inside the handler, we
2836 // call the user-provided callback.
2837 var funcArgs = Array.prototype.slice.call(arguments, 3);
2838 function callCallback() {
2839 // We immediately remove the callback from event listeners so that
2840 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
2841 // nested call would trigger the fake event handlers of any call higher
2842 // in the stack.
2843 fakeNode.removeEventListener(evtType, callCallback, false);
2844
2845 // We check for window.hasOwnProperty('event') to prevent the
2846 // window.event assignment in both IE <= 10 as they throw an error
2847 // "Member not found" in strict mode, and in Firefox which does not
2848 // support window.event.
2849 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
2850 window.event = windowEvent;
2851 }
2852
2853 func.apply(context, funcArgs);
2854 didError = false;
2855 }
2856
2857 // Create a global error event handler. We use this to capture the value
2858 // that was thrown. It's possible that this error handler will fire more
2859 // than once; for example, if non-React code also calls `dispatchEvent`
2860 // and a handler for that event throws. We should be resilient to most of
2861 // those cases. Even if our error event handler fires more than once, the
2862 // last error event is always used. If the callback actually does error,
2863 // we know that the last error event is the correct one, because it's not
2864 // possible for anything else to have happened in between our callback
2865 // erroring and the code that follows the `dispatchEvent` call below. If
2866 // the callback doesn't error, but the error event was fired, we know to
2867 // ignore it because `didError` will be false, as described above.
2868 var error = void 0;
2869 // Use this to track whether the error event is ever called.
2870 var didSetError = false;
2871 var isCrossOriginError = false;
2872
2873 function handleWindowError(event) {
2874 error = event.error;
2875 didSetError = true;
2876 if (error === null && event.colno === 0 && event.lineno === 0) {
2877 isCrossOriginError = true;
2878 }
2879 if (event.defaultPrevented) {
2880 // Some other error handler has prevented default.
2881 // Browsers silence the error report if this happens.
2882 // We'll remember this to later decide whether to log it or not.
2883 if (error != null && typeof error === 'object') {
2884 try {
2885 error._suppressLogging = true;
2886 } catch (inner) {
2887 // Ignore.
2888 }
2889 }
2890 }
2891 }
2892
2893 // Create a fake event type.
2894 var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
2895
2896 // Attach our event handlers
2897 window.addEventListener('error', handleWindowError);
2898 fakeNode.addEventListener(evtType, callCallback, false);
2899
2900 // Synchronously dispatch our fake event. If the user-provided function
2901 // errors, it will trigger our global error handler.
2902 evt.initEvent(evtType, false, false);
2903 fakeNode.dispatchEvent(evt);
2904
2905 if (windowEventDescriptor) {
2906 Object.defineProperty(window, 'event', windowEventDescriptor);
2907 }
2908
2909 if (didError) {
2910 if (!didSetError) {
2911 // The callback errored, but the error event never fired.
2912 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.');
2913 } else if (isCrossOriginError) {
2914 error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
2915 }
2916 this.onError(error);
2917 }
2918
2919 // Remove our event listeners
2920 window.removeEventListener('error', handleWindowError);
2921 };
2922
2923 invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
2924 }
2925}
2926
2927var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
2928
2929// Used by Fiber to simulate a try-catch.
2930var hasError = false;
2931var caughtError = null;
2932
2933var reporter = {
2934 onError: function (error) {
2935 hasError = true;
2936 caughtError = error;
2937 }
2938};
2939
2940/**
2941 * Call a function while guarding against errors that happens within it.
2942 * Returns an error if it throws, otherwise null.
2943 *
2944 * In production, this is implemented using a try-catch. The reason we don't
2945 * use a try-catch directly is so that we can swap out a different
2946 * implementation in DEV mode.
2947 *
2948 * @param {String} name of the guard to use for logging or debugging
2949 * @param {Function} func The function to invoke
2950 * @param {*} context The context to use when calling the function
2951 * @param {...*} args Arguments for function
2952 */
2953function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
2954 hasError = false;
2955 caughtError = null;
2956 invokeGuardedCallbackImpl$1.apply(reporter, arguments);
2957}
2958
2959/**
2960 * Same as invokeGuardedCallback, but instead of returning an error, it stores
2961 * it in a global so it can be rethrown by `rethrowCaughtError` later.
2962 * TODO: See if caughtError and rethrowError can be unified.
2963 *
2964 * @param {String} name of the guard to use for logging or debugging
2965 * @param {Function} func The function to invoke
2966 * @param {*} context The context to use when calling the function
2967 * @param {...*} args Arguments for function
2968 */
2969
2970
2971/**
2972 * During execution of guarded functions we will capture the first error which
2973 * we will rethrow to be handled by the top level error handler.
2974 */
2975
2976
2977function hasCaughtError() {
2978 return hasError;
2979}
2980
2981function clearCaughtError() {
2982 if (hasError) {
2983 var error = caughtError;
2984 hasError = false;
2985 caughtError = null;
2986 return error;
2987 } else {
2988 (function () {
2989 {
2990 {
2991 throw ReactError('clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.');
2992 }
2993 }
2994 })();
2995 }
2996}
2997
2998/**
2999 * Forked from fbjs/warning:
3000 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
3001 *
3002 * Only change is we use console.warn instead of console.error,
3003 * and do nothing when 'console' is not supported.
3004 * This really simplifies the code.
3005 * ---
3006 * Similar to invariant but only logs a warning if the condition is not met.
3007 * This can be used to log issues in development environments in critical
3008 * paths. Removing the logging code for production environments will keep the
3009 * same logic and follow the same code paths.
3010 */
3011
3012var lowPriorityWarning = function () {};
3013
3014{
3015 var printWarning = function (format) {
3016 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
3017 args[_key - 1] = arguments[_key];
3018 }
3019
3020 var argIndex = 0;
3021 var message = 'Warning: ' + format.replace(/%s/g, function () {
3022 return args[argIndex++];
3023 });
3024 if (typeof console !== 'undefined') {
3025 console.warn(message);
3026 }
3027 try {
3028 // --- Welcome to debugging React ---
3029 // This error was thrown as a convenience so that you can use this stack
3030 // to find the callsite that caused this warning to fire.
3031 throw new Error(message);
3032 } catch (x) {}
3033 };
3034
3035 lowPriorityWarning = function (condition, format) {
3036 if (format === undefined) {
3037 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
3038 }
3039 if (!condition) {
3040 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
3041 args[_key2 - 2] = arguments[_key2];
3042 }
3043
3044 printWarning.apply(undefined, [format].concat(args));
3045 }
3046 };
3047}
3048
3049var lowPriorityWarning$1 = lowPriorityWarning;
3050
3051var ReactStrictModeWarnings = {
3052 discardPendingWarnings: function () {},
3053 flushPendingDeprecationWarnings: function () {},
3054 flushPendingUnsafeLifecycleWarnings: function () {},
3055 recordDeprecationWarnings: function (fiber, instance) {},
3056 recordUnsafeLifecycleWarnings: function (fiber, instance) {},
3057 recordLegacyContextWarning: function (fiber, instance) {},
3058 flushLegacyContextWarning: function () {}
3059};
3060
3061{
3062 var LIFECYCLE_SUGGESTIONS = {
3063 UNSAFE_componentWillMount: 'componentDidMount',
3064 UNSAFE_componentWillReceiveProps: 'static getDerivedStateFromProps',
3065 UNSAFE_componentWillUpdate: 'componentDidUpdate'
3066 };
3067
3068 var pendingComponentWillMountWarnings = [];
3069 var pendingComponentWillReceivePropsWarnings = [];
3070 var pendingComponentWillUpdateWarnings = [];
3071 var pendingUnsafeLifecycleWarnings = new Map();
3072 var pendingLegacyContextWarning = new Map();
3073
3074 // Tracks components we have already warned about.
3075 var didWarnAboutDeprecatedLifecycles = new Set();
3076 var didWarnAboutUnsafeLifecycles = new Set();
3077 var didWarnAboutLegacyContext = new Set();
3078
3079 var setToSortedString = function (set) {
3080 var array = [];
3081 set.forEach(function (value) {
3082 array.push(value);
3083 });
3084 return array.sort().join(', ');
3085 };
3086
3087 ReactStrictModeWarnings.discardPendingWarnings = function () {
3088 pendingComponentWillMountWarnings = [];
3089 pendingComponentWillReceivePropsWarnings = [];
3090 pendingComponentWillUpdateWarnings = [];
3091 pendingUnsafeLifecycleWarnings = new Map();
3092 pendingLegacyContextWarning = new Map();
3093 };
3094
3095 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
3096 pendingUnsafeLifecycleWarnings.forEach(function (lifecycleWarningsMap, strictRoot) {
3097 var lifecyclesWarningMessages = [];
3098
3099 Object.keys(lifecycleWarningsMap).forEach(function (lifecycle) {
3100 var lifecycleWarnings = lifecycleWarningsMap[lifecycle];
3101 if (lifecycleWarnings.length > 0) {
3102 var componentNames = new Set();
3103 lifecycleWarnings.forEach(function (fiber) {
3104 componentNames.add(getComponentName(fiber.type) || 'Component');
3105 didWarnAboutUnsafeLifecycles.add(fiber.type);
3106 });
3107
3108 var formatted = lifecycle.replace('UNSAFE_', '');
3109 var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
3110 var sortedComponentNames = setToSortedString(componentNames);
3111
3112 lifecyclesWarningMessages.push(formatted + ': Please update the following components to use ' + (suggestion + ' instead: ' + sortedComponentNames));
3113 }
3114 });
3115
3116 if (lifecyclesWarningMessages.length > 0) {
3117 var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
3118
3119 warningWithoutStack$1(false, 'Unsafe lifecycle methods were found within a strict-mode tree:%s' + '\n\n%s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, lifecyclesWarningMessages.join('\n\n'));
3120 }
3121 });
3122
3123 pendingUnsafeLifecycleWarnings = new Map();
3124 };
3125
3126 var findStrictRoot = function (fiber) {
3127 var maybeStrictRoot = null;
3128
3129 var node = fiber;
3130 while (node !== null) {
3131 if (node.mode & StrictMode) {
3132 maybeStrictRoot = node;
3133 }
3134 node = node.return;
3135 }
3136
3137 return maybeStrictRoot;
3138 };
3139
3140 ReactStrictModeWarnings.flushPendingDeprecationWarnings = function () {
3141 if (pendingComponentWillMountWarnings.length > 0) {
3142 var uniqueNames = new Set();
3143 pendingComponentWillMountWarnings.forEach(function (fiber) {
3144 uniqueNames.add(getComponentName(fiber.type) || 'Component');
3145 didWarnAboutDeprecatedLifecycles.add(fiber.type);
3146 });
3147
3148 var sortedNames = setToSortedString(uniqueNames);
3149
3150 lowPriorityWarning$1(false, 'componentWillMount is deprecated and will be removed in the next major version. ' + 'Use componentDidMount instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillMount.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', sortedNames);
3151
3152 pendingComponentWillMountWarnings = [];
3153 }
3154
3155 if (pendingComponentWillReceivePropsWarnings.length > 0) {
3156 var _uniqueNames = new Set();
3157 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
3158 _uniqueNames.add(getComponentName(fiber.type) || 'Component');
3159 didWarnAboutDeprecatedLifecycles.add(fiber.type);
3160 });
3161
3162 var _sortedNames = setToSortedString(_uniqueNames);
3163
3164 lowPriorityWarning$1(false, 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + 'Use static getDerivedStateFromProps instead.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames);
3165
3166 pendingComponentWillReceivePropsWarnings = [];
3167 }
3168
3169 if (pendingComponentWillUpdateWarnings.length > 0) {
3170 var _uniqueNames2 = new Set();
3171 pendingComponentWillUpdateWarnings.forEach(function (fiber) {
3172 _uniqueNames2.add(getComponentName(fiber.type) || 'Component');
3173 didWarnAboutDeprecatedLifecycles.add(fiber.type);
3174 });
3175
3176 var _sortedNames2 = setToSortedString(_uniqueNames2);
3177
3178 lowPriorityWarning$1(false, 'componentWillUpdate is deprecated and will be removed in the next major version. ' + 'Use componentDidUpdate instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillUpdate.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames2);
3179
3180 pendingComponentWillUpdateWarnings = [];
3181 }
3182 };
3183
3184 ReactStrictModeWarnings.recordDeprecationWarnings = function (fiber, instance) {
3185 // Dedup strategy: Warn once per component.
3186 if (didWarnAboutDeprecatedLifecycles.has(fiber.type)) {
3187 return;
3188 }
3189
3190 // Don't warn about react-lifecycles-compat polyfilled components.
3191 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
3192 pendingComponentWillMountWarnings.push(fiber);
3193 }
3194 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
3195 pendingComponentWillReceivePropsWarnings.push(fiber);
3196 }
3197 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
3198 pendingComponentWillUpdateWarnings.push(fiber);
3199 }
3200 };
3201
3202 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
3203 var strictRoot = findStrictRoot(fiber);
3204 if (strictRoot === null) {
3205 warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
3206 return;
3207 }
3208
3209 // Dedup strategy: Warn once per component.
3210 // This is difficult to track any other way since component names
3211 // are often vague and are likely to collide between 3rd party libraries.
3212 // An expand property is probably okay to use here since it's DEV-only,
3213 // and will only be set in the event of serious warnings.
3214 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
3215 return;
3216 }
3217
3218 var warningsForRoot = void 0;
3219 if (!pendingUnsafeLifecycleWarnings.has(strictRoot)) {
3220 warningsForRoot = {
3221 UNSAFE_componentWillMount: [],
3222 UNSAFE_componentWillReceiveProps: [],
3223 UNSAFE_componentWillUpdate: []
3224 };
3225
3226 pendingUnsafeLifecycleWarnings.set(strictRoot, warningsForRoot);
3227 } else {
3228 warningsForRoot = pendingUnsafeLifecycleWarnings.get(strictRoot);
3229 }
3230
3231 var unsafeLifecycles = [];
3232 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillMount === 'function') {
3233 unsafeLifecycles.push('UNSAFE_componentWillMount');
3234 }
3235 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
3236 unsafeLifecycles.push('UNSAFE_componentWillReceiveProps');
3237 }
3238 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillUpdate === 'function') {
3239 unsafeLifecycles.push('UNSAFE_componentWillUpdate');
3240 }
3241
3242 if (unsafeLifecycles.length > 0) {
3243 unsafeLifecycles.forEach(function (lifecycle) {
3244 warningsForRoot[lifecycle].push(fiber);
3245 });
3246 }
3247 };
3248
3249 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
3250 var strictRoot = findStrictRoot(fiber);
3251 if (strictRoot === null) {
3252 warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
3253 return;
3254 }
3255
3256 // Dedup strategy: Warn once per component.
3257 if (didWarnAboutLegacyContext.has(fiber.type)) {
3258 return;
3259 }
3260
3261 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
3262
3263 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
3264 if (warningsForRoot === undefined) {
3265 warningsForRoot = [];
3266 pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
3267 }
3268 warningsForRoot.push(fiber);
3269 }
3270 };
3271
3272 ReactStrictModeWarnings.flushLegacyContextWarning = function () {
3273 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
3274 var uniqueNames = new Set();
3275 fiberArray.forEach(function (fiber) {
3276 uniqueNames.add(getComponentName(fiber.type) || 'Component');
3277 didWarnAboutLegacyContext.add(fiber.type);
3278 });
3279
3280 var sortedNames = setToSortedString(uniqueNames);
3281 var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
3282
3283 warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree: %s' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, sortedNames);
3284 });
3285 };
3286}
3287
3288/**
3289 * Similar to invariant but only logs a warning if the condition is not met.
3290 * This can be used to log issues in development environments in critical
3291 * paths. Removing the logging code for production environments will keep the
3292 * same logic and follow the same code paths.
3293 */
3294
3295var warning = warningWithoutStack$1;
3296
3297{
3298 warning = function (condition, format) {
3299 if (condition) {
3300 return;
3301 }
3302 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
3303 var stack = ReactDebugCurrentFrame.getStackAddendum();
3304 // eslint-disable-next-line react-internal/warning-and-invariant-args
3305
3306 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
3307 args[_key - 2] = arguments[_key];
3308 }
3309
3310 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
3311 };
3312}
3313
3314var warning$1 = warning;
3315
3316// This lets us hook into Fiber to debug what it's doing.
3317// See https://github.com/facebook/react/pull/8033.
3318// This is not part of the public API, not even for React DevTools.
3319// You may only inject a debugTool if you work on React Fiber itself.
3320var ReactFiberInstrumentation = {
3321 debugTool: null
3322};
3323
3324var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
3325
3326// TODO: Offscreen updates should never suspend. However, a promise that
3327// suspended inside an offscreen subtree should be able to ping at the priority
3328// of the outer render.
3329
3330function markPendingPriorityLevel(root, expirationTime) {
3331 // If there's a gap between completing a failed root and retrying it,
3332 // additional updates may be scheduled. Clear `didError`, in case the update
3333 // is sufficient to fix the error.
3334 root.didError = false;
3335
3336 // Update the latest and earliest pending times
3337 var earliestPendingTime = root.earliestPendingTime;
3338 if (earliestPendingTime === NoWork) {
3339 // No other pending updates.
3340 root.earliestPendingTime = root.latestPendingTime = expirationTime;
3341 } else {
3342 if (earliestPendingTime < expirationTime) {
3343 // This is the earliest pending update.
3344 root.earliestPendingTime = expirationTime;
3345 } else {
3346 var latestPendingTime = root.latestPendingTime;
3347 if (latestPendingTime > expirationTime) {
3348 // This is the latest pending update
3349 root.latestPendingTime = expirationTime;
3350 }
3351 }
3352 }
3353 findNextExpirationTimeToWorkOn(expirationTime, root);
3354}
3355
3356function markCommittedPriorityLevels(root, earliestRemainingTime) {
3357 root.didError = false;
3358
3359 if (earliestRemainingTime === NoWork) {
3360 // Fast path. There's no remaining work. Clear everything.
3361 root.earliestPendingTime = NoWork;
3362 root.latestPendingTime = NoWork;
3363 root.earliestSuspendedTime = NoWork;
3364 root.latestSuspendedTime = NoWork;
3365 root.latestPingedTime = NoWork;
3366 findNextExpirationTimeToWorkOn(NoWork, root);
3367 return;
3368 }
3369
3370 if (earliestRemainingTime < root.latestPingedTime) {
3371 root.latestPingedTime = NoWork;
3372 }
3373
3374 // Let's see if the previous latest known pending level was just flushed.
3375 var latestPendingTime = root.latestPendingTime;
3376 if (latestPendingTime !== NoWork) {
3377 if (latestPendingTime > earliestRemainingTime) {
3378 // We've flushed all the known pending levels.
3379 root.earliestPendingTime = root.latestPendingTime = NoWork;
3380 } else {
3381 var earliestPendingTime = root.earliestPendingTime;
3382 if (earliestPendingTime > earliestRemainingTime) {
3383 // We've flushed the earliest known pending level. Set this to the
3384 // latest pending time.
3385 root.earliestPendingTime = root.latestPendingTime;
3386 }
3387 }
3388 }
3389
3390 // Now let's handle the earliest remaining level in the whole tree. We need to
3391 // decide whether to treat it as a pending level or as suspended. Check
3392 // it falls within the range of known suspended levels.
3393
3394 var earliestSuspendedTime = root.earliestSuspendedTime;
3395 if (earliestSuspendedTime === NoWork) {
3396 // There's no suspended work. Treat the earliest remaining level as a
3397 // pending level.
3398 markPendingPriorityLevel(root, earliestRemainingTime);
3399 findNextExpirationTimeToWorkOn(NoWork, root);
3400 return;
3401 }
3402
3403 var latestSuspendedTime = root.latestSuspendedTime;
3404 if (earliestRemainingTime < latestSuspendedTime) {
3405 // The earliest remaining level is later than all the suspended work. That
3406 // means we've flushed all the suspended work.
3407 root.earliestSuspendedTime = NoWork;
3408 root.latestSuspendedTime = NoWork;
3409 root.latestPingedTime = NoWork;
3410
3411 // There's no suspended work. Treat the earliest remaining level as a
3412 // pending level.
3413 markPendingPriorityLevel(root, earliestRemainingTime);
3414 findNextExpirationTimeToWorkOn(NoWork, root);
3415 return;
3416 }
3417
3418 if (earliestRemainingTime > earliestSuspendedTime) {
3419 // The earliest remaining time is earlier than all the suspended work.
3420 // Treat it as a pending update.
3421 markPendingPriorityLevel(root, earliestRemainingTime);
3422 findNextExpirationTimeToWorkOn(NoWork, root);
3423 return;
3424 }
3425
3426 // The earliest remaining time falls within the range of known suspended
3427 // levels. We should treat this as suspended work.
3428 findNextExpirationTimeToWorkOn(NoWork, root);
3429}
3430
3431function hasLowerPriorityWork(root, erroredExpirationTime) {
3432 var latestPendingTime = root.latestPendingTime;
3433 var latestSuspendedTime = root.latestSuspendedTime;
3434 var latestPingedTime = root.latestPingedTime;
3435 return latestPendingTime !== NoWork && latestPendingTime < erroredExpirationTime || latestSuspendedTime !== NoWork && latestSuspendedTime < erroredExpirationTime || latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime;
3436}
3437
3438function isPriorityLevelSuspended(root, expirationTime) {
3439 var earliestSuspendedTime = root.earliestSuspendedTime;
3440 var latestSuspendedTime = root.latestSuspendedTime;
3441 return earliestSuspendedTime !== NoWork && expirationTime <= earliestSuspendedTime && expirationTime >= latestSuspendedTime;
3442}
3443
3444function markSuspendedPriorityLevel(root, suspendedTime) {
3445 root.didError = false;
3446 clearPing(root, suspendedTime);
3447
3448 // First, check the known pending levels and update them if needed.
3449 var earliestPendingTime = root.earliestPendingTime;
3450 var latestPendingTime = root.latestPendingTime;
3451 if (earliestPendingTime === suspendedTime) {
3452 if (latestPendingTime === suspendedTime) {
3453 // Both known pending levels were suspended. Clear them.
3454 root.earliestPendingTime = root.latestPendingTime = NoWork;
3455 } else {
3456 // The earliest pending level was suspended. Clear by setting it to the
3457 // latest pending level.
3458 root.earliestPendingTime = latestPendingTime;
3459 }
3460 } else if (latestPendingTime === suspendedTime) {
3461 // The latest pending level was suspended. Clear by setting it to the
3462 // latest pending level.
3463 root.latestPendingTime = earliestPendingTime;
3464 }
3465
3466 // Finally, update the known suspended levels.
3467 var earliestSuspendedTime = root.earliestSuspendedTime;
3468 var latestSuspendedTime = root.latestSuspendedTime;
3469 if (earliestSuspendedTime === NoWork) {
3470 // No other suspended levels.
3471 root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime;
3472 } else {
3473 if (earliestSuspendedTime < suspendedTime) {
3474 // This is the earliest suspended level.
3475 root.earliestSuspendedTime = suspendedTime;
3476 } else if (latestSuspendedTime > suspendedTime) {
3477 // This is the latest suspended level
3478 root.latestSuspendedTime = suspendedTime;
3479 }
3480 }
3481
3482 findNextExpirationTimeToWorkOn(suspendedTime, root);
3483}
3484
3485function markPingedPriorityLevel(root, pingedTime) {
3486 root.didError = false;
3487
3488 // TODO: When we add back resuming, we need to ensure the progressed work
3489 // is thrown out and not reused during the restarted render. One way to
3490 // invalidate the progressed work is to restart at expirationTime + 1.
3491 var latestPingedTime = root.latestPingedTime;
3492 if (latestPingedTime === NoWork || latestPingedTime > pingedTime) {
3493 root.latestPingedTime = pingedTime;
3494 }
3495 findNextExpirationTimeToWorkOn(pingedTime, root);
3496}
3497
3498function clearPing(root, completedTime) {
3499 var latestPingedTime = root.latestPingedTime;
3500 if (latestPingedTime >= completedTime) {
3501 root.latestPingedTime = NoWork;
3502 }
3503}
3504
3505function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) {
3506 var earliestExpirationTime = renderExpirationTime;
3507
3508 var earliestPendingTime = root.earliestPendingTime;
3509 var earliestSuspendedTime = root.earliestSuspendedTime;
3510 if (earliestPendingTime > earliestExpirationTime) {
3511 earliestExpirationTime = earliestPendingTime;
3512 }
3513 if (earliestSuspendedTime > earliestExpirationTime) {
3514 earliestExpirationTime = earliestSuspendedTime;
3515 }
3516 return earliestExpirationTime;
3517}
3518
3519function didExpireAtExpirationTime(root, currentTime) {
3520 var expirationTime = root.expirationTime;
3521 if (expirationTime !== NoWork && currentTime <= expirationTime) {
3522 // The root has expired. Flush all work up to the current time.
3523 root.nextExpirationTimeToWorkOn = currentTime;
3524 }
3525}
3526
3527function findNextExpirationTimeToWorkOn(completedExpirationTime, root) {
3528 var earliestSuspendedTime = root.earliestSuspendedTime;
3529 var latestSuspendedTime = root.latestSuspendedTime;
3530 var earliestPendingTime = root.earliestPendingTime;
3531 var latestPingedTime = root.latestPingedTime;
3532
3533 // Work on the earliest pending time. Failing that, work on the latest
3534 // pinged time.
3535 var nextExpirationTimeToWorkOn = earliestPendingTime !== NoWork ? earliestPendingTime : latestPingedTime;
3536
3537 // If there is no pending or pinged work, check if there's suspended work
3538 // that's lower priority than what we just completed.
3539 if (nextExpirationTimeToWorkOn === NoWork && (completedExpirationTime === NoWork || latestSuspendedTime < completedExpirationTime)) {
3540 // The lowest priority suspended work is the work most likely to be
3541 // committed next. Let's start rendering it again, so that if it times out,
3542 // it's ready to commit.
3543 nextExpirationTimeToWorkOn = latestSuspendedTime;
3544 }
3545
3546 var expirationTime = nextExpirationTimeToWorkOn;
3547 if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) {
3548 // Expire using the earliest known expiration time.
3549 expirationTime = earliestSuspendedTime;
3550 }
3551
3552 root.nextExpirationTimeToWorkOn = nextExpirationTimeToWorkOn;
3553 root.expirationTime = expirationTime;
3554}
3555
3556/**
3557 * inlined Object.is polyfill to avoid requiring consumers ship their own
3558 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
3559 */
3560function is(x, y) {
3561 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
3562 ;
3563}
3564
3565var hasOwnProperty = Object.prototype.hasOwnProperty;
3566
3567/**
3568 * Performs equality by iterating through keys on an object and returning false
3569 * when any key has values which are not strictly equal between the arguments.
3570 * Returns true when the values of all keys are strictly equal.
3571 */
3572function shallowEqual(objA, objB) {
3573 if (is(objA, objB)) {
3574 return true;
3575 }
3576
3577 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
3578 return false;
3579 }
3580
3581 var keysA = Object.keys(objA);
3582 var keysB = Object.keys(objB);
3583
3584 if (keysA.length !== keysB.length) {
3585 return false;
3586 }
3587
3588 // Test for A's keys different from B.
3589 for (var i = 0; i < keysA.length; i++) {
3590 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
3591 return false;
3592 }
3593 }
3594
3595 return true;
3596}
3597
3598function resolveDefaultProps(Component, baseProps) {
3599 if (Component && Component.defaultProps) {
3600 // Resolve default props. Taken from ReactElement
3601 var props = _assign({}, baseProps);
3602 var defaultProps = Component.defaultProps;
3603 for (var propName in defaultProps) {
3604 if (props[propName] === undefined) {
3605 props[propName] = defaultProps[propName];
3606 }
3607 }
3608 return props;
3609 }
3610 return baseProps;
3611}
3612
3613function readLazyComponentType(lazyComponent) {
3614 var status = lazyComponent._status;
3615 var result = lazyComponent._result;
3616 switch (status) {
3617 case Resolved:
3618 {
3619 var Component = result;
3620 return Component;
3621 }
3622 case Rejected:
3623 {
3624 var error = result;
3625 throw error;
3626 }
3627 case Pending:
3628 {
3629 var thenable = result;
3630 throw thenable;
3631 }
3632 default:
3633 {
3634 lazyComponent._status = Pending;
3635 var ctor = lazyComponent._ctor;
3636 var _thenable = ctor();
3637 _thenable.then(function (moduleObject) {
3638 if (lazyComponent._status === Pending) {
3639 var defaultExport = moduleObject.default;
3640 {
3641 if (defaultExport === undefined) {
3642 warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
3643 }
3644 }
3645 lazyComponent._status = Resolved;
3646 lazyComponent._result = defaultExport;
3647 }
3648 }, function (error) {
3649 if (lazyComponent._status === Pending) {
3650 lazyComponent._status = Rejected;
3651 lazyComponent._result = error;
3652 }
3653 });
3654 // Handle synchronous thenables.
3655 switch (lazyComponent._status) {
3656 case Resolved:
3657 return lazyComponent._result;
3658 case Rejected:
3659 throw lazyComponent._result;
3660 }
3661 lazyComponent._result = _thenable;
3662 throw _thenable;
3663 }
3664 }
3665}
3666
3667var fakeInternalInstance = {};
3668var isArray$1 = Array.isArray;
3669
3670// React.Component uses a shared frozen object by default.
3671// We'll use it to determine whether we need to initialize legacy refs.
3672var emptyRefsObject = new React.Component().refs;
3673
3674var didWarnAboutStateAssignmentForComponent = void 0;
3675var didWarnAboutUninitializedState = void 0;
3676var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0;
3677var didWarnAboutLegacyLifecyclesAndDerivedState = void 0;
3678var didWarnAboutUndefinedDerivedState = void 0;
3679var warnOnUndefinedDerivedState = void 0;
3680var warnOnInvalidCallback = void 0;
3681var didWarnAboutDirectlyAssigningPropsToState = void 0;
3682var didWarnAboutContextTypeAndContextTypes = void 0;
3683var didWarnAboutInvalidateContextType = void 0;
3684
3685{
3686 didWarnAboutStateAssignmentForComponent = new Set();
3687 didWarnAboutUninitializedState = new Set();
3688 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
3689 didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
3690 didWarnAboutDirectlyAssigningPropsToState = new Set();
3691 didWarnAboutUndefinedDerivedState = new Set();
3692 didWarnAboutContextTypeAndContextTypes = new Set();
3693 didWarnAboutInvalidateContextType = new Set();
3694
3695 var didWarnOnInvalidCallback = new Set();
3696
3697 warnOnInvalidCallback = function (callback, callerName) {
3698 if (callback === null || typeof callback === 'function') {
3699 return;
3700 }
3701 var key = callerName + '_' + callback;
3702 if (!didWarnOnInvalidCallback.has(key)) {
3703 didWarnOnInvalidCallback.add(key);
3704 warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
3705 }
3706 };
3707
3708 warnOnUndefinedDerivedState = function (type, partialState) {
3709 if (partialState === undefined) {
3710 var componentName = getComponentName(type) || 'Component';
3711 if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
3712 didWarnAboutUndefinedDerivedState.add(componentName);
3713 warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
3714 }
3715 }
3716 };
3717
3718 // This is so gross but it's at least non-critical and can be removed if
3719 // it causes problems. This is meant to give a nicer error message for
3720 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
3721 // ...)) which otherwise throws a "_processChildContext is not a function"
3722 // exception.
3723 Object.defineProperty(fakeInternalInstance, '_processChildContext', {
3724 enumerable: false,
3725 value: function () {
3726 (function () {
3727 {
3728 {
3729 throw ReactError('_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).');
3730 }
3731 }
3732 })();
3733 }
3734 });
3735 Object.freeze(fakeInternalInstance);
3736}
3737
3738function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
3739 var prevState = workInProgress.memoizedState;
3740
3741 {
3742 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3743 // Invoke the function an extra time to help detect side-effects.
3744 getDerivedStateFromProps(nextProps, prevState);
3745 }
3746 }
3747
3748 var partialState = getDerivedStateFromProps(nextProps, prevState);
3749
3750 {
3751 warnOnUndefinedDerivedState(ctor, partialState);
3752 }
3753 // Merge the partial state and the previous state.
3754 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
3755 workInProgress.memoizedState = memoizedState;
3756
3757 // Once the update queue is empty, persist the derived state onto the
3758 // base state.
3759 var updateQueue = workInProgress.updateQueue;
3760 if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
3761 updateQueue.baseState = memoizedState;
3762 }
3763}
3764
3765var classComponentUpdater = {
3766 isMounted: isMounted,
3767 enqueueSetState: function (inst, payload, callback) {
3768 var fiber = get(inst);
3769 var currentTime = requestCurrentTime$$1();
3770 var expirationTime = computeExpirationForFiber$$1(currentTime, fiber);
3771
3772 var update = createUpdate(expirationTime);
3773 update.payload = payload;
3774 if (callback !== undefined && callback !== null) {
3775 {
3776 warnOnInvalidCallback(callback, 'setState');
3777 }
3778 update.callback = callback;
3779 }
3780
3781 flushPassiveEffects$$1();
3782 enqueueUpdate(fiber, update);
3783 scheduleWork$$1(fiber, expirationTime);
3784 },
3785 enqueueReplaceState: function (inst, payload, callback) {
3786 var fiber = get(inst);
3787 var currentTime = requestCurrentTime$$1();
3788 var expirationTime = computeExpirationForFiber$$1(currentTime, fiber);
3789
3790 var update = createUpdate(expirationTime);
3791 update.tag = ReplaceState;
3792 update.payload = payload;
3793
3794 if (callback !== undefined && callback !== null) {
3795 {
3796 warnOnInvalidCallback(callback, 'replaceState');
3797 }
3798 update.callback = callback;
3799 }
3800
3801 flushPassiveEffects$$1();
3802 enqueueUpdate(fiber, update);
3803 scheduleWork$$1(fiber, expirationTime);
3804 },
3805 enqueueForceUpdate: function (inst, callback) {
3806 var fiber = get(inst);
3807 var currentTime = requestCurrentTime$$1();
3808 var expirationTime = computeExpirationForFiber$$1(currentTime, fiber);
3809
3810 var update = createUpdate(expirationTime);
3811 update.tag = ForceUpdate;
3812
3813 if (callback !== undefined && callback !== null) {
3814 {
3815 warnOnInvalidCallback(callback, 'forceUpdate');
3816 }
3817 update.callback = callback;
3818 }
3819
3820 flushPassiveEffects$$1();
3821 enqueueUpdate(fiber, update);
3822 scheduleWork$$1(fiber, expirationTime);
3823 }
3824};
3825
3826function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
3827 var instance = workInProgress.stateNode;
3828 if (typeof instance.shouldComponentUpdate === 'function') {
3829 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
3830 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
3831 stopPhaseTimer();
3832
3833 {
3834 !(shouldUpdate !== undefined) ? warningWithoutStack$1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component') : void 0;
3835 }
3836
3837 return shouldUpdate;
3838 }
3839
3840 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
3841 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
3842 }
3843
3844 return true;
3845}
3846
3847function checkClassInstance(workInProgress, ctor, newProps) {
3848 var instance = workInProgress.stateNode;
3849 {
3850 var name = getComponentName(ctor) || 'Component';
3851 var renderPresent = instance.render;
3852
3853 if (!renderPresent) {
3854 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
3855 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
3856 } else {
3857 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
3858 }
3859 }
3860
3861 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
3862 !noGetInitialStateOnES6 ? warningWithoutStack$1(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
3863 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
3864 !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
3865 var noInstancePropTypes = !instance.propTypes;
3866 !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
3867 var noInstanceContextType = !instance.contextType;
3868 !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
3869 var noInstanceContextTypes = !instance.contextTypes;
3870 !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
3871
3872 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
3873 didWarnAboutContextTypeAndContextTypes.add(ctor);
3874 warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
3875 }
3876
3877 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
3878 !noComponentShouldUpdate ? warningWithoutStack$1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
3879 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
3880 warningWithoutStack$1(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
3881 }
3882 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
3883 !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
3884 var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
3885 !noComponentDidReceiveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
3886 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
3887 !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
3888 var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
3889 !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
3890 var hasMutatedProps = instance.props !== newProps;
3891 !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
3892 var noInstanceDefaultProps = !instance.defaultProps;
3893 !noInstanceDefaultProps ? warningWithoutStack$1(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
3894
3895 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
3896 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
3897 warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
3898 }
3899
3900 var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
3901 !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
3902 var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
3903 !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
3904 var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
3905 !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
3906 var _state = instance.state;
3907 if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
3908 warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
3909 }
3910 if (typeof instance.getChildContext === 'function') {
3911 !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
3912 }
3913 }
3914}
3915
3916function adoptClassInstance(workInProgress, instance) {
3917 instance.updater = classComponentUpdater;
3918 workInProgress.stateNode = instance;
3919 // The instance needs access to the fiber so that it can schedule updates
3920 set(instance, workInProgress);
3921 {
3922 instance._reactInternalInstance = fakeInternalInstance;
3923 }
3924}
3925
3926function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
3927 var isLegacyContextConsumer = false;
3928 var unmaskedContext = emptyContextObject;
3929 var context = null;
3930 var contextType = ctor.contextType;
3931
3932 {
3933 if ('contextType' in ctor) {
3934 var isValid =
3935 // Allow null for conditional declaration
3936 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
3937
3938 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
3939 didWarnAboutInvalidateContextType.add(ctor);
3940
3941 var addendum = '';
3942 if (contextType === undefined) {
3943 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.';
3944 } else if (typeof contextType !== 'object') {
3945 addendum = ' However, it is set to a ' + typeof contextType + '.';
3946 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
3947 addendum = ' Did you accidentally pass the Context.Provider instead?';
3948 } else if (contextType._context !== undefined) {
3949 // <Context.Consumer>
3950 addendum = ' Did you accidentally pass the Context.Consumer instead?';
3951 } else {
3952 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
3953 }
3954 warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
3955 }
3956 }
3957 }
3958
3959 if (typeof contextType === 'object' && contextType !== null) {
3960 context = readContext(contextType);
3961 } else {
3962 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
3963 var contextTypes = ctor.contextTypes;
3964 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
3965 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
3966 }
3967
3968 // Instantiate twice to help detect side-effects.
3969 {
3970 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3971 new ctor(props, context); // eslint-disable-line no-new
3972 }
3973 }
3974
3975 var instance = new ctor(props, context);
3976 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
3977 adoptClassInstance(workInProgress, instance);
3978
3979 {
3980 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
3981 var componentName = getComponentName(ctor) || 'Component';
3982 if (!didWarnAboutUninitializedState.has(componentName)) {
3983 didWarnAboutUninitializedState.add(componentName);
3984 warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
3985 }
3986 }
3987
3988 // If new component APIs are defined, "unsafe" lifecycles won't be called.
3989 // Warn about these lifecycles if they are present.
3990 // Don't warn about react-lifecycles-compat polyfilled methods though.
3991 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
3992 var foundWillMountName = null;
3993 var foundWillReceivePropsName = null;
3994 var foundWillUpdateName = null;
3995 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
3996 foundWillMountName = 'componentWillMount';
3997 } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
3998 foundWillMountName = 'UNSAFE_componentWillMount';
3999 }
4000 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
4001 foundWillReceivePropsName = 'componentWillReceiveProps';
4002 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4003 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
4004 }
4005 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
4006 foundWillUpdateName = 'componentWillUpdate';
4007 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4008 foundWillUpdateName = 'UNSAFE_componentWillUpdate';
4009 }
4010 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
4011 var _componentName = getComponentName(ctor) || 'Component';
4012 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
4013 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
4014 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
4015 warningWithoutStack$1(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', _componentName, newApiName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '');
4016 }
4017 }
4018 }
4019 }
4020
4021 // Cache unmasked context so we can avoid recreating masked context unless necessary.
4022 // ReactFiberContext usually updates this cache but can't for newly-created instances.
4023 if (isLegacyContextConsumer) {
4024 cacheContext(workInProgress, unmaskedContext, context);
4025 }
4026
4027 return instance;
4028}
4029
4030function callComponentWillMount(workInProgress, instance) {
4031 startPhaseTimer(workInProgress, 'componentWillMount');
4032 var oldState = instance.state;
4033
4034 if (typeof instance.componentWillMount === 'function') {
4035 instance.componentWillMount();
4036 }
4037 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4038 instance.UNSAFE_componentWillMount();
4039 }
4040
4041 stopPhaseTimer();
4042
4043 if (oldState !== instance.state) {
4044 {
4045 warningWithoutStack$1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
4046 }
4047 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4048 }
4049}
4050
4051function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
4052 var oldState = instance.state;
4053 startPhaseTimer(workInProgress, 'componentWillReceiveProps');
4054 if (typeof instance.componentWillReceiveProps === 'function') {
4055 instance.componentWillReceiveProps(newProps, nextContext);
4056 }
4057 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4058 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
4059 }
4060 stopPhaseTimer();
4061
4062 if (instance.state !== oldState) {
4063 {
4064 var componentName = getComponentName(workInProgress.type) || 'Component';
4065 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
4066 didWarnAboutStateAssignmentForComponent.add(componentName);
4067 warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
4068 }
4069 }
4070 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4071 }
4072}
4073
4074// Invokes the mount life-cycles on a previously never rendered instance.
4075function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4076 {
4077 checkClassInstance(workInProgress, ctor, newProps);
4078 }
4079
4080 var instance = workInProgress.stateNode;
4081 instance.props = newProps;
4082 instance.state = workInProgress.memoizedState;
4083 instance.refs = emptyRefsObject;
4084
4085 var contextType = ctor.contextType;
4086 if (typeof contextType === 'object' && contextType !== null) {
4087 instance.context = readContext(contextType);
4088 } else {
4089 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4090 instance.context = getMaskedContext(workInProgress, unmaskedContext);
4091 }
4092
4093 {
4094 if (instance.state === newProps) {
4095 var componentName = getComponentName(ctor) || 'Component';
4096 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
4097 didWarnAboutDirectlyAssigningPropsToState.add(componentName);
4098 warningWithoutStack$1(false, '%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
4099 }
4100 }
4101
4102 if (workInProgress.mode & StrictMode) {
4103 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
4104
4105 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
4106 }
4107
4108 if (warnAboutDeprecatedLifecycles) {
4109 ReactStrictModeWarnings.recordDeprecationWarnings(workInProgress, instance);
4110 }
4111 }
4112
4113 var updateQueue = workInProgress.updateQueue;
4114 if (updateQueue !== null) {
4115 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4116 instance.state = workInProgress.memoizedState;
4117 }
4118
4119 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4120 if (typeof getDerivedStateFromProps === 'function') {
4121 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4122 instance.state = workInProgress.memoizedState;
4123 }
4124
4125 // In order to support react-lifecycles-compat polyfilled components,
4126 // Unsafe lifecycles should not be invoked for components using the new APIs.
4127 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4128 callComponentWillMount(workInProgress, instance);
4129 // If we had additional state updates during this life-cycle, let's
4130 // process them now.
4131 updateQueue = workInProgress.updateQueue;
4132 if (updateQueue !== null) {
4133 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4134 instance.state = workInProgress.memoizedState;
4135 }
4136 }
4137
4138 if (typeof instance.componentDidMount === 'function') {
4139 workInProgress.effectTag |= Update;
4140 }
4141}
4142
4143function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4144 var instance = workInProgress.stateNode;
4145
4146 var oldProps = workInProgress.memoizedProps;
4147 instance.props = oldProps;
4148
4149 var oldContext = instance.context;
4150 var contextType = ctor.contextType;
4151 var nextContext = void 0;
4152 if (typeof contextType === 'object' && contextType !== null) {
4153 nextContext = readContext(contextType);
4154 } else {
4155 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4156 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4157 }
4158
4159 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4160 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
4161
4162 // Note: During these life-cycles, instance.props/instance.state are what
4163 // ever the previously attempted to render - not the "current". However,
4164 // during componentDidUpdate we pass the "current" props.
4165
4166 // In order to support react-lifecycles-compat polyfilled components,
4167 // Unsafe lifecycles should not be invoked for components using the new APIs.
4168 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4169 if (oldProps !== newProps || oldContext !== nextContext) {
4170 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4171 }
4172 }
4173
4174 resetHasForceUpdateBeforeProcessing();
4175
4176 var oldState = workInProgress.memoizedState;
4177 var newState = instance.state = oldState;
4178 var updateQueue = workInProgress.updateQueue;
4179 if (updateQueue !== null) {
4180 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4181 newState = workInProgress.memoizedState;
4182 }
4183 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4184 // If an update was already in progress, we should schedule an Update
4185 // effect even though we're bailing out, so that cWU/cDU are called.
4186 if (typeof instance.componentDidMount === 'function') {
4187 workInProgress.effectTag |= Update;
4188 }
4189 return false;
4190 }
4191
4192 if (typeof getDerivedStateFromProps === 'function') {
4193 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4194 newState = workInProgress.memoizedState;
4195 }
4196
4197 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4198
4199 if (shouldUpdate) {
4200 // In order to support react-lifecycles-compat polyfilled components,
4201 // Unsafe lifecycles should not be invoked for components using the new APIs.
4202 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4203 startPhaseTimer(workInProgress, 'componentWillMount');
4204 if (typeof instance.componentWillMount === 'function') {
4205 instance.componentWillMount();
4206 }
4207 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4208 instance.UNSAFE_componentWillMount();
4209 }
4210 stopPhaseTimer();
4211 }
4212 if (typeof instance.componentDidMount === 'function') {
4213 workInProgress.effectTag |= Update;
4214 }
4215 } else {
4216 // If an update was already in progress, we should schedule an Update
4217 // effect even though we're bailing out, so that cWU/cDU are called.
4218 if (typeof instance.componentDidMount === 'function') {
4219 workInProgress.effectTag |= Update;
4220 }
4221
4222 // If shouldComponentUpdate returned false, we should still update the
4223 // memoized state to indicate that this work can be reused.
4224 workInProgress.memoizedProps = newProps;
4225 workInProgress.memoizedState = newState;
4226 }
4227
4228 // Update the existing instance's state, props, and context pointers even
4229 // if shouldComponentUpdate returns false.
4230 instance.props = newProps;
4231 instance.state = newState;
4232 instance.context = nextContext;
4233
4234 return shouldUpdate;
4235}
4236
4237// Invokes the update life-cycles and returns false if it shouldn't rerender.
4238function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
4239 var instance = workInProgress.stateNode;
4240
4241 var oldProps = workInProgress.memoizedProps;
4242 instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
4243
4244 var oldContext = instance.context;
4245 var contextType = ctor.contextType;
4246 var nextContext = void 0;
4247 if (typeof contextType === 'object' && contextType !== null) {
4248 nextContext = readContext(contextType);
4249 } else {
4250 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4251 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
4252 }
4253
4254 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4255 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
4256
4257 // Note: During these life-cycles, instance.props/instance.state are what
4258 // ever the previously attempted to render - not the "current". However,
4259 // during componentDidUpdate we pass the "current" props.
4260
4261 // In order to support react-lifecycles-compat polyfilled components,
4262 // Unsafe lifecycles should not be invoked for components using the new APIs.
4263 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4264 if (oldProps !== newProps || oldContext !== nextContext) {
4265 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4266 }
4267 }
4268
4269 resetHasForceUpdateBeforeProcessing();
4270
4271 var oldState = workInProgress.memoizedState;
4272 var newState = instance.state = oldState;
4273 var updateQueue = workInProgress.updateQueue;
4274 if (updateQueue !== null) {
4275 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4276 newState = workInProgress.memoizedState;
4277 }
4278
4279 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4280 // If an update was already in progress, we should schedule an Update
4281 // effect even though we're bailing out, so that cWU/cDU are called.
4282 if (typeof instance.componentDidUpdate === 'function') {
4283 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4284 workInProgress.effectTag |= Update;
4285 }
4286 }
4287 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4288 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4289 workInProgress.effectTag |= Snapshot;
4290 }
4291 }
4292 return false;
4293 }
4294
4295 if (typeof getDerivedStateFromProps === 'function') {
4296 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4297 newState = workInProgress.memoizedState;
4298 }
4299
4300 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4301
4302 if (shouldUpdate) {
4303 // In order to support react-lifecycles-compat polyfilled components,
4304 // Unsafe lifecycles should not be invoked for components using the new APIs.
4305 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
4306 startPhaseTimer(workInProgress, 'componentWillUpdate');
4307 if (typeof instance.componentWillUpdate === 'function') {
4308 instance.componentWillUpdate(newProps, newState, nextContext);
4309 }
4310 if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4311 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
4312 }
4313 stopPhaseTimer();
4314 }
4315 if (typeof instance.componentDidUpdate === 'function') {
4316 workInProgress.effectTag |= Update;
4317 }
4318 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4319 workInProgress.effectTag |= Snapshot;
4320 }
4321 } else {
4322 // If an update was already in progress, we should schedule an Update
4323 // effect even though we're bailing out, so that cWU/cDU are called.
4324 if (typeof instance.componentDidUpdate === 'function') {
4325 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4326 workInProgress.effectTag |= Update;
4327 }
4328 }
4329 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4330 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4331 workInProgress.effectTag |= Snapshot;
4332 }
4333 }
4334
4335 // If shouldComponentUpdate returned false, we should still update the
4336 // memoized props/state to indicate that this work can be reused.
4337 workInProgress.memoizedProps = newProps;
4338 workInProgress.memoizedState = newState;
4339 }
4340
4341 // Update the existing instance's state, props, and context pointers even
4342 // if shouldComponentUpdate returns false.
4343 instance.props = newProps;
4344 instance.state = newState;
4345 instance.context = nextContext;
4346
4347 return shouldUpdate;
4348}
4349
4350var didWarnAboutMaps = void 0;
4351var didWarnAboutGenerators = void 0;
4352var didWarnAboutStringRefInStrictMode = void 0;
4353var ownerHasKeyUseWarning = void 0;
4354var ownerHasFunctionTypeWarning = void 0;
4355var warnForMissingKey = function (child) {};
4356
4357{
4358 didWarnAboutMaps = false;
4359 didWarnAboutGenerators = false;
4360 didWarnAboutStringRefInStrictMode = {};
4361
4362 /**
4363 * Warn if there's no key explicitly set on dynamic arrays of children or
4364 * object keys are not valid. This allows us to keep track of children between
4365 * updates.
4366 */
4367 ownerHasKeyUseWarning = {};
4368 ownerHasFunctionTypeWarning = {};
4369
4370 warnForMissingKey = function (child) {
4371 if (child === null || typeof child !== 'object') {
4372 return;
4373 }
4374 if (!child._store || child._store.validated || child.key != null) {
4375 return;
4376 }
4377 (function () {
4378 if (!(typeof child._store === 'object')) {
4379 {
4380 throw ReactError('React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.');
4381 }
4382 }
4383 })();
4384 child._store.validated = true;
4385
4386 var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
4387 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
4388 return;
4389 }
4390 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
4391
4392 warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
4393 };
4394}
4395
4396var isArray = Array.isArray;
4397
4398function coerceRef(returnFiber, current$$1, element) {
4399 var mixedRef = element.ref;
4400 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
4401 {
4402 if (returnFiber.mode & StrictMode) {
4403 var componentName = getComponentName(returnFiber.type) || 'Component';
4404 if (!didWarnAboutStringRefInStrictMode[componentName]) {
4405 warningWithoutStack$1(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using createRef() instead.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-string-ref', mixedRef, getStackByFiberInDevAndProd(returnFiber));
4406 didWarnAboutStringRefInStrictMode[componentName] = true;
4407 }
4408 }
4409 }
4410
4411 if (element._owner) {
4412 var owner = element._owner;
4413 var inst = void 0;
4414 if (owner) {
4415 var ownerFiber = owner;
4416 (function () {
4417 if (!(ownerFiber.tag === ClassComponent)) {
4418 {
4419 throw ReactError('Function components cannot have refs. Did you mean to use React.forwardRef()?');
4420 }
4421 }
4422 })();
4423 inst = ownerFiber.stateNode;
4424 }
4425 (function () {
4426 if (!inst) {
4427 {
4428 throw ReactError('Missing owner for string ref ' + mixedRef + '. This error is likely caused by a bug in React. Please file an issue.');
4429 }
4430 }
4431 })();
4432 var stringRef = '' + mixedRef;
4433 // Check if previous string ref matches new string ref
4434 if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
4435 return current$$1.ref;
4436 }
4437 var ref = function (value) {
4438 var refs = inst.refs;
4439 if (refs === emptyRefsObject) {
4440 // This is a lazy pooled frozen object, so we need to initialize.
4441 refs = inst.refs = {};
4442 }
4443 if (value === null) {
4444 delete refs[stringRef];
4445 } else {
4446 refs[stringRef] = value;
4447 }
4448 };
4449 ref._stringRef = stringRef;
4450 return ref;
4451 } else {
4452 (function () {
4453 if (!(typeof mixedRef === 'string')) {
4454 {
4455 throw ReactError('Expected ref to be a function, a string, an object returned by React.createRef(), or null.');
4456 }
4457 }
4458 })();
4459 (function () {
4460 if (!element._owner) {
4461 {
4462 throw ReactError('Element ref was specified as a string (' + mixedRef + ') but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component\'s render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.');
4463 }
4464 }
4465 })();
4466 }
4467 }
4468 return mixedRef;
4469}
4470
4471function throwOnInvalidObjectType(returnFiber, newChild) {
4472 if (returnFiber.type !== 'textarea') {
4473 var addendum = '';
4474 {
4475 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
4476 }
4477 (function () {
4478 {
4479 {
4480 throw ReactError('Objects are not valid as a React child (found: ' + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ').' + addendum);
4481 }
4482 }
4483 })();
4484 }
4485}
4486
4487function warnOnFunctionType() {
4488 var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev();
4489
4490 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
4491 return;
4492 }
4493 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
4494
4495 warning$1(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
4496}
4497
4498// This wrapper function exists because I expect to clone the code in each path
4499// to be able to optimize each path individually by branching early. This needs
4500// a compiler or we can do it manually. Helpers that don't need this branching
4501// live outside of this function.
4502function ChildReconciler(shouldTrackSideEffects) {
4503 function deleteChild(returnFiber, childToDelete) {
4504 if (!shouldTrackSideEffects) {
4505 // Noop.
4506 return;
4507 }
4508 // Deletions are added in reversed order so we add it to the front.
4509 // At this point, the return fiber's effect list is empty except for
4510 // deletions, so we can just append the deletion to the list. The remaining
4511 // effects aren't added until the complete phase. Once we implement
4512 // resuming, this may not be true.
4513 var last = returnFiber.lastEffect;
4514 if (last !== null) {
4515 last.nextEffect = childToDelete;
4516 returnFiber.lastEffect = childToDelete;
4517 } else {
4518 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
4519 }
4520 childToDelete.nextEffect = null;
4521 childToDelete.effectTag = Deletion;
4522 }
4523
4524 function deleteRemainingChildren(returnFiber, currentFirstChild) {
4525 if (!shouldTrackSideEffects) {
4526 // Noop.
4527 return null;
4528 }
4529
4530 // TODO: For the shouldClone case, this could be micro-optimized a bit by
4531 // assuming that after the first child we've already added everything.
4532 var childToDelete = currentFirstChild;
4533 while (childToDelete !== null) {
4534 deleteChild(returnFiber, childToDelete);
4535 childToDelete = childToDelete.sibling;
4536 }
4537 return null;
4538 }
4539
4540 function mapRemainingChildren(returnFiber, currentFirstChild) {
4541 // Add the remaining children to a temporary map so that we can find them by
4542 // keys quickly. Implicit (null) keys get added to this set with their index
4543 var existingChildren = new Map();
4544
4545 var existingChild = currentFirstChild;
4546 while (existingChild !== null) {
4547 if (existingChild.key !== null) {
4548 existingChildren.set(existingChild.key, existingChild);
4549 } else {
4550 existingChildren.set(existingChild.index, existingChild);
4551 }
4552 existingChild = existingChild.sibling;
4553 }
4554 return existingChildren;
4555 }
4556
4557 function useFiber(fiber, pendingProps, expirationTime) {
4558 // We currently set sibling to null and index to 0 here because it is easy
4559 // to forget to do before returning it. E.g. for the single child case.
4560 var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
4561 clone.index = 0;
4562 clone.sibling = null;
4563 return clone;
4564 }
4565
4566 function placeChild(newFiber, lastPlacedIndex, newIndex) {
4567 newFiber.index = newIndex;
4568 if (!shouldTrackSideEffects) {
4569 // Noop.
4570 return lastPlacedIndex;
4571 }
4572 var current$$1 = newFiber.alternate;
4573 if (current$$1 !== null) {
4574 var oldIndex = current$$1.index;
4575 if (oldIndex < lastPlacedIndex) {
4576 // This is a move.
4577 newFiber.effectTag = Placement;
4578 return lastPlacedIndex;
4579 } else {
4580 // This item can stay in place.
4581 return oldIndex;
4582 }
4583 } else {
4584 // This is an insertion.
4585 newFiber.effectTag = Placement;
4586 return lastPlacedIndex;
4587 }
4588 }
4589
4590 function placeSingleChild(newFiber) {
4591 // This is simpler for the single child case. We only need to do a
4592 // placement for inserting new children.
4593 if (shouldTrackSideEffects && newFiber.alternate === null) {
4594 newFiber.effectTag = Placement;
4595 }
4596 return newFiber;
4597 }
4598
4599 function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
4600 if (current$$1 === null || current$$1.tag !== HostText) {
4601 // Insert
4602 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
4603 created.return = returnFiber;
4604 return created;
4605 } else {
4606 // Update
4607 var existing = useFiber(current$$1, textContent, expirationTime);
4608 existing.return = returnFiber;
4609 return existing;
4610 }
4611 }
4612
4613 function updateElement(returnFiber, current$$1, element, expirationTime) {
4614 if (current$$1 !== null && current$$1.elementType === element.type) {
4615 // Move based on index
4616 var existing = useFiber(current$$1, element.props, expirationTime);
4617 existing.ref = coerceRef(returnFiber, current$$1, element);
4618 existing.return = returnFiber;
4619 {
4620 existing._debugSource = element._source;
4621 existing._debugOwner = element._owner;
4622 }
4623 return existing;
4624 } else {
4625 // Insert
4626 var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
4627 created.ref = coerceRef(returnFiber, current$$1, element);
4628 created.return = returnFiber;
4629 return created;
4630 }
4631 }
4632
4633 function updatePortal(returnFiber, current$$1, portal, expirationTime) {
4634 if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
4635 // Insert
4636 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
4637 created.return = returnFiber;
4638 return created;
4639 } else {
4640 // Update
4641 var existing = useFiber(current$$1, portal.children || [], expirationTime);
4642 existing.return = returnFiber;
4643 return existing;
4644 }
4645 }
4646
4647 function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
4648 if (current$$1 === null || current$$1.tag !== Fragment) {
4649 // Insert
4650 var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
4651 created.return = returnFiber;
4652 return created;
4653 } else {
4654 // Update
4655 var existing = useFiber(current$$1, fragment, expirationTime);
4656 existing.return = returnFiber;
4657 return existing;
4658 }
4659 }
4660
4661 function createChild(returnFiber, newChild, expirationTime) {
4662 if (typeof newChild === 'string' || typeof newChild === 'number') {
4663 // Text nodes don't have keys. If the previous node is implicitly keyed
4664 // we can continue to replace it without aborting even if it is not a text
4665 // node.
4666 var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
4667 created.return = returnFiber;
4668 return created;
4669 }
4670
4671 if (typeof newChild === 'object' && newChild !== null) {
4672 switch (newChild.$$typeof) {
4673 case REACT_ELEMENT_TYPE:
4674 {
4675 var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
4676 _created.ref = coerceRef(returnFiber, null, newChild);
4677 _created.return = returnFiber;
4678 return _created;
4679 }
4680 case REACT_PORTAL_TYPE:
4681 {
4682 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
4683 _created2.return = returnFiber;
4684 return _created2;
4685 }
4686 }
4687
4688 if (isArray(newChild) || getIteratorFn(newChild)) {
4689 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
4690 _created3.return = returnFiber;
4691 return _created3;
4692 }
4693
4694 throwOnInvalidObjectType(returnFiber, newChild);
4695 }
4696
4697 {
4698 if (typeof newChild === 'function') {
4699 warnOnFunctionType();
4700 }
4701 }
4702
4703 return null;
4704 }
4705
4706 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
4707 // Update the fiber if the keys match, otherwise return null.
4708
4709 var key = oldFiber !== null ? oldFiber.key : null;
4710
4711 if (typeof newChild === 'string' || typeof newChild === 'number') {
4712 // Text nodes don't have keys. If the previous node is implicitly keyed
4713 // we can continue to replace it without aborting even if it is not a text
4714 // node.
4715 if (key !== null) {
4716 return null;
4717 }
4718 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
4719 }
4720
4721 if (typeof newChild === 'object' && newChild !== null) {
4722 switch (newChild.$$typeof) {
4723 case REACT_ELEMENT_TYPE:
4724 {
4725 if (newChild.key === key) {
4726 if (newChild.type === REACT_FRAGMENT_TYPE) {
4727 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
4728 }
4729 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
4730 } else {
4731 return null;
4732 }
4733 }
4734 case REACT_PORTAL_TYPE:
4735 {
4736 if (newChild.key === key) {
4737 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
4738 } else {
4739 return null;
4740 }
4741 }
4742 }
4743
4744 if (isArray(newChild) || getIteratorFn(newChild)) {
4745 if (key !== null) {
4746 return null;
4747 }
4748
4749 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
4750 }
4751
4752 throwOnInvalidObjectType(returnFiber, newChild);
4753 }
4754
4755 {
4756 if (typeof newChild === 'function') {
4757 warnOnFunctionType();
4758 }
4759 }
4760
4761 return null;
4762 }
4763
4764 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
4765 if (typeof newChild === 'string' || typeof newChild === 'number') {
4766 // Text nodes don't have keys, so we neither have to check the old nor
4767 // new node for the key. If both are text nodes, they match.
4768 var matchedFiber = existingChildren.get(newIdx) || null;
4769 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
4770 }
4771
4772 if (typeof newChild === 'object' && newChild !== null) {
4773 switch (newChild.$$typeof) {
4774 case REACT_ELEMENT_TYPE:
4775 {
4776 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
4777 if (newChild.type === REACT_FRAGMENT_TYPE) {
4778 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
4779 }
4780 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
4781 }
4782 case REACT_PORTAL_TYPE:
4783 {
4784 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
4785 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
4786 }
4787 }
4788
4789 if (isArray(newChild) || getIteratorFn(newChild)) {
4790 var _matchedFiber3 = existingChildren.get(newIdx) || null;
4791 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
4792 }
4793
4794 throwOnInvalidObjectType(returnFiber, newChild);
4795 }
4796
4797 {
4798 if (typeof newChild === 'function') {
4799 warnOnFunctionType();
4800 }
4801 }
4802
4803 return null;
4804 }
4805
4806 /**
4807 * Warns if there is a duplicate or missing key
4808 */
4809 function warnOnInvalidKey(child, knownKeys) {
4810 {
4811 if (typeof child !== 'object' || child === null) {
4812 return knownKeys;
4813 }
4814 switch (child.$$typeof) {
4815 case REACT_ELEMENT_TYPE:
4816 case REACT_PORTAL_TYPE:
4817 warnForMissingKey(child);
4818 var key = child.key;
4819 if (typeof key !== 'string') {
4820 break;
4821 }
4822 if (knownKeys === null) {
4823 knownKeys = new Set();
4824 knownKeys.add(key);
4825 break;
4826 }
4827 if (!knownKeys.has(key)) {
4828 knownKeys.add(key);
4829 break;
4830 }
4831 warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);
4832 break;
4833 default:
4834 break;
4835 }
4836 }
4837 return knownKeys;
4838 }
4839
4840 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
4841 // This algorithm can't optimize by searching from both ends since we
4842 // don't have backpointers on fibers. I'm trying to see how far we can get
4843 // with that model. If it ends up not being worth the tradeoffs, we can
4844 // add it later.
4845
4846 // Even with a two ended optimization, we'd want to optimize for the case
4847 // where there are few changes and brute force the comparison instead of
4848 // going for the Map. It'd like to explore hitting that path first in
4849 // forward-only mode and only go for the Map once we notice that we need
4850 // lots of look ahead. This doesn't handle reversal as well as two ended
4851 // search but that's unusual. Besides, for the two ended optimization to
4852 // work on Iterables, we'd need to copy the whole set.
4853
4854 // In this first iteration, we'll just live with hitting the bad case
4855 // (adding everything to a Map) in for every insert/move.
4856
4857 // If you change this code, also update reconcileChildrenIterator() which
4858 // uses the same algorithm.
4859
4860 {
4861 // First, validate keys.
4862 var knownKeys = null;
4863 for (var i = 0; i < newChildren.length; i++) {
4864 var child = newChildren[i];
4865 knownKeys = warnOnInvalidKey(child, knownKeys);
4866 }
4867 }
4868
4869 var resultingFirstChild = null;
4870 var previousNewFiber = null;
4871
4872 var oldFiber = currentFirstChild;
4873 var lastPlacedIndex = 0;
4874 var newIdx = 0;
4875 var nextOldFiber = null;
4876 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
4877 if (oldFiber.index > newIdx) {
4878 nextOldFiber = oldFiber;
4879 oldFiber = null;
4880 } else {
4881 nextOldFiber = oldFiber.sibling;
4882 }
4883 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
4884 if (newFiber === null) {
4885 // TODO: This breaks on empty slots like null children. That's
4886 // unfortunate because it triggers the slow path all the time. We need
4887 // a better way to communicate whether this was a miss or null,
4888 // boolean, undefined, etc.
4889 if (oldFiber === null) {
4890 oldFiber = nextOldFiber;
4891 }
4892 break;
4893 }
4894 if (shouldTrackSideEffects) {
4895 if (oldFiber && newFiber.alternate === null) {
4896 // We matched the slot, but we didn't reuse the existing fiber, so we
4897 // need to delete the existing child.
4898 deleteChild(returnFiber, oldFiber);
4899 }
4900 }
4901 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
4902 if (previousNewFiber === null) {
4903 // TODO: Move out of the loop. This only happens for the first run.
4904 resultingFirstChild = newFiber;
4905 } else {
4906 // TODO: Defer siblings if we're not at the right index for this slot.
4907 // I.e. if we had null values before, then we want to defer this
4908 // for each null value. However, we also don't want to call updateSlot
4909 // with the previous one.
4910 previousNewFiber.sibling = newFiber;
4911 }
4912 previousNewFiber = newFiber;
4913 oldFiber = nextOldFiber;
4914 }
4915
4916 if (newIdx === newChildren.length) {
4917 // We've reached the end of the new children. We can delete the rest.
4918 deleteRemainingChildren(returnFiber, oldFiber);
4919 return resultingFirstChild;
4920 }
4921
4922 if (oldFiber === null) {
4923 // If we don't have any more existing children we can choose a fast path
4924 // since the rest will all be insertions.
4925 for (; newIdx < newChildren.length; newIdx++) {
4926 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
4927 if (!_newFiber) {
4928 continue;
4929 }
4930 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
4931 if (previousNewFiber === null) {
4932 // TODO: Move out of the loop. This only happens for the first run.
4933 resultingFirstChild = _newFiber;
4934 } else {
4935 previousNewFiber.sibling = _newFiber;
4936 }
4937 previousNewFiber = _newFiber;
4938 }
4939 return resultingFirstChild;
4940 }
4941
4942 // Add all children to a key map for quick lookups.
4943 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
4944
4945 // Keep scanning and use the map to restore deleted items as moves.
4946 for (; newIdx < newChildren.length; newIdx++) {
4947 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
4948 if (_newFiber2) {
4949 if (shouldTrackSideEffects) {
4950 if (_newFiber2.alternate !== null) {
4951 // The new fiber is a work in progress, but if there exists a
4952 // current, that means that we reused the fiber. We need to delete
4953 // it from the child list so that we don't add it to the deletion
4954 // list.
4955 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
4956 }
4957 }
4958 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
4959 if (previousNewFiber === null) {
4960 resultingFirstChild = _newFiber2;
4961 } else {
4962 previousNewFiber.sibling = _newFiber2;
4963 }
4964 previousNewFiber = _newFiber2;
4965 }
4966 }
4967
4968 if (shouldTrackSideEffects) {
4969 // Any existing children that weren't consumed above were deleted. We need
4970 // to add them to the deletion list.
4971 existingChildren.forEach(function (child) {
4972 return deleteChild(returnFiber, child);
4973 });
4974 }
4975
4976 return resultingFirstChild;
4977 }
4978
4979 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
4980 // This is the same implementation as reconcileChildrenArray(),
4981 // but using the iterator instead.
4982
4983 var iteratorFn = getIteratorFn(newChildrenIterable);
4984 (function () {
4985 if (!(typeof iteratorFn === 'function')) {
4986 {
4987 throw ReactError('An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.');
4988 }
4989 }
4990 })();
4991
4992 {
4993 // We don't support rendering Generators because it's a mutation.
4994 // See https://github.com/facebook/react/issues/12995
4995 if (typeof Symbol === 'function' &&
4996 // $FlowFixMe Flow doesn't know about toStringTag
4997 newChildrenIterable[Symbol.toStringTag] === 'Generator') {
4998 !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;
4999 didWarnAboutGenerators = true;
5000 }
5001
5002 // Warn about using Maps as children
5003 if (newChildrenIterable.entries === iteratorFn) {
5004 !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
5005 didWarnAboutMaps = true;
5006 }
5007
5008 // First, validate keys.
5009 // We'll get a different iterator later for the main pass.
5010 var _newChildren = iteratorFn.call(newChildrenIterable);
5011 if (_newChildren) {
5012 var knownKeys = null;
5013 var _step = _newChildren.next();
5014 for (; !_step.done; _step = _newChildren.next()) {
5015 var child = _step.value;
5016 knownKeys = warnOnInvalidKey(child, knownKeys);
5017 }
5018 }
5019 }
5020
5021 var newChildren = iteratorFn.call(newChildrenIterable);
5022 (function () {
5023 if (!(newChildren != null)) {
5024 {
5025 throw ReactError('An iterable object provided no iterator.');
5026 }
5027 }
5028 })();
5029
5030 var resultingFirstChild = null;
5031 var previousNewFiber = null;
5032
5033 var oldFiber = currentFirstChild;
5034 var lastPlacedIndex = 0;
5035 var newIdx = 0;
5036 var nextOldFiber = null;
5037
5038 var step = newChildren.next();
5039 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
5040 if (oldFiber.index > newIdx) {
5041 nextOldFiber = oldFiber;
5042 oldFiber = null;
5043 } else {
5044 nextOldFiber = oldFiber.sibling;
5045 }
5046 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
5047 if (newFiber === null) {
5048 // TODO: This breaks on empty slots like null children. That's
5049 // unfortunate because it triggers the slow path all the time. We need
5050 // a better way to communicate whether this was a miss or null,
5051 // boolean, undefined, etc.
5052 if (!oldFiber) {
5053 oldFiber = nextOldFiber;
5054 }
5055 break;
5056 }
5057 if (shouldTrackSideEffects) {
5058 if (oldFiber && newFiber.alternate === null) {
5059 // We matched the slot, but we didn't reuse the existing fiber, so we
5060 // need to delete the existing child.
5061 deleteChild(returnFiber, oldFiber);
5062 }
5063 }
5064 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
5065 if (previousNewFiber === null) {
5066 // TODO: Move out of the loop. This only happens for the first run.
5067 resultingFirstChild = newFiber;
5068 } else {
5069 // TODO: Defer siblings if we're not at the right index for this slot.
5070 // I.e. if we had null values before, then we want to defer this
5071 // for each null value. However, we also don't want to call updateSlot
5072 // with the previous one.
5073 previousNewFiber.sibling = newFiber;
5074 }
5075 previousNewFiber = newFiber;
5076 oldFiber = nextOldFiber;
5077 }
5078
5079 if (step.done) {
5080 // We've reached the end of the new children. We can delete the rest.
5081 deleteRemainingChildren(returnFiber, oldFiber);
5082 return resultingFirstChild;
5083 }
5084
5085 if (oldFiber === null) {
5086 // If we don't have any more existing children we can choose a fast path
5087 // since the rest will all be insertions.
5088 for (; !step.done; newIdx++, step = newChildren.next()) {
5089 var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
5090 if (_newFiber3 === null) {
5091 continue;
5092 }
5093 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
5094 if (previousNewFiber === null) {
5095 // TODO: Move out of the loop. This only happens for the first run.
5096 resultingFirstChild = _newFiber3;
5097 } else {
5098 previousNewFiber.sibling = _newFiber3;
5099 }
5100 previousNewFiber = _newFiber3;
5101 }
5102 return resultingFirstChild;
5103 }
5104
5105 // Add all children to a key map for quick lookups.
5106 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
5107
5108 // Keep scanning and use the map to restore deleted items as moves.
5109 for (; !step.done; newIdx++, step = newChildren.next()) {
5110 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
5111 if (_newFiber4 !== null) {
5112 if (shouldTrackSideEffects) {
5113 if (_newFiber4.alternate !== null) {
5114 // The new fiber is a work in progress, but if there exists a
5115 // current, that means that we reused the fiber. We need to delete
5116 // it from the child list so that we don't add it to the deletion
5117 // list.
5118 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
5119 }
5120 }
5121 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
5122 if (previousNewFiber === null) {
5123 resultingFirstChild = _newFiber4;
5124 } else {
5125 previousNewFiber.sibling = _newFiber4;
5126 }
5127 previousNewFiber = _newFiber4;
5128 }
5129 }
5130
5131 if (shouldTrackSideEffects) {
5132 // Any existing children that weren't consumed above were deleted. We need
5133 // to add them to the deletion list.
5134 existingChildren.forEach(function (child) {
5135 return deleteChild(returnFiber, child);
5136 });
5137 }
5138
5139 return resultingFirstChild;
5140 }
5141
5142 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
5143 // There's no need to check for keys on text nodes since we don't have a
5144 // way to define them.
5145 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
5146 // We already have an existing node so let's just update it and delete
5147 // the rest.
5148 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
5149 var existing = useFiber(currentFirstChild, textContent, expirationTime);
5150 existing.return = returnFiber;
5151 return existing;
5152 }
5153 // The existing first child is not a text node so we need to create one
5154 // and delete the existing ones.
5155 deleteRemainingChildren(returnFiber, currentFirstChild);
5156 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
5157 created.return = returnFiber;
5158 return created;
5159 }
5160
5161 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
5162 var key = element.key;
5163 var child = currentFirstChild;
5164 while (child !== null) {
5165 // TODO: If key === null and child.key === null, then this only applies to
5166 // the first item in the list.
5167 if (child.key === key) {
5168 if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {
5169 deleteRemainingChildren(returnFiber, child.sibling);
5170 var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
5171 existing.ref = coerceRef(returnFiber, child, element);
5172 existing.return = returnFiber;
5173 {
5174 existing._debugSource = element._source;
5175 existing._debugOwner = element._owner;
5176 }
5177 return existing;
5178 } else {
5179 deleteRemainingChildren(returnFiber, child);
5180 break;
5181 }
5182 } else {
5183 deleteChild(returnFiber, child);
5184 }
5185 child = child.sibling;
5186 }
5187
5188 if (element.type === REACT_FRAGMENT_TYPE) {
5189 var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
5190 created.return = returnFiber;
5191 return created;
5192 } else {
5193 var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
5194 _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
5195 _created4.return = returnFiber;
5196 return _created4;
5197 }
5198 }
5199
5200 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
5201 var key = portal.key;
5202 var child = currentFirstChild;
5203 while (child !== null) {
5204 // TODO: If key === null and child.key === null, then this only applies to
5205 // the first item in the list.
5206 if (child.key === key) {
5207 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
5208 deleteRemainingChildren(returnFiber, child.sibling);
5209 var existing = useFiber(child, portal.children || [], expirationTime);
5210 existing.return = returnFiber;
5211 return existing;
5212 } else {
5213 deleteRemainingChildren(returnFiber, child);
5214 break;
5215 }
5216 } else {
5217 deleteChild(returnFiber, child);
5218 }
5219 child = child.sibling;
5220 }
5221
5222 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
5223 created.return = returnFiber;
5224 return created;
5225 }
5226
5227 // This API will tag the children with the side-effect of the reconciliation
5228 // itself. They will be added to the side-effect list as we pass through the
5229 // children and the parent.
5230 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
5231 // This function is not recursive.
5232 // If the top level item is an array, we treat it as a set of children,
5233 // not as a fragment. Nested arrays on the other hand will be treated as
5234 // fragment nodes. Recursion happens at the normal flow.
5235
5236 // Handle top level unkeyed fragments as if they were arrays.
5237 // This leads to an ambiguity between <>{[...]}</> and <>...</>.
5238 // We treat the ambiguous cases above the same.
5239 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
5240 if (isUnkeyedTopLevelFragment) {
5241 newChild = newChild.props.children;
5242 }
5243
5244 // Handle object types
5245 var isObject = typeof newChild === 'object' && newChild !== null;
5246
5247 if (isObject) {
5248 switch (newChild.$$typeof) {
5249 case REACT_ELEMENT_TYPE:
5250 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
5251 case REACT_PORTAL_TYPE:
5252 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
5253 }
5254 }
5255
5256 if (typeof newChild === 'string' || typeof newChild === 'number') {
5257 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
5258 }
5259
5260 if (isArray(newChild)) {
5261 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
5262 }
5263
5264 if (getIteratorFn(newChild)) {
5265 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
5266 }
5267
5268 if (isObject) {
5269 throwOnInvalidObjectType(returnFiber, newChild);
5270 }
5271
5272 {
5273 if (typeof newChild === 'function') {
5274 warnOnFunctionType();
5275 }
5276 }
5277 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
5278 // If the new child is undefined, and the return fiber is a composite
5279 // component, throw an error. If Fiber return types are disabled,
5280 // we already threw above.
5281 switch (returnFiber.tag) {
5282 case ClassComponent:
5283 {
5284 {
5285 var instance = returnFiber.stateNode;
5286 if (instance.render._isMockFunction) {
5287 // We allow auto-mocks to proceed as if they're returning null.
5288 break;
5289 }
5290 }
5291 }
5292 // Intentionally fall through to the next case, which handles both
5293 // functions and classes
5294 // eslint-disable-next-lined no-fallthrough
5295 case FunctionComponent:
5296 {
5297 var Component = returnFiber.type;
5298 (function () {
5299 {
5300 {
5301 throw ReactError((Component.displayName || Component.name || 'Component') + '(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.');
5302 }
5303 }
5304 })();
5305 }
5306 }
5307 }
5308
5309 // Remaining cases are all treated as empty.
5310 return deleteRemainingChildren(returnFiber, currentFirstChild);
5311 }
5312
5313 return reconcileChildFibers;
5314}
5315
5316var reconcileChildFibers = ChildReconciler(true);
5317var mountChildFibers = ChildReconciler(false);
5318
5319function cloneChildFibers(current$$1, workInProgress) {
5320 (function () {
5321 if (!(current$$1 === null || workInProgress.child === current$$1.child)) {
5322 {
5323 throw ReactError('Resuming work not yet implemented.');
5324 }
5325 }
5326 })();
5327
5328 if (workInProgress.child === null) {
5329 return;
5330 }
5331
5332 var currentChild = workInProgress.child;
5333 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5334 workInProgress.child = newChild;
5335
5336 newChild.return = workInProgress;
5337 while (currentChild.sibling !== null) {
5338 currentChild = currentChild.sibling;
5339 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5340 newChild.return = workInProgress;
5341 }
5342 newChild.sibling = null;
5343}
5344
5345var NO_CONTEXT$1 = {};
5346
5347var contextStackCursor$1 = createCursor(NO_CONTEXT$1);
5348var contextFiberStackCursor = createCursor(NO_CONTEXT$1);
5349var rootInstanceStackCursor = createCursor(NO_CONTEXT$1);
5350
5351function requiredContext(c) {
5352 (function () {
5353 if (!(c !== NO_CONTEXT$1)) {
5354 {
5355 throw ReactError('Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.');
5356 }
5357 }
5358 })();
5359 return c;
5360}
5361
5362function getRootHostContainer() {
5363 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5364 return rootInstance;
5365}
5366
5367function pushHostContainer(fiber, nextRootInstance) {
5368 // Push current root instance onto the stack;
5369 // This allows us to reset root when portals are popped.
5370 push(rootInstanceStackCursor, nextRootInstance, fiber);
5371 // Track the context and the Fiber that provided it.
5372 // This enables us to pop only Fibers that provide unique contexts.
5373 push(contextFiberStackCursor, fiber, fiber);
5374
5375 // Finally, we need to push the host context to the stack.
5376 // However, we can't just call getRootHostContext() and push it because
5377 // we'd have a different number of entries on the stack depending on
5378 // whether getRootHostContext() throws somewhere in renderer code or not.
5379 // So we push an empty value first. This lets us safely unwind on errors.
5380 push(contextStackCursor$1, NO_CONTEXT$1, fiber);
5381 var nextRootContext = getRootHostContext(nextRootInstance);
5382 // Now that we know this function doesn't throw, replace it.
5383 pop(contextStackCursor$1, fiber);
5384 push(contextStackCursor$1, nextRootContext, fiber);
5385}
5386
5387function popHostContainer(fiber) {
5388 pop(contextStackCursor$1, fiber);
5389 pop(contextFiberStackCursor, fiber);
5390 pop(rootInstanceStackCursor, fiber);
5391}
5392
5393function getHostContext() {
5394 var context = requiredContext(contextStackCursor$1.current);
5395 return context;
5396}
5397
5398function pushHostContext(fiber) {
5399 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5400 var context = requiredContext(contextStackCursor$1.current);
5401 var nextContext = getChildHostContext(context, fiber.type, rootInstance);
5402
5403 // Don't push this Fiber's context unless it's unique.
5404 if (context === nextContext) {
5405 return;
5406 }
5407
5408 // Track the context and the Fiber that provided it.
5409 // This enables us to pop only Fibers that provide unique contexts.
5410 push(contextFiberStackCursor, fiber, fiber);
5411 push(contextStackCursor$1, nextContext, fiber);
5412}
5413
5414function pushHostContextForEventComponent(fiber) {
5415 var context = requiredContext(contextStackCursor$1.current);
5416 var nextContext = getChildHostContextForEventComponent(context);
5417
5418 // Don't push this Fiber's context unless it's unique.
5419 if (context === nextContext) {
5420 return;
5421 }
5422
5423 // Track the context and the Fiber that provided it.
5424 // This enables us to pop only Fibers that provide unique contexts.
5425 push(contextFiberStackCursor, fiber, fiber);
5426 push(contextStackCursor$1, nextContext, fiber);
5427}
5428
5429function pushHostContextForEventTarget(fiber) {
5430 var context = requiredContext(contextStackCursor$1.current);
5431 var eventTargetType = fiber.type.type;
5432 var nextContext = getChildHostContextForEventTarget(context, eventTargetType);
5433
5434 // Don't push this Fiber's context unless it's unique.
5435 if (context === nextContext) {
5436 return;
5437 }
5438
5439 // Track the context and the Fiber that provided it.
5440 // This enables us to pop only Fibers that provide unique contexts.
5441 push(contextFiberStackCursor, fiber, fiber);
5442 push(contextStackCursor$1, nextContext, fiber);
5443}
5444
5445function popHostContext(fiber) {
5446 // Do not pop unless this Fiber provided the current context.
5447 // pushHostContext() only pushes Fibers that provide unique contexts.
5448 if (contextFiberStackCursor.current !== fiber) {
5449 return;
5450 }
5451
5452 pop(contextStackCursor$1, fiber);
5453 pop(contextFiberStackCursor, fiber);
5454}
5455
5456var NoEffect$1 = /* */0;
5457var UnmountSnapshot = /* */2;
5458var UnmountMutation = /* */4;
5459var MountMutation = /* */8;
5460var UnmountLayout = /* */16;
5461var MountLayout = /* */32;
5462var MountPassive = /* */64;
5463var UnmountPassive = /* */128;
5464
5465var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
5466
5467
5468var didWarnAboutMismatchedHooksForComponent = void 0;
5469{
5470 didWarnAboutMismatchedHooksForComponent = new Set();
5471}
5472
5473// These are set right before calling the component.
5474var renderExpirationTime = NoWork;
5475// The work-in-progress fiber. I've named it differently to distinguish it from
5476// the work-in-progress hook.
5477var currentlyRenderingFiber$1 = null;
5478
5479// Hooks are stored as a linked list on the fiber's memoizedState field. The
5480// current hook list is the list that belongs to the current fiber. The
5481// work-in-progress hook list is a new list that will be added to the
5482// work-in-progress fiber.
5483var currentHook = null;
5484var nextCurrentHook = null;
5485var firstWorkInProgressHook = null;
5486var workInProgressHook = null;
5487var nextWorkInProgressHook = null;
5488
5489var remainingExpirationTime = NoWork;
5490var componentUpdateQueue = null;
5491var sideEffectTag = 0;
5492
5493// Updates scheduled during render will trigger an immediate re-render at the
5494// end of the current pass. We can't store these updates on the normal queue,
5495// because if the work is aborted, they should be discarded. Because this is
5496// a relatively rare case, we also don't want to add an additional field to
5497// either the hook or queue object types. So we store them in a lazily create
5498// map of queue -> render-phase updates, which are discarded once the component
5499// completes without re-rendering.
5500
5501// Whether an update was scheduled during the currently executing render pass.
5502var didScheduleRenderPhaseUpdate = false;
5503// Lazily created map of render-phase updates
5504var renderPhaseUpdates = null;
5505// Counter to prevent infinite loops.
5506var numberOfReRenders = 0;
5507var RE_RENDER_LIMIT = 25;
5508
5509// In DEV, this is the name of the currently executing primitive hook
5510var currentHookNameInDev = null;
5511
5512// In DEV, this list ensures that hooks are called in the same order between renders.
5513// The list stores the order of hooks used during the initial render (mount).
5514// Subsequent renders (updates) reference this list.
5515var hookTypesDev = null;
5516var hookTypesUpdateIndexDev = -1;
5517
5518function mountHookTypesDev() {
5519 {
5520 var hookName = currentHookNameInDev;
5521
5522 if (hookTypesDev === null) {
5523 hookTypesDev = [hookName];
5524 } else {
5525 hookTypesDev.push(hookName);
5526 }
5527 }
5528}
5529
5530function updateHookTypesDev() {
5531 {
5532 var hookName = currentHookNameInDev;
5533
5534 if (hookTypesDev !== null) {
5535 hookTypesUpdateIndexDev++;
5536 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
5537 warnOnHookMismatchInDev(hookName);
5538 }
5539 }
5540 }
5541}
5542
5543function checkDepsAreArrayDev(deps) {
5544 {
5545 if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
5546 // Verify deps, but only on mount to avoid extra checks.
5547 // It's unlikely their type would change as usually you define them inline.
5548 warning$1(false, '%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps);
5549 }
5550 }
5551}
5552
5553function warnOnHookMismatchInDev(currentHookName) {
5554 {
5555 var componentName = getComponentName(currentlyRenderingFiber$1.type);
5556 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
5557 didWarnAboutMismatchedHooksForComponent.add(componentName);
5558
5559 if (hookTypesDev !== null) {
5560 var table = '';
5561
5562 var secondColumnStart = 30;
5563
5564 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
5565 var oldHookName = hookTypesDev[i];
5566 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
5567
5568 var row = i + 1 + '. ' + oldHookName;
5569
5570 // Extra space so second column lines up
5571 // lol @ IE not supporting String#repeat
5572 while (row.length < secondColumnStart) {
5573 row += ' ';
5574 }
5575
5576 row += newHookName + '\n';
5577
5578 table += row;
5579 }
5580
5581 warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
5582 }
5583 }
5584 }
5585}
5586
5587function throwInvalidHookError() {
5588 (function () {
5589 {
5590 {
5591 throw ReactError('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.');
5592 }
5593 }
5594 })();
5595}
5596
5597function areHookInputsEqual(nextDeps, prevDeps) {
5598 if (prevDeps === null) {
5599 {
5600 warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
5601 }
5602 return false;
5603 }
5604
5605 {
5606 // Don't bother comparing lengths in prod because these arrays should be
5607 // passed inline.
5608 if (nextDeps.length !== prevDeps.length) {
5609 warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, '[' + nextDeps.join(', ') + ']', '[' + prevDeps.join(', ') + ']');
5610 }
5611 }
5612 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
5613 if (is(nextDeps[i], prevDeps[i])) {
5614 continue;
5615 }
5616 return false;
5617 }
5618 return true;
5619}
5620
5621function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
5622 renderExpirationTime = nextRenderExpirationTime;
5623 currentlyRenderingFiber$1 = workInProgress;
5624 nextCurrentHook = current !== null ? current.memoizedState : null;
5625
5626 {
5627 hookTypesDev = current !== null ? current._debugHookTypes : null;
5628 hookTypesUpdateIndexDev = -1;
5629 }
5630
5631 // The following should have already been reset
5632 // currentHook = null;
5633 // workInProgressHook = null;
5634
5635 // remainingExpirationTime = NoWork;
5636 // componentUpdateQueue = null;
5637
5638 // didScheduleRenderPhaseUpdate = false;
5639 // renderPhaseUpdates = null;
5640 // numberOfReRenders = 0;
5641 // sideEffectTag = 0;
5642
5643 // TODO Warn if no hooks are used at all during mount, then some are used during update.
5644 // Currently we will identify the update render as a mount because nextCurrentHook === null.
5645 // This is tricky because it's valid for certain types of components (e.g. React.lazy)
5646
5647 // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
5648 // Non-stateful hooks (e.g. context) don't get added to memoizedState,
5649 // so nextCurrentHook would be null during updates and mounts.
5650 {
5651 if (nextCurrentHook !== null) {
5652 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
5653 } else if (hookTypesDev !== null) {
5654 // This dispatcher handles an edge case where a component is updating,
5655 // but no stateful hooks have been used.
5656 // We want to match the production code behavior (which will use HooksDispatcherOnMount),
5657 // but with the extra DEV validation to ensure hooks ordering hasn't changed.
5658 // This dispatcher does that.
5659 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
5660 } else {
5661 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
5662 }
5663 }
5664
5665 var children = Component(props, refOrContext);
5666
5667 if (didScheduleRenderPhaseUpdate) {
5668 do {
5669 didScheduleRenderPhaseUpdate = false;
5670 numberOfReRenders += 1;
5671
5672 // Start over from the beginning of the list
5673 nextCurrentHook = current !== null ? current.memoizedState : null;
5674 nextWorkInProgressHook = firstWorkInProgressHook;
5675
5676 currentHook = null;
5677 workInProgressHook = null;
5678 componentUpdateQueue = null;
5679
5680 {
5681 // Also validate hook order for cascading updates.
5682 hookTypesUpdateIndexDev = -1;
5683 }
5684
5685 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
5686
5687 children = Component(props, refOrContext);
5688 } while (didScheduleRenderPhaseUpdate);
5689
5690 renderPhaseUpdates = null;
5691 numberOfReRenders = 0;
5692 }
5693
5694 // We can assume the previous dispatcher is always this one, since we set it
5695 // at the beginning of the render phase and there's no re-entrancy.
5696 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
5697
5698 var renderedWork = currentlyRenderingFiber$1;
5699
5700 renderedWork.memoizedState = firstWorkInProgressHook;
5701 renderedWork.expirationTime = remainingExpirationTime;
5702 renderedWork.updateQueue = componentUpdateQueue;
5703 renderedWork.effectTag |= sideEffectTag;
5704
5705 {
5706 renderedWork._debugHookTypes = hookTypesDev;
5707 }
5708
5709 // This check uses currentHook so that it works the same in DEV and prod bundles.
5710 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
5711 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
5712
5713 renderExpirationTime = NoWork;
5714 currentlyRenderingFiber$1 = null;
5715
5716 currentHook = null;
5717 nextCurrentHook = null;
5718 firstWorkInProgressHook = null;
5719 workInProgressHook = null;
5720 nextWorkInProgressHook = null;
5721
5722 {
5723 currentHookNameInDev = null;
5724 hookTypesDev = null;
5725 hookTypesUpdateIndexDev = -1;
5726 }
5727
5728 remainingExpirationTime = NoWork;
5729 componentUpdateQueue = null;
5730 sideEffectTag = 0;
5731
5732 // These were reset above
5733 // didScheduleRenderPhaseUpdate = false;
5734 // renderPhaseUpdates = null;
5735 // numberOfReRenders = 0;
5736
5737 (function () {
5738 if (!!didRenderTooFewHooks) {
5739 {
5740 throw ReactError('Rendered fewer hooks than expected. This may be caused by an accidental early return statement.');
5741 }
5742 }
5743 })();
5744
5745 return children;
5746}
5747
5748function bailoutHooks(current, workInProgress, expirationTime) {
5749 workInProgress.updateQueue = current.updateQueue;
5750 workInProgress.effectTag &= ~(Passive | Update);
5751 if (current.expirationTime <= expirationTime) {
5752 current.expirationTime = NoWork;
5753 }
5754}
5755
5756function resetHooks() {
5757 // We can assume the previous dispatcher is always this one, since we set it
5758 // at the beginning of the render phase and there's no re-entrancy.
5759 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
5760
5761 // This is used to reset the state of this module when a component throws.
5762 // It's also called inside mountIndeterminateComponent if we determine the
5763 // component is a module-style component.
5764 renderExpirationTime = NoWork;
5765 currentlyRenderingFiber$1 = null;
5766
5767 currentHook = null;
5768 nextCurrentHook = null;
5769 firstWorkInProgressHook = null;
5770 workInProgressHook = null;
5771 nextWorkInProgressHook = null;
5772
5773 {
5774 hookTypesDev = null;
5775 hookTypesUpdateIndexDev = -1;
5776
5777 currentHookNameInDev = null;
5778 }
5779
5780 remainingExpirationTime = NoWork;
5781 componentUpdateQueue = null;
5782 sideEffectTag = 0;
5783
5784 didScheduleRenderPhaseUpdate = false;
5785 renderPhaseUpdates = null;
5786 numberOfReRenders = 0;
5787}
5788
5789function mountWorkInProgressHook() {
5790 var hook = {
5791 memoizedState: null,
5792
5793 baseState: null,
5794 queue: null,
5795 baseUpdate: null,
5796
5797 next: null
5798 };
5799
5800 if (workInProgressHook === null) {
5801 // This is the first hook in the list
5802 firstWorkInProgressHook = workInProgressHook = hook;
5803 } else {
5804 // Append to the end of the list
5805 workInProgressHook = workInProgressHook.next = hook;
5806 }
5807 return workInProgressHook;
5808}
5809
5810function updateWorkInProgressHook() {
5811 // This function is used both for updates and for re-renders triggered by a
5812 // render phase update. It assumes there is either a current hook we can
5813 // clone, or a work-in-progress hook from a previous render pass that we can
5814 // use as a base. When we reach the end of the base list, we must switch to
5815 // the dispatcher used for mounts.
5816 if (nextWorkInProgressHook !== null) {
5817 // There's already a work-in-progress. Reuse it.
5818 workInProgressHook = nextWorkInProgressHook;
5819 nextWorkInProgressHook = workInProgressHook.next;
5820
5821 currentHook = nextCurrentHook;
5822 nextCurrentHook = currentHook !== null ? currentHook.next : null;
5823 } else {
5824 // Clone from the current hook.
5825 (function () {
5826 if (!(nextCurrentHook !== null)) {
5827 {
5828 throw ReactError('Rendered more hooks than during the previous render.');
5829 }
5830 }
5831 })();
5832 currentHook = nextCurrentHook;
5833
5834 var newHook = {
5835 memoizedState: currentHook.memoizedState,
5836
5837 baseState: currentHook.baseState,
5838 queue: currentHook.queue,
5839 baseUpdate: currentHook.baseUpdate,
5840
5841 next: null
5842 };
5843
5844 if (workInProgressHook === null) {
5845 // This is the first hook in the list.
5846 workInProgressHook = firstWorkInProgressHook = newHook;
5847 } else {
5848 // Append to the end of the list.
5849 workInProgressHook = workInProgressHook.next = newHook;
5850 }
5851 nextCurrentHook = currentHook.next;
5852 }
5853 return workInProgressHook;
5854}
5855
5856function createFunctionComponentUpdateQueue() {
5857 return {
5858 lastEffect: null
5859 };
5860}
5861
5862function basicStateReducer(state, action) {
5863 return typeof action === 'function' ? action(state) : action;
5864}
5865
5866function mountReducer(reducer, initialArg, init) {
5867 var hook = mountWorkInProgressHook();
5868 var initialState = void 0;
5869 if (init !== undefined) {
5870 initialState = init(initialArg);
5871 } else {
5872 initialState = initialArg;
5873 }
5874 hook.memoizedState = hook.baseState = initialState;
5875 var queue = hook.queue = {
5876 last: null,
5877 dispatch: null,
5878 lastRenderedReducer: reducer,
5879 lastRenderedState: initialState
5880 };
5881 var dispatch = queue.dispatch = dispatchAction.bind(null,
5882 // Flow doesn't know this is non-null, but we do.
5883 currentlyRenderingFiber$1, queue);
5884 return [hook.memoizedState, dispatch];
5885}
5886
5887function updateReducer(reducer, initialArg, init) {
5888 var hook = updateWorkInProgressHook();
5889 var queue = hook.queue;
5890 (function () {
5891 if (!(queue !== null)) {
5892 {
5893 throw ReactError('Should have a queue. This is likely a bug in React. Please file an issue.');
5894 }
5895 }
5896 })();
5897
5898 queue.lastRenderedReducer = reducer;
5899
5900 if (numberOfReRenders > 0) {
5901 // This is a re-render. Apply the new render phase updates to the previous
5902 var _dispatch = queue.dispatch;
5903 if (renderPhaseUpdates !== null) {
5904 // Render phase updates are stored in a map of queue -> linked list
5905 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
5906 if (firstRenderPhaseUpdate !== undefined) {
5907 renderPhaseUpdates.delete(queue);
5908 var newState = hook.memoizedState;
5909 var update = firstRenderPhaseUpdate;
5910 do {
5911 // Process this render phase update. We don't have to check the
5912 // priority because it will always be the same as the current
5913 // render's.
5914 var _action = update.action;
5915 newState = reducer(newState, _action);
5916 update = update.next;
5917 } while (update !== null);
5918
5919 // Mark that the fiber performed work, but only if the new state is
5920 // different from the current state.
5921 if (!is(newState, hook.memoizedState)) {
5922 markWorkInProgressReceivedUpdate();
5923 }
5924
5925 hook.memoizedState = newState;
5926 // Don't persist the state accumlated from the render phase updates to
5927 // the base state unless the queue is empty.
5928 // TODO: Not sure if this is the desired semantics, but it's what we
5929 // do for gDSFP. I can't remember why.
5930 if (hook.baseUpdate === queue.last) {
5931 hook.baseState = newState;
5932 }
5933
5934 queue.lastRenderedState = newState;
5935
5936 return [newState, _dispatch];
5937 }
5938 }
5939 return [hook.memoizedState, _dispatch];
5940 }
5941
5942 // The last update in the entire queue
5943 var last = queue.last;
5944 // The last update that is part of the base state.
5945 var baseUpdate = hook.baseUpdate;
5946 var baseState = hook.baseState;
5947
5948 // Find the first unprocessed update.
5949 var first = void 0;
5950 if (baseUpdate !== null) {
5951 if (last !== null) {
5952 // For the first update, the queue is a circular linked list where
5953 // `queue.last.next = queue.first`. Once the first update commits, and
5954 // the `baseUpdate` is no longer empty, we can unravel the list.
5955 last.next = null;
5956 }
5957 first = baseUpdate.next;
5958 } else {
5959 first = last !== null ? last.next : null;
5960 }
5961 if (first !== null) {
5962 var _newState = baseState;
5963 var newBaseState = null;
5964 var newBaseUpdate = null;
5965 var prevUpdate = baseUpdate;
5966 var _update = first;
5967 var didSkip = false;
5968 do {
5969 var updateExpirationTime = _update.expirationTime;
5970 if (updateExpirationTime < renderExpirationTime) {
5971 // Priority is insufficient. Skip this update. If this is the first
5972 // skipped update, the previous update/state is the new base
5973 // update/state.
5974 if (!didSkip) {
5975 didSkip = true;
5976 newBaseUpdate = prevUpdate;
5977 newBaseState = _newState;
5978 }
5979 // Update the remaining priority in the queue.
5980 if (updateExpirationTime > remainingExpirationTime) {
5981 remainingExpirationTime = updateExpirationTime;
5982 }
5983 } else {
5984 // Process this update.
5985 if (_update.eagerReducer === reducer) {
5986 // If this update was processed eagerly, and its reducer matches the
5987 // current reducer, we can use the eagerly computed state.
5988 _newState = _update.eagerState;
5989 } else {
5990 var _action2 = _update.action;
5991 _newState = reducer(_newState, _action2);
5992 }
5993 }
5994 prevUpdate = _update;
5995 _update = _update.next;
5996 } while (_update !== null && _update !== first);
5997
5998 if (!didSkip) {
5999 newBaseUpdate = prevUpdate;
6000 newBaseState = _newState;
6001 }
6002
6003 // Mark that the fiber performed work, but only if the new state is
6004 // different from the current state.
6005 if (!is(_newState, hook.memoizedState)) {
6006 markWorkInProgressReceivedUpdate();
6007 }
6008
6009 hook.memoizedState = _newState;
6010 hook.baseUpdate = newBaseUpdate;
6011 hook.baseState = newBaseState;
6012
6013 queue.lastRenderedState = _newState;
6014 }
6015
6016 var dispatch = queue.dispatch;
6017 return [hook.memoizedState, dispatch];
6018}
6019
6020function mountState(initialState) {
6021 var hook = mountWorkInProgressHook();
6022 if (typeof initialState === 'function') {
6023 initialState = initialState();
6024 }
6025 hook.memoizedState = hook.baseState = initialState;
6026 var queue = hook.queue = {
6027 last: null,
6028 dispatch: null,
6029 lastRenderedReducer: basicStateReducer,
6030 lastRenderedState: initialState
6031 };
6032 var dispatch = queue.dispatch = dispatchAction.bind(null,
6033 // Flow doesn't know this is non-null, but we do.
6034 currentlyRenderingFiber$1, queue);
6035 return [hook.memoizedState, dispatch];
6036}
6037
6038function updateState(initialState) {
6039 return updateReducer(basicStateReducer, initialState);
6040}
6041
6042function pushEffect(tag, create, destroy, deps) {
6043 var effect = {
6044 tag: tag,
6045 create: create,
6046 destroy: destroy,
6047 deps: deps,
6048 // Circular
6049 next: null
6050 };
6051 if (componentUpdateQueue === null) {
6052 componentUpdateQueue = createFunctionComponentUpdateQueue();
6053 componentUpdateQueue.lastEffect = effect.next = effect;
6054 } else {
6055 var _lastEffect = componentUpdateQueue.lastEffect;
6056 if (_lastEffect === null) {
6057 componentUpdateQueue.lastEffect = effect.next = effect;
6058 } else {
6059 var firstEffect = _lastEffect.next;
6060 _lastEffect.next = effect;
6061 effect.next = firstEffect;
6062 componentUpdateQueue.lastEffect = effect;
6063 }
6064 }
6065 return effect;
6066}
6067
6068function mountRef(initialValue) {
6069 var hook = mountWorkInProgressHook();
6070 var ref = { current: initialValue };
6071 {
6072 Object.seal(ref);
6073 }
6074 hook.memoizedState = ref;
6075 return ref;
6076}
6077
6078function updateRef(initialValue) {
6079 var hook = updateWorkInProgressHook();
6080 return hook.memoizedState;
6081}
6082
6083function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6084 var hook = mountWorkInProgressHook();
6085 var nextDeps = deps === undefined ? null : deps;
6086 sideEffectTag |= fiberEffectTag;
6087 hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
6088}
6089
6090function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6091 var hook = updateWorkInProgressHook();
6092 var nextDeps = deps === undefined ? null : deps;
6093 var destroy = undefined;
6094
6095 if (currentHook !== null) {
6096 var prevEffect = currentHook.memoizedState;
6097 destroy = prevEffect.destroy;
6098 if (nextDeps !== null) {
6099 var prevDeps = prevEffect.deps;
6100 if (areHookInputsEqual(nextDeps, prevDeps)) {
6101 pushEffect(NoEffect$1, create, destroy, nextDeps);
6102 return;
6103 }
6104 }
6105 }
6106
6107 sideEffectTag |= fiberEffectTag;
6108 hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
6109}
6110
6111function mountEffect(create, deps) {
6112 return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6113}
6114
6115function updateEffect(create, deps) {
6116 return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6117}
6118
6119function mountLayoutEffect(create, deps) {
6120 return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6121}
6122
6123function updateLayoutEffect(create, deps) {
6124 return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6125}
6126
6127function imperativeHandleEffect(create, ref) {
6128 if (typeof ref === 'function') {
6129 var refCallback = ref;
6130 var _inst = create();
6131 refCallback(_inst);
6132 return function () {
6133 refCallback(null);
6134 };
6135 } else if (ref !== null && ref !== undefined) {
6136 var refObject = ref;
6137 {
6138 !refObject.hasOwnProperty('current') ? warning$1(false, 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}') : void 0;
6139 }
6140 var _inst2 = create();
6141 refObject.current = _inst2;
6142 return function () {
6143 refObject.current = null;
6144 };
6145 }
6146}
6147
6148function mountImperativeHandle(ref, create, deps) {
6149 {
6150 !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
6151 }
6152
6153 // TODO: If deps are provided, should we skip comparing the ref itself?
6154 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6155
6156 return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6157}
6158
6159function updateImperativeHandle(ref, create, deps) {
6160 {
6161 !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
6162 }
6163
6164 // TODO: If deps are provided, should we skip comparing the ref itself?
6165 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6166
6167 return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6168}
6169
6170function mountDebugValue(value, formatterFn) {
6171 // This hook is normally a no-op.
6172 // The react-debug-hooks package injects its own implementation
6173 // so that e.g. DevTools can display custom hook values.
6174}
6175
6176var updateDebugValue = mountDebugValue;
6177
6178function mountCallback(callback, deps) {
6179 var hook = mountWorkInProgressHook();
6180 var nextDeps = deps === undefined ? null : deps;
6181 hook.memoizedState = [callback, nextDeps];
6182 return callback;
6183}
6184
6185function updateCallback(callback, deps) {
6186 var hook = updateWorkInProgressHook();
6187 var nextDeps = deps === undefined ? null : deps;
6188 var prevState = hook.memoizedState;
6189 if (prevState !== null) {
6190 if (nextDeps !== null) {
6191 var prevDeps = prevState[1];
6192 if (areHookInputsEqual(nextDeps, prevDeps)) {
6193 return prevState[0];
6194 }
6195 }
6196 }
6197 hook.memoizedState = [callback, nextDeps];
6198 return callback;
6199}
6200
6201function mountMemo(nextCreate, deps) {
6202 var hook = mountWorkInProgressHook();
6203 var nextDeps = deps === undefined ? null : deps;
6204 var nextValue = nextCreate();
6205 hook.memoizedState = [nextValue, nextDeps];
6206 return nextValue;
6207}
6208
6209function updateMemo(nextCreate, deps) {
6210 var hook = updateWorkInProgressHook();
6211 var nextDeps = deps === undefined ? null : deps;
6212 var prevState = hook.memoizedState;
6213 if (prevState !== null) {
6214 // Assume these are defined. If they're not, areHookInputsEqual will warn.
6215 if (nextDeps !== null) {
6216 var prevDeps = prevState[1];
6217 if (areHookInputsEqual(nextDeps, prevDeps)) {
6218 return prevState[0];
6219 }
6220 }
6221 }
6222 var nextValue = nextCreate();
6223 hook.memoizedState = [nextValue, nextDeps];
6224 return nextValue;
6225}
6226
6227function dispatchAction(fiber, queue, action) {
6228 (function () {
6229 if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
6230 {
6231 throw ReactError('Too many re-renders. React limits the number of renders to prevent an infinite loop.');
6232 }
6233 }
6234 })();
6235
6236 {
6237 !(arguments.length <= 3) ? warning$1(false, "State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().') : void 0;
6238 }
6239
6240 var alternate = fiber.alternate;
6241 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
6242 // This is a render phase update. Stash it in a lazily-created map of
6243 // queue -> linked list of updates. After this render pass, we'll restart
6244 // and apply the stashed updates on top of the work-in-progress hook.
6245 didScheduleRenderPhaseUpdate = true;
6246 var update = {
6247 expirationTime: renderExpirationTime,
6248 action: action,
6249 eagerReducer: null,
6250 eagerState: null,
6251 next: null
6252 };
6253 if (renderPhaseUpdates === null) {
6254 renderPhaseUpdates = new Map();
6255 }
6256 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
6257 if (firstRenderPhaseUpdate === undefined) {
6258 renderPhaseUpdates.set(queue, update);
6259 } else {
6260 // Append the update to the end of the list.
6261 var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
6262 while (lastRenderPhaseUpdate.next !== null) {
6263 lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
6264 }
6265 lastRenderPhaseUpdate.next = update;
6266 }
6267 } else {
6268 flushPassiveEffects$$1();
6269
6270 var currentTime = requestCurrentTime$$1();
6271 var _expirationTime = computeExpirationForFiber$$1(currentTime, fiber);
6272
6273 var _update2 = {
6274 expirationTime: _expirationTime,
6275 action: action,
6276 eagerReducer: null,
6277 eagerState: null,
6278 next: null
6279 };
6280
6281 // Append the update to the end of the list.
6282 var _last = queue.last;
6283 if (_last === null) {
6284 // This is the first update. Create a circular list.
6285 _update2.next = _update2;
6286 } else {
6287 var first = _last.next;
6288 if (first !== null) {
6289 // Still circular.
6290 _update2.next = first;
6291 }
6292 _last.next = _update2;
6293 }
6294 queue.last = _update2;
6295
6296 if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
6297 // The queue is currently empty, which means we can eagerly compute the
6298 // next state before entering the render phase. If the new state is the
6299 // same as the current state, we may be able to bail out entirely.
6300 var _lastRenderedReducer = queue.lastRenderedReducer;
6301 if (_lastRenderedReducer !== null) {
6302 var prevDispatcher = void 0;
6303 {
6304 prevDispatcher = ReactCurrentDispatcher$1.current;
6305 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6306 }
6307 try {
6308 var currentState = queue.lastRenderedState;
6309 var _eagerState = _lastRenderedReducer(currentState, action);
6310 // Stash the eagerly computed state, and the reducer used to compute
6311 // it, on the update object. If the reducer hasn't changed by the
6312 // time we enter the render phase, then the eager state can be used
6313 // without calling the reducer again.
6314 _update2.eagerReducer = _lastRenderedReducer;
6315 _update2.eagerState = _eagerState;
6316 if (is(_eagerState, currentState)) {
6317 // Fast path. We can bail out without scheduling React to re-render.
6318 // It's still possible that we'll need to rebase this update later,
6319 // if the component re-renders for a different reason and by that
6320 // time the reducer has changed.
6321 return;
6322 }
6323 } catch (error) {
6324 // Suppress the error. It will throw again in the render phase.
6325 } finally {
6326 {
6327 ReactCurrentDispatcher$1.current = prevDispatcher;
6328 }
6329 }
6330 }
6331 }
6332 {
6333 // jest isn't a 'global', it's just exposed to tests via a wrapped function
6334 // further, this isn't a test file, so flow doesn't recognize the symbol. So...
6335 // $FlowExpectedError - because requirements don't give a damn about your type sigs.
6336 if ('undefined' !== typeof jest) {
6337 warnIfNotCurrentlyActingUpdatesInDev$$1(fiber);
6338 }
6339 }
6340 scheduleWork$$1(fiber, _expirationTime);
6341 }
6342}
6343
6344var ContextOnlyDispatcher = {
6345 readContext: readContext,
6346
6347 useCallback: throwInvalidHookError,
6348 useContext: throwInvalidHookError,
6349 useEffect: throwInvalidHookError,
6350 useImperativeHandle: throwInvalidHookError,
6351 useLayoutEffect: throwInvalidHookError,
6352 useMemo: throwInvalidHookError,
6353 useReducer: throwInvalidHookError,
6354 useRef: throwInvalidHookError,
6355 useState: throwInvalidHookError,
6356 useDebugValue: throwInvalidHookError
6357};
6358
6359var HooksDispatcherOnMountInDEV = null;
6360var HooksDispatcherOnMountWithHookTypesInDEV = null;
6361var HooksDispatcherOnUpdateInDEV = null;
6362var InvalidNestedHooksDispatcherOnMountInDEV = null;
6363var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
6364
6365{
6366 var warnInvalidContextAccess = function () {
6367 warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
6368 };
6369
6370 var warnInvalidHookAccess = function () {
6371 warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
6372 };
6373
6374 HooksDispatcherOnMountInDEV = {
6375 readContext: function (context, observedBits) {
6376 return readContext(context, observedBits);
6377 },
6378 useCallback: function (callback, deps) {
6379 currentHookNameInDev = 'useCallback';
6380 mountHookTypesDev();
6381 checkDepsAreArrayDev(deps);
6382 return mountCallback(callback, deps);
6383 },
6384 useContext: function (context, observedBits) {
6385 currentHookNameInDev = 'useContext';
6386 mountHookTypesDev();
6387 return readContext(context, observedBits);
6388 },
6389 useEffect: function (create, deps) {
6390 currentHookNameInDev = 'useEffect';
6391 mountHookTypesDev();
6392 checkDepsAreArrayDev(deps);
6393 return mountEffect(create, deps);
6394 },
6395 useImperativeHandle: function (ref, create, deps) {
6396 currentHookNameInDev = 'useImperativeHandle';
6397 mountHookTypesDev();
6398 checkDepsAreArrayDev(deps);
6399 return mountImperativeHandle(ref, create, deps);
6400 },
6401 useLayoutEffect: function (create, deps) {
6402 currentHookNameInDev = 'useLayoutEffect';
6403 mountHookTypesDev();
6404 checkDepsAreArrayDev(deps);
6405 return mountLayoutEffect(create, deps);
6406 },
6407 useMemo: function (create, deps) {
6408 currentHookNameInDev = 'useMemo';
6409 mountHookTypesDev();
6410 checkDepsAreArrayDev(deps);
6411 var prevDispatcher = ReactCurrentDispatcher$1.current;
6412 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6413 try {
6414 return mountMemo(create, deps);
6415 } finally {
6416 ReactCurrentDispatcher$1.current = prevDispatcher;
6417 }
6418 },
6419 useReducer: function (reducer, initialArg, init) {
6420 currentHookNameInDev = 'useReducer';
6421 mountHookTypesDev();
6422 var prevDispatcher = ReactCurrentDispatcher$1.current;
6423 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6424 try {
6425 return mountReducer(reducer, initialArg, init);
6426 } finally {
6427 ReactCurrentDispatcher$1.current = prevDispatcher;
6428 }
6429 },
6430 useRef: function (initialValue) {
6431 currentHookNameInDev = 'useRef';
6432 mountHookTypesDev();
6433 return mountRef(initialValue);
6434 },
6435 useState: function (initialState) {
6436 currentHookNameInDev = 'useState';
6437 mountHookTypesDev();
6438 var prevDispatcher = ReactCurrentDispatcher$1.current;
6439 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6440 try {
6441 return mountState(initialState);
6442 } finally {
6443 ReactCurrentDispatcher$1.current = prevDispatcher;
6444 }
6445 },
6446 useDebugValue: function (value, formatterFn) {
6447 currentHookNameInDev = 'useDebugValue';
6448 mountHookTypesDev();
6449 return mountDebugValue(value, formatterFn);
6450 }
6451 };
6452
6453 HooksDispatcherOnMountWithHookTypesInDEV = {
6454 readContext: function (context, observedBits) {
6455 return readContext(context, observedBits);
6456 },
6457 useCallback: function (callback, deps) {
6458 currentHookNameInDev = 'useCallback';
6459 updateHookTypesDev();
6460 return mountCallback(callback, deps);
6461 },
6462 useContext: function (context, observedBits) {
6463 currentHookNameInDev = 'useContext';
6464 updateHookTypesDev();
6465 return readContext(context, observedBits);
6466 },
6467 useEffect: function (create, deps) {
6468 currentHookNameInDev = 'useEffect';
6469 updateHookTypesDev();
6470 return mountEffect(create, deps);
6471 },
6472 useImperativeHandle: function (ref, create, deps) {
6473 currentHookNameInDev = 'useImperativeHandle';
6474 updateHookTypesDev();
6475 return mountImperativeHandle(ref, create, deps);
6476 },
6477 useLayoutEffect: function (create, deps) {
6478 currentHookNameInDev = 'useLayoutEffect';
6479 updateHookTypesDev();
6480 return mountLayoutEffect(create, deps);
6481 },
6482 useMemo: function (create, deps) {
6483 currentHookNameInDev = 'useMemo';
6484 updateHookTypesDev();
6485 var prevDispatcher = ReactCurrentDispatcher$1.current;
6486 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6487 try {
6488 return mountMemo(create, deps);
6489 } finally {
6490 ReactCurrentDispatcher$1.current = prevDispatcher;
6491 }
6492 },
6493 useReducer: function (reducer, initialArg, init) {
6494 currentHookNameInDev = 'useReducer';
6495 updateHookTypesDev();
6496 var prevDispatcher = ReactCurrentDispatcher$1.current;
6497 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6498 try {
6499 return mountReducer(reducer, initialArg, init);
6500 } finally {
6501 ReactCurrentDispatcher$1.current = prevDispatcher;
6502 }
6503 },
6504 useRef: function (initialValue) {
6505 currentHookNameInDev = 'useRef';
6506 updateHookTypesDev();
6507 return mountRef(initialValue);
6508 },
6509 useState: function (initialState) {
6510 currentHookNameInDev = 'useState';
6511 updateHookTypesDev();
6512 var prevDispatcher = ReactCurrentDispatcher$1.current;
6513 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6514 try {
6515 return mountState(initialState);
6516 } finally {
6517 ReactCurrentDispatcher$1.current = prevDispatcher;
6518 }
6519 },
6520 useDebugValue: function (value, formatterFn) {
6521 currentHookNameInDev = 'useDebugValue';
6522 updateHookTypesDev();
6523 return mountDebugValue(value, formatterFn);
6524 }
6525 };
6526
6527 HooksDispatcherOnUpdateInDEV = {
6528 readContext: function (context, observedBits) {
6529 return readContext(context, observedBits);
6530 },
6531 useCallback: function (callback, deps) {
6532 currentHookNameInDev = 'useCallback';
6533 updateHookTypesDev();
6534 return updateCallback(callback, deps);
6535 },
6536 useContext: function (context, observedBits) {
6537 currentHookNameInDev = 'useContext';
6538 updateHookTypesDev();
6539 return readContext(context, observedBits);
6540 },
6541 useEffect: function (create, deps) {
6542 currentHookNameInDev = 'useEffect';
6543 updateHookTypesDev();
6544 return updateEffect(create, deps);
6545 },
6546 useImperativeHandle: function (ref, create, deps) {
6547 currentHookNameInDev = 'useImperativeHandle';
6548 updateHookTypesDev();
6549 return updateImperativeHandle(ref, create, deps);
6550 },
6551 useLayoutEffect: function (create, deps) {
6552 currentHookNameInDev = 'useLayoutEffect';
6553 updateHookTypesDev();
6554 return updateLayoutEffect(create, deps);
6555 },
6556 useMemo: function (create, deps) {
6557 currentHookNameInDev = 'useMemo';
6558 updateHookTypesDev();
6559 var prevDispatcher = ReactCurrentDispatcher$1.current;
6560 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6561 try {
6562 return updateMemo(create, deps);
6563 } finally {
6564 ReactCurrentDispatcher$1.current = prevDispatcher;
6565 }
6566 },
6567 useReducer: function (reducer, initialArg, init) {
6568 currentHookNameInDev = 'useReducer';
6569 updateHookTypesDev();
6570 var prevDispatcher = ReactCurrentDispatcher$1.current;
6571 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6572 try {
6573 return updateReducer(reducer, initialArg, init);
6574 } finally {
6575 ReactCurrentDispatcher$1.current = prevDispatcher;
6576 }
6577 },
6578 useRef: function (initialValue) {
6579 currentHookNameInDev = 'useRef';
6580 updateHookTypesDev();
6581 return updateRef(initialValue);
6582 },
6583 useState: function (initialState) {
6584 currentHookNameInDev = 'useState';
6585 updateHookTypesDev();
6586 var prevDispatcher = ReactCurrentDispatcher$1.current;
6587 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6588 try {
6589 return updateState(initialState);
6590 } finally {
6591 ReactCurrentDispatcher$1.current = prevDispatcher;
6592 }
6593 },
6594 useDebugValue: function (value, formatterFn) {
6595 currentHookNameInDev = 'useDebugValue';
6596 updateHookTypesDev();
6597 return updateDebugValue(value, formatterFn);
6598 }
6599 };
6600
6601 InvalidNestedHooksDispatcherOnMountInDEV = {
6602 readContext: function (context, observedBits) {
6603 warnInvalidContextAccess();
6604 return readContext(context, observedBits);
6605 },
6606 useCallback: function (callback, deps) {
6607 currentHookNameInDev = 'useCallback';
6608 warnInvalidHookAccess();
6609 mountHookTypesDev();
6610 return mountCallback(callback, deps);
6611 },
6612 useContext: function (context, observedBits) {
6613 currentHookNameInDev = 'useContext';
6614 warnInvalidHookAccess();
6615 mountHookTypesDev();
6616 return readContext(context, observedBits);
6617 },
6618 useEffect: function (create, deps) {
6619 currentHookNameInDev = 'useEffect';
6620 warnInvalidHookAccess();
6621 mountHookTypesDev();
6622 return mountEffect(create, deps);
6623 },
6624 useImperativeHandle: function (ref, create, deps) {
6625 currentHookNameInDev = 'useImperativeHandle';
6626 warnInvalidHookAccess();
6627 mountHookTypesDev();
6628 return mountImperativeHandle(ref, create, deps);
6629 },
6630 useLayoutEffect: function (create, deps) {
6631 currentHookNameInDev = 'useLayoutEffect';
6632 warnInvalidHookAccess();
6633 mountHookTypesDev();
6634 return mountLayoutEffect(create, deps);
6635 },
6636 useMemo: function (create, deps) {
6637 currentHookNameInDev = 'useMemo';
6638 warnInvalidHookAccess();
6639 mountHookTypesDev();
6640 var prevDispatcher = ReactCurrentDispatcher$1.current;
6641 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6642 try {
6643 return mountMemo(create, deps);
6644 } finally {
6645 ReactCurrentDispatcher$1.current = prevDispatcher;
6646 }
6647 },
6648 useReducer: function (reducer, initialArg, init) {
6649 currentHookNameInDev = 'useReducer';
6650 warnInvalidHookAccess();
6651 mountHookTypesDev();
6652 var prevDispatcher = ReactCurrentDispatcher$1.current;
6653 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6654 try {
6655 return mountReducer(reducer, initialArg, init);
6656 } finally {
6657 ReactCurrentDispatcher$1.current = prevDispatcher;
6658 }
6659 },
6660 useRef: function (initialValue) {
6661 currentHookNameInDev = 'useRef';
6662 warnInvalidHookAccess();
6663 mountHookTypesDev();
6664 return mountRef(initialValue);
6665 },
6666 useState: function (initialState) {
6667 currentHookNameInDev = 'useState';
6668 warnInvalidHookAccess();
6669 mountHookTypesDev();
6670 var prevDispatcher = ReactCurrentDispatcher$1.current;
6671 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6672 try {
6673 return mountState(initialState);
6674 } finally {
6675 ReactCurrentDispatcher$1.current = prevDispatcher;
6676 }
6677 },
6678 useDebugValue: function (value, formatterFn) {
6679 currentHookNameInDev = 'useDebugValue';
6680 warnInvalidHookAccess();
6681 mountHookTypesDev();
6682 return mountDebugValue(value, formatterFn);
6683 }
6684 };
6685
6686 InvalidNestedHooksDispatcherOnUpdateInDEV = {
6687 readContext: function (context, observedBits) {
6688 warnInvalidContextAccess();
6689 return readContext(context, observedBits);
6690 },
6691 useCallback: function (callback, deps) {
6692 currentHookNameInDev = 'useCallback';
6693 warnInvalidHookAccess();
6694 updateHookTypesDev();
6695 return updateCallback(callback, deps);
6696 },
6697 useContext: function (context, observedBits) {
6698 currentHookNameInDev = 'useContext';
6699 warnInvalidHookAccess();
6700 updateHookTypesDev();
6701 return readContext(context, observedBits);
6702 },
6703 useEffect: function (create, deps) {
6704 currentHookNameInDev = 'useEffect';
6705 warnInvalidHookAccess();
6706 updateHookTypesDev();
6707 return updateEffect(create, deps);
6708 },
6709 useImperativeHandle: function (ref, create, deps) {
6710 currentHookNameInDev = 'useImperativeHandle';
6711 warnInvalidHookAccess();
6712 updateHookTypesDev();
6713 return updateImperativeHandle(ref, create, deps);
6714 },
6715 useLayoutEffect: function (create, deps) {
6716 currentHookNameInDev = 'useLayoutEffect';
6717 warnInvalidHookAccess();
6718 updateHookTypesDev();
6719 return updateLayoutEffect(create, deps);
6720 },
6721 useMemo: function (create, deps) {
6722 currentHookNameInDev = 'useMemo';
6723 warnInvalidHookAccess();
6724 updateHookTypesDev();
6725 var prevDispatcher = ReactCurrentDispatcher$1.current;
6726 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6727 try {
6728 return updateMemo(create, deps);
6729 } finally {
6730 ReactCurrentDispatcher$1.current = prevDispatcher;
6731 }
6732 },
6733 useReducer: function (reducer, initialArg, init) {
6734 currentHookNameInDev = 'useReducer';
6735 warnInvalidHookAccess();
6736 updateHookTypesDev();
6737 var prevDispatcher = ReactCurrentDispatcher$1.current;
6738 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6739 try {
6740 return updateReducer(reducer, initialArg, init);
6741 } finally {
6742 ReactCurrentDispatcher$1.current = prevDispatcher;
6743 }
6744 },
6745 useRef: function (initialValue) {
6746 currentHookNameInDev = 'useRef';
6747 warnInvalidHookAccess();
6748 updateHookTypesDev();
6749 return updateRef(initialValue);
6750 },
6751 useState: function (initialState) {
6752 currentHookNameInDev = 'useState';
6753 warnInvalidHookAccess();
6754 updateHookTypesDev();
6755 var prevDispatcher = ReactCurrentDispatcher$1.current;
6756 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6757 try {
6758 return updateState(initialState);
6759 } finally {
6760 ReactCurrentDispatcher$1.current = prevDispatcher;
6761 }
6762 },
6763 useDebugValue: function (value, formatterFn) {
6764 currentHookNameInDev = 'useDebugValue';
6765 warnInvalidHookAccess();
6766 updateHookTypesDev();
6767 return updateDebugValue(value, formatterFn);
6768 }
6769 };
6770}
6771
6772// Intentionally not named imports because Rollup would use dynamic dispatch for
6773// CommonJS interop named imports.
6774var now$3 = Scheduler.unstable_now;
6775
6776
6777var commitTime = 0;
6778var profilerStartTime = -1;
6779
6780function getCommitTime() {
6781 return commitTime;
6782}
6783
6784function recordCommitTime() {
6785 if (!enableProfilerTimer) {
6786 return;
6787 }
6788 commitTime = now$3();
6789}
6790
6791function startProfilerTimer(fiber) {
6792 if (!enableProfilerTimer) {
6793 return;
6794 }
6795
6796 profilerStartTime = now$3();
6797
6798 if (fiber.actualStartTime < 0) {
6799 fiber.actualStartTime = now$3();
6800 }
6801}
6802
6803function stopProfilerTimerIfRunning(fiber) {
6804 if (!enableProfilerTimer) {
6805 return;
6806 }
6807 profilerStartTime = -1;
6808}
6809
6810function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
6811 if (!enableProfilerTimer) {
6812 return;
6813 }
6814
6815 if (profilerStartTime >= 0) {
6816 var elapsedTime = now$3() - profilerStartTime;
6817 fiber.actualDuration += elapsedTime;
6818 if (overrideBaseTime) {
6819 fiber.selfBaseDuration = elapsedTime;
6820 }
6821 profilerStartTime = -1;
6822 }
6823}
6824
6825// The deepest Fiber on the stack involved in a hydration context.
6826// This may have been an insertion or a hydration.
6827var hydrationParentFiber = null;
6828var nextHydratableInstance = null;
6829var isHydrating = false;
6830
6831function enterHydrationState(fiber) {
6832 if (!supportsHydration) {
6833 return false;
6834 }
6835
6836 var parentInstance = fiber.stateNode.containerInfo;
6837 nextHydratableInstance = getFirstHydratableChild(parentInstance);
6838 hydrationParentFiber = fiber;
6839 isHydrating = true;
6840 return true;
6841}
6842
6843function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
6844 if (!supportsHydration) {
6845 return false;
6846 }
6847
6848 var suspenseInstance = fiber.stateNode;
6849 nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
6850 popToNextHostParent(fiber);
6851 isHydrating = true;
6852 return true;
6853}
6854
6855function deleteHydratableInstance(returnFiber, instance) {
6856 {
6857 switch (returnFiber.tag) {
6858 case HostRoot:
6859 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
6860 break;
6861 case HostComponent:
6862 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
6863 break;
6864 }
6865 }
6866
6867 var childToDelete = createFiberFromHostInstanceForDeletion();
6868 childToDelete.stateNode = instance;
6869 childToDelete.return = returnFiber;
6870 childToDelete.effectTag = Deletion;
6871
6872 // This might seem like it belongs on progressedFirstDeletion. However,
6873 // these children are not part of the reconciliation list of children.
6874 // Even if we abort and rereconcile the children, that will try to hydrate
6875 // again and the nodes are still in the host tree so these will be
6876 // recreated.
6877 if (returnFiber.lastEffect !== null) {
6878 returnFiber.lastEffect.nextEffect = childToDelete;
6879 returnFiber.lastEffect = childToDelete;
6880 } else {
6881 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
6882 }
6883}
6884
6885function insertNonHydratedInstance(returnFiber, fiber) {
6886 fiber.effectTag |= Placement;
6887 {
6888 switch (returnFiber.tag) {
6889 case HostRoot:
6890 {
6891 var parentContainer = returnFiber.stateNode.containerInfo;
6892 switch (fiber.tag) {
6893 case HostComponent:
6894 var type = fiber.type;
6895 var props = fiber.pendingProps;
6896 didNotFindHydratableContainerInstance(parentContainer, type, props);
6897 break;
6898 case HostText:
6899 var text = fiber.pendingProps;
6900 didNotFindHydratableContainerTextInstance(parentContainer, text);
6901 break;
6902 case SuspenseComponent:
6903 didNotFindHydratableContainerSuspenseInstance(parentContainer);
6904 break;
6905 }
6906 break;
6907 }
6908 case HostComponent:
6909 {
6910 var parentType = returnFiber.type;
6911 var parentProps = returnFiber.memoizedProps;
6912 var parentInstance = returnFiber.stateNode;
6913 switch (fiber.tag) {
6914 case HostComponent:
6915 var _type = fiber.type;
6916 var _props = fiber.pendingProps;
6917 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
6918 break;
6919 case HostText:
6920 var _text = fiber.pendingProps;
6921 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
6922 break;
6923 case SuspenseComponent:
6924 didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
6925 break;
6926 }
6927 break;
6928 }
6929 default:
6930 return;
6931 }
6932 }
6933}
6934
6935function tryHydrate(fiber, nextInstance) {
6936 switch (fiber.tag) {
6937 case HostComponent:
6938 {
6939 var type = fiber.type;
6940 var props = fiber.pendingProps;
6941 var instance = canHydrateInstance(nextInstance, type, props);
6942 if (instance !== null) {
6943 fiber.stateNode = instance;
6944 return true;
6945 }
6946 return false;
6947 }
6948 case HostText:
6949 {
6950 var text = fiber.pendingProps;
6951 var textInstance = canHydrateTextInstance(nextInstance, text);
6952 if (textInstance !== null) {
6953 fiber.stateNode = textInstance;
6954 return true;
6955 }
6956 return false;
6957 }
6958 case SuspenseComponent:
6959 {
6960 if (enableSuspenseServerRenderer) {
6961 var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
6962 if (suspenseInstance !== null) {
6963 // Downgrade the tag to a dehydrated component until we've hydrated it.
6964 fiber.tag = DehydratedSuspenseComponent;
6965 fiber.stateNode = suspenseInstance;
6966 return true;
6967 }
6968 }
6969 return false;
6970 }
6971 default:
6972 return false;
6973 }
6974}
6975
6976function tryToClaimNextHydratableInstance(fiber) {
6977 if (!isHydrating) {
6978 return;
6979 }
6980 var nextInstance = nextHydratableInstance;
6981 if (!nextInstance) {
6982 // Nothing to hydrate. Make it an insertion.
6983 insertNonHydratedInstance(hydrationParentFiber, fiber);
6984 isHydrating = false;
6985 hydrationParentFiber = fiber;
6986 return;
6987 }
6988 var firstAttemptedInstance = nextInstance;
6989 if (!tryHydrate(fiber, nextInstance)) {
6990 // If we can't hydrate this instance let's try the next one.
6991 // We use this as a heuristic. It's based on intuition and not data so it
6992 // might be flawed or unnecessary.
6993 nextInstance = getNextHydratableSibling(firstAttemptedInstance);
6994 if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
6995 // Nothing to hydrate. Make it an insertion.
6996 insertNonHydratedInstance(hydrationParentFiber, fiber);
6997 isHydrating = false;
6998 hydrationParentFiber = fiber;
6999 return;
7000 }
7001 // We matched the next one, we'll now assume that the first one was
7002 // superfluous and we'll delete it. Since we can't eagerly delete it
7003 // we'll have to schedule a deletion. To do that, this node needs a dummy
7004 // fiber associated with it.
7005 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
7006 }
7007 hydrationParentFiber = fiber;
7008 nextHydratableInstance = getFirstHydratableChild(nextInstance);
7009}
7010
7011function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
7012 if (!supportsHydration) {
7013 (function () {
7014 {
7015 {
7016 throw ReactError('Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
7017 }
7018 }
7019 })();
7020 }
7021
7022 var instance = fiber.stateNode;
7023 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
7024 // TODO: Type this specific to this type of component.
7025 fiber.updateQueue = updatePayload;
7026 // If the update payload indicates that there is a change or if there
7027 // is a new ref we mark this as an update.
7028 if (updatePayload !== null) {
7029 return true;
7030 }
7031 return false;
7032}
7033
7034function prepareToHydrateHostTextInstance(fiber) {
7035 if (!supportsHydration) {
7036 (function () {
7037 {
7038 {
7039 throw ReactError('Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
7040 }
7041 }
7042 })();
7043 }
7044
7045 var textInstance = fiber.stateNode;
7046 var textContent = fiber.memoizedProps;
7047 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
7048 {
7049 if (shouldUpdate) {
7050 // We assume that prepareToHydrateHostTextInstance is called in a context where the
7051 // hydration parent is the parent host component of this host text.
7052 var returnFiber = hydrationParentFiber;
7053 if (returnFiber !== null) {
7054 switch (returnFiber.tag) {
7055 case HostRoot:
7056 {
7057 var parentContainer = returnFiber.stateNode.containerInfo;
7058 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
7059 break;
7060 }
7061 case HostComponent:
7062 {
7063 var parentType = returnFiber.type;
7064 var parentProps = returnFiber.memoizedProps;
7065 var parentInstance = returnFiber.stateNode;
7066 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
7067 break;
7068 }
7069 }
7070 }
7071 }
7072 }
7073 return shouldUpdate;
7074}
7075
7076function skipPastDehydratedSuspenseInstance(fiber) {
7077 if (!supportsHydration) {
7078 (function () {
7079 {
7080 {
7081 throw ReactError('Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
7082 }
7083 }
7084 })();
7085 }
7086 var suspenseInstance = fiber.stateNode;
7087 (function () {
7088 if (!suspenseInstance) {
7089 {
7090 throw ReactError('Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.');
7091 }
7092 }
7093 })();
7094 nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
7095}
7096
7097function popToNextHostParent(fiber) {
7098 var parent = fiber.return;
7099 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
7100 parent = parent.return;
7101 }
7102 hydrationParentFiber = parent;
7103}
7104
7105function popHydrationState(fiber) {
7106 if (!supportsHydration) {
7107 return false;
7108 }
7109 if (fiber !== hydrationParentFiber) {
7110 // We're deeper than the current hydration context, inside an inserted
7111 // tree.
7112 return false;
7113 }
7114 if (!isHydrating) {
7115 // If we're not currently hydrating but we're in a hydration context, then
7116 // we were an insertion and now need to pop up reenter hydration of our
7117 // siblings.
7118 popToNextHostParent(fiber);
7119 isHydrating = true;
7120 return false;
7121 }
7122
7123 var type = fiber.type;
7124
7125 // If we have any remaining hydratable nodes, we need to delete them now.
7126 // We only do this deeper than head and body since they tend to have random
7127 // other nodes in them. We also ignore components with pure text content in
7128 // side of them.
7129 // TODO: Better heuristic.
7130 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
7131 var nextInstance = nextHydratableInstance;
7132 while (nextInstance) {
7133 deleteHydratableInstance(fiber, nextInstance);
7134 nextInstance = getNextHydratableSibling(nextInstance);
7135 }
7136 }
7137
7138 popToNextHostParent(fiber);
7139 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
7140 return true;
7141}
7142
7143function resetHydrationState() {
7144 if (!supportsHydration) {
7145 return;
7146 }
7147
7148 hydrationParentFiber = null;
7149 nextHydratableInstance = null;
7150 isHydrating = false;
7151}
7152
7153var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
7154
7155var didReceiveUpdate = false;
7156
7157var didWarnAboutBadClass = void 0;
7158var didWarnAboutModulePatternComponent = void 0;
7159var didWarnAboutContextTypeOnFunctionComponent = void 0;
7160var didWarnAboutGetDerivedStateOnFunctionComponent = void 0;
7161var didWarnAboutFunctionRefs = void 0;
7162var didWarnAboutReassigningProps = void 0;
7163var didWarnAboutMaxDuration = void 0;
7164
7165{
7166 didWarnAboutBadClass = {};
7167 didWarnAboutModulePatternComponent = {};
7168 didWarnAboutContextTypeOnFunctionComponent = {};
7169 didWarnAboutGetDerivedStateOnFunctionComponent = {};
7170 didWarnAboutFunctionRefs = {};
7171 didWarnAboutReassigningProps = false;
7172 didWarnAboutMaxDuration = false;
7173}
7174
7175function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7176 if (current$$1 === null) {
7177 // If this is a fresh new component that hasn't been rendered yet, we
7178 // won't update its child set by applying minimal side-effects. Instead,
7179 // we will add them all to the child before it gets rendered. That means
7180 // we can optimize this reconciliation pass by not tracking side-effects.
7181 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7182 } else {
7183 // If the current child is the same as the work in progress, it means that
7184 // we haven't yet started any work on these children. Therefore, we use
7185 // the clone algorithm to create a copy of all the current children.
7186
7187 // If we had any progressed work already, that is invalid at this point so
7188 // let's throw it out.
7189 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
7190 }
7191}
7192
7193function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7194 // This function is fork of reconcileChildren. It's used in cases where we
7195 // want to reconcile without matching against the existing set. This has the
7196 // effect of all current children being unmounted; even if the type and key
7197 // are the same, the old child is unmounted and a new child is created.
7198 //
7199 // To do this, we're going to go through the reconcile algorithm twice. In
7200 // the first pass, we schedule a deletion for all the current children by
7201 // passing null.
7202 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
7203 // In the second pass, we mount the new children. The trick here is that we
7204 // pass null in place of where we usually pass the current child set. This has
7205 // the effect of remounting all children regardless of whether their their
7206 // identity matches.
7207 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7208}
7209
7210function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7211 // TODO: current can be non-null here even if the component
7212 // hasn't yet mounted. This happens after the first render suspends.
7213 // We'll need to figure out if this is fine or can cause issues.
7214
7215 {
7216 if (workInProgress.type !== workInProgress.elementType) {
7217 // Lazy component props can't be validated in createElement
7218 // because they're only guaranteed to be resolved here.
7219 var innerPropTypes = Component.propTypes;
7220 if (innerPropTypes) {
7221 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7222 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7223 }
7224 }
7225 }
7226
7227 var render = Component.render;
7228 var ref = workInProgress.ref;
7229
7230 // The rest is a fork of updateFunctionComponent
7231 var nextChildren = void 0;
7232 prepareToReadContext(workInProgress, renderExpirationTime);
7233 {
7234 ReactCurrentOwner$2.current = workInProgress;
7235 setCurrentPhase('render');
7236 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7237 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7238 // Only double-render components with Hooks
7239 if (workInProgress.memoizedState !== null) {
7240 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7241 }
7242 }
7243 setCurrentPhase(null);
7244 }
7245
7246 if (current$$1 !== null && !didReceiveUpdate) {
7247 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
7248 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7249 }
7250
7251 // React DevTools reads this flag.
7252 workInProgress.effectTag |= PerformedWork;
7253 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7254 return workInProgress.child;
7255}
7256
7257function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7258 if (current$$1 === null) {
7259 var type = Component.type;
7260 if (isSimpleFunctionComponent(type) && Component.compare === null &&
7261 // SimpleMemoComponent codepath doesn't resolve outer props either.
7262 Component.defaultProps === undefined) {
7263 // If this is a plain function component without default props,
7264 // and with only the default shallow comparison, we upgrade it
7265 // to a SimpleMemoComponent to allow fast path updates.
7266 workInProgress.tag = SimpleMemoComponent;
7267 workInProgress.type = type;
7268 {
7269 validateFunctionComponentInDev(workInProgress, type);
7270 }
7271 return updateSimpleMemoComponent(current$$1, workInProgress, type, nextProps, updateExpirationTime, renderExpirationTime);
7272 }
7273 {
7274 var innerPropTypes = type.propTypes;
7275 if (innerPropTypes) {
7276 // Inner memo component props aren't currently validated in createElement.
7277 // We could move it there, but we'd still need this for lazy code path.
7278 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7279 'prop', getComponentName(type), getCurrentFiberStackInDev);
7280 }
7281 }
7282 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
7283 child.ref = workInProgress.ref;
7284 child.return = workInProgress;
7285 workInProgress.child = child;
7286 return child;
7287 }
7288 {
7289 var _type = Component.type;
7290 var _innerPropTypes = _type.propTypes;
7291 if (_innerPropTypes) {
7292 // Inner memo component props aren't currently validated in createElement.
7293 // We could move it there, but we'd still need this for lazy code path.
7294 checkPropTypes(_innerPropTypes, nextProps, // Resolved props
7295 'prop', getComponentName(_type), getCurrentFiberStackInDev);
7296 }
7297 }
7298 var currentChild = current$$1.child; // This is always exactly one child
7299 if (updateExpirationTime < renderExpirationTime) {
7300 // This will be the props with resolved defaultProps,
7301 // unlike current.memoizedProps which will be the unresolved ones.
7302 var prevProps = currentChild.memoizedProps;
7303 // Default to shallow comparison
7304 var compare = Component.compare;
7305 compare = compare !== null ? compare : shallowEqual;
7306 if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
7307 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7308 }
7309 }
7310 // React DevTools reads this flag.
7311 workInProgress.effectTag |= PerformedWork;
7312 var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
7313 newChild.ref = workInProgress.ref;
7314 newChild.return = workInProgress;
7315 workInProgress.child = newChild;
7316 return newChild;
7317}
7318
7319function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7320 // TODO: current can be non-null here even if the component
7321 // hasn't yet mounted. This happens when the inner render suspends.
7322 // We'll need to figure out if this is fine or can cause issues.
7323
7324 {
7325 if (workInProgress.type !== workInProgress.elementType) {
7326 // Lazy component props can't be validated in createElement
7327 // because they're only guaranteed to be resolved here.
7328 var outerMemoType = workInProgress.elementType;
7329 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
7330 // We warn when you define propTypes on lazy()
7331 // so let's just skip over it to find memo() outer wrapper.
7332 // Inner props for memo are validated later.
7333 outerMemoType = refineResolvedLazyComponent(outerMemoType);
7334 }
7335 var outerPropTypes = outerMemoType && outerMemoType.propTypes;
7336 if (outerPropTypes) {
7337 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
7338 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
7339 }
7340 // Inner propTypes will be validated in the function component path.
7341 }
7342 }
7343 if (current$$1 !== null) {
7344 var prevProps = current$$1.memoizedProps;
7345 if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
7346 didReceiveUpdate = false;
7347 if (updateExpirationTime < renderExpirationTime) {
7348 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7349 }
7350 }
7351 }
7352 return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
7353}
7354
7355function updateFragment(current$$1, workInProgress, renderExpirationTime) {
7356 var nextChildren = workInProgress.pendingProps;
7357 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7358 return workInProgress.child;
7359}
7360
7361function updateMode(current$$1, workInProgress, renderExpirationTime) {
7362 var nextChildren = workInProgress.pendingProps.children;
7363 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7364 return workInProgress.child;
7365}
7366
7367function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
7368 if (enableProfilerTimer) {
7369 workInProgress.effectTag |= Update;
7370 }
7371 var nextProps = workInProgress.pendingProps;
7372 var nextChildren = nextProps.children;
7373 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7374 return workInProgress.child;
7375}
7376
7377function markRef(current$$1, workInProgress) {
7378 var ref = workInProgress.ref;
7379 if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
7380 // Schedule a Ref effect
7381 workInProgress.effectTag |= Ref;
7382 }
7383}
7384
7385function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7386 {
7387 if (workInProgress.type !== workInProgress.elementType) {
7388 // Lazy component props can't be validated in createElement
7389 // because they're only guaranteed to be resolved here.
7390 var innerPropTypes = Component.propTypes;
7391 if (innerPropTypes) {
7392 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7393 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7394 }
7395 }
7396 }
7397
7398 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
7399 var context = getMaskedContext(workInProgress, unmaskedContext);
7400
7401 var nextChildren = void 0;
7402 prepareToReadContext(workInProgress, renderExpirationTime);
7403 {
7404 ReactCurrentOwner$2.current = workInProgress;
7405 setCurrentPhase('render');
7406 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
7407 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7408 // Only double-render components with Hooks
7409 if (workInProgress.memoizedState !== null) {
7410 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
7411 }
7412 }
7413 setCurrentPhase(null);
7414 }
7415
7416 if (current$$1 !== null && !didReceiveUpdate) {
7417 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
7418 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7419 }
7420
7421 // React DevTools reads this flag.
7422 workInProgress.effectTag |= PerformedWork;
7423 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7424 return workInProgress.child;
7425}
7426
7427function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7428 {
7429 if (workInProgress.type !== workInProgress.elementType) {
7430 // Lazy component props can't be validated in createElement
7431 // because they're only guaranteed to be resolved here.
7432 var innerPropTypes = Component.propTypes;
7433 if (innerPropTypes) {
7434 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7435 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7436 }
7437 }
7438 }
7439
7440 // Push context providers early to prevent context stack mismatches.
7441 // During mounting we don't know the child context yet as the instance doesn't exist.
7442 // We will invalidate the child context in finishClassComponent() right after rendering.
7443 var hasContext = void 0;
7444 if (isContextProvider(Component)) {
7445 hasContext = true;
7446 pushContextProvider(workInProgress);
7447 } else {
7448 hasContext = false;
7449 }
7450 prepareToReadContext(workInProgress, renderExpirationTime);
7451
7452 var instance = workInProgress.stateNode;
7453 var shouldUpdate = void 0;
7454 if (instance === null) {
7455 if (current$$1 !== null) {
7456 // An class component without an instance only mounts if it suspended
7457 // inside a non- concurrent tree, in an inconsistent state. We want to
7458 // tree it like a new mount, even though an empty version of it already
7459 // committed. Disconnect the alternate pointers.
7460 current$$1.alternate = null;
7461 workInProgress.alternate = null;
7462 // Since this is conceptually a new fiber, schedule a Placement effect
7463 workInProgress.effectTag |= Placement;
7464 }
7465 // In the initial pass we might need to construct the instance.
7466 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7467 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7468 shouldUpdate = true;
7469 } else if (current$$1 === null) {
7470 // In a resume, we'll already have an instance we can reuse.
7471 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7472 } else {
7473 shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
7474 }
7475 var nextUnitOfWork = finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
7476 {
7477 var inst = workInProgress.stateNode;
7478 if (inst.props !== nextProps) {
7479 !didWarnAboutReassigningProps ? warning$1(false, 'It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component') : void 0;
7480 didWarnAboutReassigningProps = true;
7481 }
7482 }
7483 return nextUnitOfWork;
7484}
7485
7486function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
7487 // Refs should update even if shouldComponentUpdate returns false
7488 markRef(current$$1, workInProgress);
7489
7490 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
7491
7492 if (!shouldUpdate && !didCaptureError) {
7493 // Context providers should defer to sCU for rendering
7494 if (hasContext) {
7495 invalidateContextProvider(workInProgress, Component, false);
7496 }
7497
7498 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7499 }
7500
7501 var instance = workInProgress.stateNode;
7502
7503 // Rerender
7504 ReactCurrentOwner$2.current = workInProgress;
7505 var nextChildren = void 0;
7506 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
7507 // If we captured an error, but getDerivedStateFrom catch is not defined,
7508 // unmount all the children. componentDidCatch will schedule an update to
7509 // re-render a fallback. This is temporary until we migrate everyone to
7510 // the new API.
7511 // TODO: Warn in a future release.
7512 nextChildren = null;
7513
7514 if (enableProfilerTimer) {
7515 stopProfilerTimerIfRunning(workInProgress);
7516 }
7517 } else {
7518 {
7519 setCurrentPhase('render');
7520 nextChildren = instance.render();
7521 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7522 instance.render();
7523 }
7524 setCurrentPhase(null);
7525 }
7526 }
7527
7528 // React DevTools reads this flag.
7529 workInProgress.effectTag |= PerformedWork;
7530 if (current$$1 !== null && didCaptureError) {
7531 // If we're recovering from an error, reconcile without reusing any of
7532 // the existing children. Conceptually, the normal children and the children
7533 // that are shown on error are two different sets, so we shouldn't reuse
7534 // normal children even if their identities match.
7535 forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
7536 } else {
7537 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7538 }
7539
7540 // Memoize state using the values we just used to render.
7541 // TODO: Restructure so we never read values from the instance.
7542 workInProgress.memoizedState = instance.state;
7543
7544 // The context might have changed so we need to recalculate it.
7545 if (hasContext) {
7546 invalidateContextProvider(workInProgress, Component, true);
7547 }
7548
7549 return workInProgress.child;
7550}
7551
7552function pushHostRootContext(workInProgress) {
7553 var root = workInProgress.stateNode;
7554 if (root.pendingContext) {
7555 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
7556 } else if (root.context) {
7557 // Should always be set
7558 pushTopLevelContextObject(workInProgress, root.context, false);
7559 }
7560 pushHostContainer(workInProgress, root.containerInfo);
7561}
7562
7563function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
7564 pushHostRootContext(workInProgress);
7565 var updateQueue = workInProgress.updateQueue;
7566 (function () {
7567 if (!(updateQueue !== null)) {
7568 {
7569 throw ReactError('If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.');
7570 }
7571 }
7572 })();
7573 var nextProps = workInProgress.pendingProps;
7574 var prevState = workInProgress.memoizedState;
7575 var prevChildren = prevState !== null ? prevState.element : null;
7576 processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
7577 var nextState = workInProgress.memoizedState;
7578 // Caution: React DevTools currently depends on this property
7579 // being called "element".
7580 var nextChildren = nextState.element;
7581 if (nextChildren === prevChildren) {
7582 // If the state is the same as before, that's a bailout because we had
7583 // no work that expires at this time.
7584 resetHydrationState();
7585 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7586 }
7587 var root = workInProgress.stateNode;
7588 if ((current$$1 === null || current$$1.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
7589 // If we don't have any current children this might be the first pass.
7590 // We always try to hydrate. If this isn't a hydration pass there won't
7591 // be any children to hydrate which is effectively the same thing as
7592 // not hydrating.
7593
7594 // This is a bit of a hack. We track the host root as a placement to
7595 // know that we're currently in a mounting state. That way isMounted
7596 // works as expected. We must reset this before committing.
7597 // TODO: Delete this when we delete isMounted and findDOMNode.
7598 workInProgress.effectTag |= Placement;
7599
7600 // Ensure that children mount into this root without tracking
7601 // side-effects. This ensures that we don't store Placement effects on
7602 // nodes that will be hydrated.
7603 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7604 } else {
7605 // Otherwise reset hydration state in case we aborted and resumed another
7606 // root.
7607 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7608 resetHydrationState();
7609 }
7610 return workInProgress.child;
7611}
7612
7613function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
7614 pushHostContext(workInProgress);
7615
7616 if (current$$1 === null) {
7617 tryToClaimNextHydratableInstance(workInProgress);
7618 }
7619
7620 var type = workInProgress.type;
7621 var nextProps = workInProgress.pendingProps;
7622 var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
7623
7624 var nextChildren = nextProps.children;
7625 var isDirectTextChild = shouldSetTextContent(type, nextProps);
7626
7627 if (isDirectTextChild) {
7628 // We special case a direct text child of a host node. This is a common
7629 // case. We won't handle it as a reified child. We will instead handle
7630 // this in the host environment that also have access to this prop. That
7631 // avoids allocating another HostText fiber and traversing it.
7632 nextChildren = null;
7633 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
7634 // If we're switching from a direct text child to a normal child, or to
7635 // empty, we need to schedule the text content to be reset.
7636 workInProgress.effectTag |= ContentReset;
7637 }
7638
7639 markRef(current$$1, workInProgress);
7640
7641 // Check the host config to see if the children are offscreen/hidden.
7642 if (renderExpirationTime !== Never && workInProgress.mode & ConcurrentMode && shouldDeprioritizeSubtree(type, nextProps)) {
7643 // Schedule this fiber to re-render at offscreen priority. Then bailout.
7644 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
7645 return null;
7646 }
7647
7648 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7649 return workInProgress.child;
7650}
7651
7652function updateHostText(current$$1, workInProgress) {
7653 if (current$$1 === null) {
7654 tryToClaimNextHydratableInstance(workInProgress);
7655 }
7656 // Nothing to do here. This is terminal. We'll do the completion step
7657 // immediately after.
7658 return null;
7659}
7660
7661function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
7662 if (_current !== null) {
7663 // An lazy component only mounts if it suspended inside a non-
7664 // concurrent tree, in an inconsistent state. We want to treat it like
7665 // a new mount, even though an empty version of it already committed.
7666 // Disconnect the alternate pointers.
7667 _current.alternate = null;
7668 workInProgress.alternate = null;
7669 // Since this is conceptually a new fiber, schedule a Placement effect
7670 workInProgress.effectTag |= Placement;
7671 }
7672
7673 var props = workInProgress.pendingProps;
7674 // We can't start a User Timing measurement with correct label yet.
7675 // Cancel and resume right after we know the tag.
7676 cancelWorkTimer(workInProgress);
7677 var Component = readLazyComponentType(elementType);
7678 // Store the unwrapped component in the type.
7679 workInProgress.type = Component;
7680 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
7681 startWorkTimer(workInProgress);
7682 var resolvedProps = resolveDefaultProps(Component, props);
7683 var child = void 0;
7684 switch (resolvedTag) {
7685 case FunctionComponent:
7686 {
7687 {
7688 validateFunctionComponentInDev(workInProgress, Component);
7689 }
7690 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
7691 break;
7692 }
7693 case ClassComponent:
7694 {
7695 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
7696 break;
7697 }
7698 case ForwardRef:
7699 {
7700 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
7701 break;
7702 }
7703 case MemoComponent:
7704 {
7705 {
7706 if (workInProgress.type !== workInProgress.elementType) {
7707 var outerPropTypes = Component.propTypes;
7708 if (outerPropTypes) {
7709 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
7710 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7711 }
7712 }
7713 }
7714 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
7715 updateExpirationTime, renderExpirationTime);
7716 break;
7717 }
7718 default:
7719 {
7720 var hint = '';
7721 {
7722 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
7723 hint = ' Did you wrap a component in React.lazy() more than once?';
7724 }
7725 }
7726 // This message intentionally doesn't mention ForwardRef or MemoComponent
7727 // because the fact that it's a separate type of work is an
7728 // implementation detail.
7729 (function () {
7730 {
7731 {
7732 throw ReactError('Element type is invalid. Received a promise that resolves to: ' + Component + '. Lazy element type must resolve to a class or function.' + hint);
7733 }
7734 }
7735 })();
7736 }
7737 }
7738 return child;
7739}
7740
7741function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
7742 if (_current !== null) {
7743 // An incomplete component only mounts if it suspended inside a non-
7744 // concurrent tree, in an inconsistent state. We want to treat it like
7745 // a new mount, even though an empty version of it already committed.
7746 // Disconnect the alternate pointers.
7747 _current.alternate = null;
7748 workInProgress.alternate = null;
7749 // Since this is conceptually a new fiber, schedule a Placement effect
7750 workInProgress.effectTag |= Placement;
7751 }
7752
7753 // Promote the fiber to a class and try rendering again.
7754 workInProgress.tag = ClassComponent;
7755
7756 // The rest of this function is a fork of `updateClassComponent`
7757
7758 // Push context providers early to prevent context stack mismatches.
7759 // During mounting we don't know the child context yet as the instance doesn't exist.
7760 // We will invalidate the child context in finishClassComponent() right after rendering.
7761 var hasContext = void 0;
7762 if (isContextProvider(Component)) {
7763 hasContext = true;
7764 pushContextProvider(workInProgress);
7765 } else {
7766 hasContext = false;
7767 }
7768 prepareToReadContext(workInProgress, renderExpirationTime);
7769
7770 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7771 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7772
7773 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
7774}
7775
7776function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
7777 if (_current !== null) {
7778 // An indeterminate component only mounts if it suspended inside a non-
7779 // concurrent tree, in an inconsistent state. We want to treat it like
7780 // a new mount, even though an empty version of it already committed.
7781 // Disconnect the alternate pointers.
7782 _current.alternate = null;
7783 workInProgress.alternate = null;
7784 // Since this is conceptually a new fiber, schedule a Placement effect
7785 workInProgress.effectTag |= Placement;
7786 }
7787
7788 var props = workInProgress.pendingProps;
7789 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
7790 var context = getMaskedContext(workInProgress, unmaskedContext);
7791
7792 prepareToReadContext(workInProgress, renderExpirationTime);
7793
7794 var value = void 0;
7795
7796 {
7797 if (Component.prototype && typeof Component.prototype.render === 'function') {
7798 var componentName = getComponentName(Component) || 'Unknown';
7799
7800 if (!didWarnAboutBadClass[componentName]) {
7801 warningWithoutStack$1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
7802 didWarnAboutBadClass[componentName] = true;
7803 }
7804 }
7805
7806 if (workInProgress.mode & StrictMode) {
7807 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
7808 }
7809
7810 ReactCurrentOwner$2.current = workInProgress;
7811 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
7812 }
7813 // React DevTools reads this flag.
7814 workInProgress.effectTag |= PerformedWork;
7815
7816 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
7817 {
7818 var _componentName = getComponentName(Component) || 'Unknown';
7819 if (!didWarnAboutModulePatternComponent[_componentName]) {
7820 warningWithoutStack$1(false, 'The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
7821 didWarnAboutModulePatternComponent[_componentName] = true;
7822 }
7823 }
7824
7825 // Proceed under the assumption that this is a class instance
7826 workInProgress.tag = ClassComponent;
7827
7828 // Throw out any hooks that were used.
7829 resetHooks();
7830
7831 // Push context providers early to prevent context stack mismatches.
7832 // During mounting we don't know the child context yet as the instance doesn't exist.
7833 // We will invalidate the child context in finishClassComponent() right after rendering.
7834 var hasContext = false;
7835 if (isContextProvider(Component)) {
7836 hasContext = true;
7837 pushContextProvider(workInProgress);
7838 } else {
7839 hasContext = false;
7840 }
7841
7842 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
7843
7844 var getDerivedStateFromProps = Component.getDerivedStateFromProps;
7845 if (typeof getDerivedStateFromProps === 'function') {
7846 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
7847 }
7848
7849 adoptClassInstance(workInProgress, value);
7850 mountClassInstance(workInProgress, Component, props, renderExpirationTime);
7851 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
7852 } else {
7853 // Proceed under the assumption that this is a function component
7854 workInProgress.tag = FunctionComponent;
7855 {
7856 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7857 // Only double-render components with Hooks
7858 if (workInProgress.memoizedState !== null) {
7859 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
7860 }
7861 }
7862 }
7863 reconcileChildren(null, workInProgress, value, renderExpirationTime);
7864 {
7865 validateFunctionComponentInDev(workInProgress, Component);
7866 }
7867 return workInProgress.child;
7868 }
7869}
7870
7871function validateFunctionComponentInDev(workInProgress, Component) {
7872 if (Component) {
7873 !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
7874 }
7875 if (workInProgress.ref !== null) {
7876 var info = '';
7877 var ownerName = getCurrentFiberOwnerNameInDevOrNull();
7878 if (ownerName) {
7879 info += '\n\nCheck the render method of `' + ownerName + '`.';
7880 }
7881
7882 var warningKey = ownerName || workInProgress._debugID || '';
7883 var debugSource = workInProgress._debugSource;
7884 if (debugSource) {
7885 warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
7886 }
7887 if (!didWarnAboutFunctionRefs[warningKey]) {
7888 didWarnAboutFunctionRefs[warningKey] = true;
7889 warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
7890 }
7891 }
7892
7893 if (typeof Component.getDerivedStateFromProps === 'function') {
7894 var componentName = getComponentName(Component) || 'Unknown';
7895
7896 if (!didWarnAboutGetDerivedStateOnFunctionComponent[componentName]) {
7897 warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', componentName);
7898 didWarnAboutGetDerivedStateOnFunctionComponent[componentName] = true;
7899 }
7900 }
7901
7902 if (typeof Component.contextType === 'object' && Component.contextType !== null) {
7903 var _componentName2 = getComponentName(Component) || 'Unknown';
7904
7905 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) {
7906 warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName2);
7907 didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true;
7908 }
7909 }
7910}
7911
7912function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
7913 var mode = workInProgress.mode;
7914 var nextProps = workInProgress.pendingProps;
7915
7916 // We should attempt to render the primary children unless this boundary
7917 // already suspended during this render (`alreadyCaptured` is true).
7918 var nextState = workInProgress.memoizedState;
7919
7920 var nextDidTimeout = void 0;
7921 if ((workInProgress.effectTag & DidCapture) === NoEffect) {
7922 // This is the first attempt.
7923 nextState = null;
7924 nextDidTimeout = false;
7925 } else {
7926 // Something in this boundary's subtree already suspended. Switch to
7927 // rendering the fallback children.
7928 nextState = {
7929 timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork
7930 };
7931 nextDidTimeout = true;
7932 workInProgress.effectTag &= ~DidCapture;
7933 }
7934
7935 {
7936 if ('maxDuration' in nextProps) {
7937 if (!didWarnAboutMaxDuration) {
7938 didWarnAboutMaxDuration = true;
7939 warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
7940 }
7941 }
7942 }
7943
7944 // This next part is a bit confusing. If the children timeout, we switch to
7945 // showing the fallback children in place of the "primary" children.
7946 // However, we don't want to delete the primary children because then their
7947 // state will be lost (both the React state and the host state, e.g.
7948 // uncontrolled form inputs). Instead we keep them mounted and hide them.
7949 // Both the fallback children AND the primary children are rendered at the
7950 // same time. Once the primary children are un-suspended, we can delete
7951 // the fallback children — don't need to preserve their state.
7952 //
7953 // The two sets of children are siblings in the host environment, but
7954 // semantically, for purposes of reconciliation, they are two separate sets.
7955 // So we store them using two fragment fibers.
7956 //
7957 // However, we want to avoid allocating extra fibers for every placeholder.
7958 // They're only necessary when the children time out, because that's the
7959 // only time when both sets are mounted.
7960 //
7961 // So, the extra fragment fibers are only used if the children time out.
7962 // Otherwise, we render the primary children directly. This requires some
7963 // custom reconciliation logic to preserve the state of the primary
7964 // children. It's essentially a very basic form of re-parenting.
7965
7966 // `child` points to the child fiber. In the normal case, this is the first
7967 // fiber of the primary children set. In the timed-out case, it's a
7968 // a fragment fiber containing the primary children.
7969 var child = void 0;
7970 // `next` points to the next fiber React should render. In the normal case,
7971 // it's the same as `child`: the first fiber of the primary children set.
7972 // In the timed-out case, it's a fragment fiber containing the *fallback*
7973 // children -- we skip over the primary children entirely.
7974 var next = void 0;
7975 if (current$$1 === null) {
7976 if (enableSuspenseServerRenderer) {
7977 // If we're currently hydrating, try to hydrate this boundary.
7978 // But only if this has a fallback.
7979 if (nextProps.fallback !== undefined) {
7980 tryToClaimNextHydratableInstance(workInProgress);
7981 // This could've changed the tag if this was a dehydrated suspense component.
7982 if (workInProgress.tag === DehydratedSuspenseComponent) {
7983 return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
7984 }
7985 }
7986 }
7987
7988 // This is the initial mount. This branch is pretty simple because there's
7989 // no previous state that needs to be preserved.
7990 if (nextDidTimeout) {
7991 // Mount separate fragments for primary and fallback children.
7992 var nextFallbackChildren = nextProps.fallback;
7993 var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
7994
7995 if ((workInProgress.mode & ConcurrentMode) === NoContext) {
7996 // Outside of concurrent mode, we commit the effects from the
7997 var progressedState = workInProgress.memoizedState;
7998 var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
7999 primaryChildFragment.child = progressedPrimaryChild;
8000 }
8001
8002 var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
8003 primaryChildFragment.sibling = fallbackChildFragment;
8004 child = primaryChildFragment;
8005 // Skip the primary children, and continue working on the
8006 // fallback children.
8007 next = fallbackChildFragment;
8008 child.return = next.return = workInProgress;
8009 } else {
8010 // Mount the primary children without an intermediate fragment fiber.
8011 var nextPrimaryChildren = nextProps.children;
8012 child = next = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
8013 }
8014 } else {
8015 // This is an update. This branch is more complicated because we need to
8016 // ensure the state of the primary children is preserved.
8017 var prevState = current$$1.memoizedState;
8018 var prevDidTimeout = prevState !== null;
8019 if (prevDidTimeout) {
8020 // The current tree already timed out. That means each child set is
8021 var currentPrimaryChildFragment = current$$1.child;
8022 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
8023 if (nextDidTimeout) {
8024 // Still timed out. Reuse the current primary children by cloning
8025 // its fragment. We're going to skip over these entirely.
8026 var _nextFallbackChildren = nextProps.fallback;
8027 var _primaryChildFragment = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
8028
8029 if ((workInProgress.mode & ConcurrentMode) === NoContext) {
8030 // Outside of concurrent mode, we commit the effects from the
8031 var _progressedState = workInProgress.memoizedState;
8032 var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
8033 if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
8034 _primaryChildFragment.child = _progressedPrimaryChild;
8035 }
8036 }
8037
8038 // Because primaryChildFragment is a new fiber that we're inserting as the
8039 // parent of a new tree, we need to set its treeBaseDuration.
8040 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8041 // treeBaseDuration is the sum of all the child tree base durations.
8042 var treeBaseDuration = 0;
8043 var hiddenChild = _primaryChildFragment.child;
8044 while (hiddenChild !== null) {
8045 treeBaseDuration += hiddenChild.treeBaseDuration;
8046 hiddenChild = hiddenChild.sibling;
8047 }
8048 _primaryChildFragment.treeBaseDuration = treeBaseDuration;
8049 }
8050
8051 // Clone the fallback child fragment, too. These we'll continue
8052 // working on.
8053 var _fallbackChildFragment = _primaryChildFragment.sibling = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren, currentFallbackChildFragment.expirationTime);
8054 child = _primaryChildFragment;
8055 _primaryChildFragment.childExpirationTime = NoWork;
8056 // Skip the primary children, and continue working on the
8057 // fallback children.
8058 next = _fallbackChildFragment;
8059 child.return = next.return = workInProgress;
8060 } else {
8061 // No longer suspended. Switch back to showing the primary children,
8062 // and remove the intermediate fragment fiber.
8063 var _nextPrimaryChildren = nextProps.children;
8064 var currentPrimaryChild = currentPrimaryChildFragment.child;
8065 var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
8066
8067 // If this render doesn't suspend, we need to delete the fallback
8068 // children. Wait until the complete phase, after we've confirmed the
8069 // fallback is no longer needed.
8070 // TODO: Would it be better to store the fallback fragment on
8071 // the stateNode?
8072
8073 // Continue rendering the children, like we normally do.
8074 child = next = primaryChild;
8075 }
8076 } else {
8077 // The current tree has not already timed out. That means the primary
8078 // children are not wrapped in a fragment fiber.
8079 var _currentPrimaryChild = current$$1.child;
8080 if (nextDidTimeout) {
8081 // Timed out. Wrap the children in a fragment fiber to keep them
8082 // separate from the fallback children.
8083 var _nextFallbackChildren2 = nextProps.fallback;
8084 var _primaryChildFragment2 = createFiberFromFragment(
8085 // It shouldn't matter what the pending props are because we aren't
8086 // going to render this fragment.
8087 null, mode, NoWork, null);
8088 _primaryChildFragment2.child = _currentPrimaryChild;
8089
8090 // Even though we're creating a new fiber, there are no new children,
8091 // because we're reusing an already mounted tree. So we don't need to
8092 // schedule a placement.
8093 // primaryChildFragment.effectTag |= Placement;
8094
8095 if ((workInProgress.mode & ConcurrentMode) === NoContext) {
8096 // Outside of concurrent mode, we commit the effects from the
8097 var _progressedState2 = workInProgress.memoizedState;
8098 var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
8099 _primaryChildFragment2.child = _progressedPrimaryChild2;
8100 }
8101
8102 // Because primaryChildFragment is a new fiber that we're inserting as the
8103 // parent of a new tree, we need to set its treeBaseDuration.
8104 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8105 // treeBaseDuration is the sum of all the child tree base durations.
8106 var _treeBaseDuration = 0;
8107 var _hiddenChild = _primaryChildFragment2.child;
8108 while (_hiddenChild !== null) {
8109 _treeBaseDuration += _hiddenChild.treeBaseDuration;
8110 _hiddenChild = _hiddenChild.sibling;
8111 }
8112 _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
8113 }
8114
8115 // Create a fragment from the fallback children, too.
8116 var _fallbackChildFragment2 = _primaryChildFragment2.sibling = createFiberFromFragment(_nextFallbackChildren2, mode, renderExpirationTime, null);
8117 _fallbackChildFragment2.effectTag |= Placement;
8118 child = _primaryChildFragment2;
8119 _primaryChildFragment2.childExpirationTime = NoWork;
8120 // Skip the primary children, and continue working on the
8121 // fallback children.
8122 next = _fallbackChildFragment2;
8123 child.return = next.return = workInProgress;
8124 } else {
8125 // Still haven't timed out. Continue rendering the children, like we
8126 // normally do.
8127 var _nextPrimaryChildren2 = nextProps.children;
8128 next = child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
8129 }
8130 }
8131 workInProgress.stateNode = current$$1.stateNode;
8132 }
8133
8134 workInProgress.memoizedState = nextState;
8135 workInProgress.child = child;
8136 return next;
8137}
8138
8139function retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime) {
8140 // Detach from the current dehydrated boundary.
8141 current$$1.alternate = null;
8142 workInProgress.alternate = null;
8143
8144 // Insert a deletion in the effect list.
8145 var returnFiber = workInProgress.return;
8146 (function () {
8147 if (!(returnFiber !== null)) {
8148 {
8149 throw ReactError('Suspense boundaries are never on the root. This is probably a bug in React.');
8150 }
8151 }
8152 })();
8153 var last = returnFiber.lastEffect;
8154 if (last !== null) {
8155 last.nextEffect = current$$1;
8156 returnFiber.lastEffect = current$$1;
8157 } else {
8158 returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
8159 }
8160 current$$1.nextEffect = null;
8161 current$$1.effectTag = Deletion;
8162
8163 // Upgrade this work in progress to a real Suspense component.
8164 workInProgress.tag = SuspenseComponent;
8165 workInProgress.stateNode = null;
8166 workInProgress.memoizedState = null;
8167 // This is now an insertion.
8168 workInProgress.effectTag |= Placement;
8169 // Retry as a real Suspense component.
8170 return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
8171}
8172
8173function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
8174 var suspenseInstance = workInProgress.stateNode;
8175 if (current$$1 === null) {
8176 // During the first pass, we'll bail out and not drill into the children.
8177 // Instead, we'll leave the content in place and try to hydrate it later.
8178 if (isSuspenseInstanceFallback(suspenseInstance)) {
8179 // This is a client-only boundary. Since we won't get any content from the server
8180 // for this, we need to schedule that at a higher priority based on when it would
8181 // have timed out. In theory we could render it in this pass but it would have the
8182 // wrong priority associated with it and will prevent hydration of parent path.
8183 // Instead, we'll leave work left on it to render it in a separate commit.
8184
8185 // TODO This time should be the time at which the server rendered response that is
8186 // a parent to this boundary was displayed. However, since we currently don't have
8187 // a protocol to transfer that time, we'll just estimate it by using the current
8188 // time. This will mean that Suspense timeouts are slightly shifted to later than
8189 // they should be.
8190 var serverDisplayTime = requestCurrentTime$$1();
8191 // Schedule a normal pri update to render this content.
8192 workInProgress.expirationTime = computeAsyncExpiration(serverDisplayTime);
8193 } else {
8194 // We'll continue hydrating the rest at offscreen priority since we'll already
8195 // be showing the right content coming from the server, it is no rush.
8196 workInProgress.expirationTime = Never;
8197 }
8198 return null;
8199 }
8200 if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
8201 // Something suspended. Leave the existing children in place.
8202 // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
8203 workInProgress.child = null;
8204 return null;
8205 }
8206 if (isSuspenseInstanceFallback(suspenseInstance)) {
8207 // This boundary is in a permanent fallback state. In this case, we'll never
8208 // get an update and we'll never be able to hydrate the final content. Let's just try the
8209 // client side render instead.
8210 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
8211 }
8212 // We use childExpirationTime to indicate that a child might depend on context, so if
8213 // any context has changed, we need to treat is as if the input might have changed.
8214 var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
8215 if (didReceiveUpdate || hasContextChanged$$1) {
8216 // This boundary has changed since the first render. This means that we are now unable to
8217 // hydrate it. We might still be able to hydrate it using an earlier expiration time but
8218 // during this render we can't. Instead, we're going to delete the whole subtree and
8219 // instead inject a new real Suspense boundary to take its place, which may render content
8220 // or fallback. The real Suspense boundary will suspend for a while so we have some time
8221 // to ensure it can produce real content, but all state and pending events will be lost.
8222 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
8223 } else if (isSuspenseInstancePending(suspenseInstance)) {
8224 // This component is still pending more data from the server, so we can't hydrate its
8225 // content. We treat it as if this component suspended itself. It might seem as if
8226 // we could just try to render it client-side instead. However, this will perform a
8227 // lot of unnecessary work and is unlikely to complete since it often will suspend
8228 // on missing data anyway. Additionally, the server might be able to render more
8229 // than we can on the client yet. In that case we'd end up with more fallback states
8230 // on the client than if we just leave it alone. If the server times out or errors
8231 // these should update this boundary to the permanent Fallback state instead.
8232 // Mark it as having captured (i.e. suspended).
8233 workInProgress.effectTag |= DidCapture;
8234 // Leave the children in place. I.e. empty.
8235 workInProgress.child = null;
8236 // Register a callback to retry this boundary once the server has sent the result.
8237 registerSuspenseInstanceRetry(suspenseInstance, retryTimedOutBoundary$$1.bind(null, current$$1));
8238 return null;
8239 } else {
8240 // This is the first attempt.
8241 reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
8242 var nextProps = workInProgress.pendingProps;
8243 var nextChildren = nextProps.children;
8244 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
8245 return workInProgress.child;
8246 }
8247}
8248
8249function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
8250 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
8251 var nextChildren = workInProgress.pendingProps;
8252 if (current$$1 === null) {
8253 // Portals are special because we don't append the children during mount
8254 // but at commit. Therefore we need to track insertions which the normal
8255 // flow doesn't do during mount. This doesn't happen at the root because
8256 // the root always starts with a "current" with a null child.
8257 // TODO: Consider unifying this with how the root works.
8258 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
8259 } else {
8260 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8261 }
8262 return workInProgress.child;
8263}
8264
8265function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
8266 var providerType = workInProgress.type;
8267 var context = providerType._context;
8268
8269 var newProps = workInProgress.pendingProps;
8270 var oldProps = workInProgress.memoizedProps;
8271
8272 var newValue = newProps.value;
8273
8274 {
8275 var providerPropTypes = workInProgress.type.propTypes;
8276
8277 if (providerPropTypes) {
8278 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
8279 }
8280 }
8281
8282 pushProvider(workInProgress, newValue);
8283
8284 if (oldProps !== null) {
8285 var oldValue = oldProps.value;
8286 var changedBits = calculateChangedBits(context, newValue, oldValue);
8287 if (changedBits === 0) {
8288 // No change. Bailout early if children are the same.
8289 if (oldProps.children === newProps.children && !hasContextChanged()) {
8290 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8291 }
8292 } else {
8293 // The context value changed. Search for matching consumers and schedule
8294 // them to update.
8295 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
8296 }
8297 }
8298
8299 var newChildren = newProps.children;
8300 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
8301 return workInProgress.child;
8302}
8303
8304var hasWarnedAboutUsingContextAsConsumer = false;
8305
8306function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
8307 var context = workInProgress.type;
8308 // The logic below for Context differs depending on PROD or DEV mode. In
8309 // DEV mode, we create a separate object for Context.Consumer that acts
8310 // like a proxy to Context. This proxy object adds unnecessary code in PROD
8311 // so we use the old behaviour (Context.Consumer references Context) to
8312 // reduce size and overhead. The separate object references context via
8313 // a property called "_context", which also gives us the ability to check
8314 // in DEV mode if this property exists or not and warn if it does not.
8315 {
8316 if (context._context === undefined) {
8317 // This may be because it's a Context (rather than a Consumer).
8318 // Or it may be because it's older React where they're the same thing.
8319 // We only want to warn if we're sure it's a new React.
8320 if (context !== context.Consumer) {
8321 if (!hasWarnedAboutUsingContextAsConsumer) {
8322 hasWarnedAboutUsingContextAsConsumer = true;
8323 warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
8324 }
8325 }
8326 } else {
8327 context = context._context;
8328 }
8329 }
8330 var newProps = workInProgress.pendingProps;
8331 var render = newProps.children;
8332
8333 {
8334 !(typeof render === 'function') ? warningWithoutStack$1(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
8335 }
8336
8337 prepareToReadContext(workInProgress, renderExpirationTime);
8338 var newValue = readContext(context, newProps.unstable_observedBits);
8339 var newChildren = void 0;
8340 {
8341 ReactCurrentOwner$2.current = workInProgress;
8342 setCurrentPhase('render');
8343 newChildren = render(newValue);
8344 setCurrentPhase(null);
8345 }
8346
8347 // React DevTools reads this flag.
8348 workInProgress.effectTag |= PerformedWork;
8349 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
8350 return workInProgress.child;
8351}
8352
8353function updateEventComponent(current$$1, workInProgress, renderExpirationTime) {
8354 var nextProps = workInProgress.pendingProps;
8355 var nextChildren = nextProps.children;
8356
8357 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8358 pushHostContextForEventComponent(workInProgress);
8359 return workInProgress.child;
8360}
8361
8362function updateEventTarget(current$$1, workInProgress, renderExpirationTime) {
8363 var nextProps = workInProgress.pendingProps;
8364 var nextChildren = nextProps.children;
8365
8366 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8367 pushHostContextForEventTarget(workInProgress);
8368 return workInProgress.child;
8369}
8370
8371function markWorkInProgressReceivedUpdate() {
8372 didReceiveUpdate = true;
8373}
8374
8375function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
8376 cancelWorkTimer(workInProgress);
8377
8378 if (current$$1 !== null) {
8379 // Reuse previous context list
8380 workInProgress.contextDependencies = current$$1.contextDependencies;
8381 }
8382
8383 if (enableProfilerTimer) {
8384 // Don't update "base" render times for bailouts.
8385 stopProfilerTimerIfRunning(workInProgress);
8386 }
8387
8388 // Check if the children have any pending work.
8389 var childExpirationTime = workInProgress.childExpirationTime;
8390 if (childExpirationTime < renderExpirationTime) {
8391 // The children don't have any work either. We can skip them.
8392 // TODO: Once we add back resuming, we should check if the children are
8393 // a work-in-progress set. If so, we need to transfer their effects.
8394 return null;
8395 } else {
8396 // This fiber doesn't have work, but its subtree does. Clone the child
8397 // fibers and continue.
8398 cloneChildFibers(current$$1, workInProgress);
8399 return workInProgress.child;
8400 }
8401}
8402
8403function beginWork(current$$1, workInProgress, renderExpirationTime) {
8404 var updateExpirationTime = workInProgress.expirationTime;
8405
8406 if (current$$1 !== null) {
8407 var oldProps = current$$1.memoizedProps;
8408 var newProps = workInProgress.pendingProps;
8409
8410 if (oldProps !== newProps || hasContextChanged()) {
8411 // If props or context changed, mark the fiber as having performed work.
8412 // This may be unset if the props are determined to be equal later (memo).
8413 didReceiveUpdate = true;
8414 } else if (updateExpirationTime < renderExpirationTime) {
8415 didReceiveUpdate = false;
8416 // This fiber does not have any pending work. Bailout without entering
8417 // the begin phase. There's still some bookkeeping we that needs to be done
8418 // in this optimized path, mostly pushing stuff onto the stack.
8419 switch (workInProgress.tag) {
8420 case HostRoot:
8421 pushHostRootContext(workInProgress);
8422 resetHydrationState();
8423 break;
8424 case HostComponent:
8425 pushHostContext(workInProgress);
8426 break;
8427 case ClassComponent:
8428 {
8429 var Component = workInProgress.type;
8430 if (isContextProvider(Component)) {
8431 pushContextProvider(workInProgress);
8432 }
8433 break;
8434 }
8435 case HostPortal:
8436 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
8437 break;
8438 case ContextProvider:
8439 {
8440 var newValue = workInProgress.memoizedProps.value;
8441 pushProvider(workInProgress, newValue);
8442 break;
8443 }
8444 case Profiler:
8445 if (enableProfilerTimer) {
8446 workInProgress.effectTag |= Update;
8447 }
8448 break;
8449 case SuspenseComponent:
8450 {
8451 var state = workInProgress.memoizedState;
8452 var didTimeout = state !== null;
8453 if (didTimeout) {
8454 // If this boundary is currently timed out, we need to decide
8455 // whether to retry the primary children, or to skip over it and
8456 // go straight to the fallback. Check the priority of the primary
8457 var primaryChildFragment = workInProgress.child;
8458 var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
8459 if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
8460 // The primary children have pending work. Use the normal path
8461 // to attempt to render the primary children again.
8462 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
8463 } else {
8464 // The primary children do not have pending work with sufficient
8465 // priority. Bailout.
8466 var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8467 if (child !== null) {
8468 // The fallback children have pending work. Skip over the
8469 // primary children and work on the fallback.
8470 return child.sibling;
8471 } else {
8472 return null;
8473 }
8474 }
8475 }
8476 break;
8477 }
8478 case DehydratedSuspenseComponent:
8479 {
8480 if (enableSuspenseServerRenderer) {
8481 // We know that this component will suspend again because if it has
8482 // been unsuspended it has committed as a regular Suspense component.
8483 // If it needs to be retried, it should have work scheduled on it.
8484 workInProgress.effectTag |= DidCapture;
8485 }
8486 break;
8487 }
8488 case EventComponent:
8489 if (enableEventAPI) {
8490 pushHostContextForEventComponent(workInProgress);
8491 }
8492 break;
8493 case EventTarget:
8494 {
8495 if (enableEventAPI) {
8496 pushHostContextForEventTarget(workInProgress);
8497 }
8498 break;
8499 }
8500 }
8501 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8502 }
8503 } else {
8504 didReceiveUpdate = false;
8505 }
8506
8507 // Before entering the begin phase, clear the expiration time.
8508 workInProgress.expirationTime = NoWork;
8509
8510 switch (workInProgress.tag) {
8511 case IndeterminateComponent:
8512 {
8513 var elementType = workInProgress.elementType;
8514 return mountIndeterminateComponent(current$$1, workInProgress, elementType, renderExpirationTime);
8515 }
8516 case LazyComponent:
8517 {
8518 var _elementType = workInProgress.elementType;
8519 return mountLazyComponent(current$$1, workInProgress, _elementType, updateExpirationTime, renderExpirationTime);
8520 }
8521 case FunctionComponent:
8522 {
8523 var _Component = workInProgress.type;
8524 var unresolvedProps = workInProgress.pendingProps;
8525 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
8526 return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
8527 }
8528 case ClassComponent:
8529 {
8530 var _Component2 = workInProgress.type;
8531 var _unresolvedProps = workInProgress.pendingProps;
8532 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
8533 return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
8534 }
8535 case HostRoot:
8536 return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
8537 case HostComponent:
8538 return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
8539 case HostText:
8540 return updateHostText(current$$1, workInProgress);
8541 case SuspenseComponent:
8542 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
8543 case HostPortal:
8544 return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
8545 case ForwardRef:
8546 {
8547 var type = workInProgress.type;
8548 var _unresolvedProps2 = workInProgress.pendingProps;
8549 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
8550 return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
8551 }
8552 case Fragment:
8553 return updateFragment(current$$1, workInProgress, renderExpirationTime);
8554 case Mode$1:
8555 return updateMode(current$$1, workInProgress, renderExpirationTime);
8556 case Profiler:
8557 return updateProfiler(current$$1, workInProgress, renderExpirationTime);
8558 case ContextProvider:
8559 return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
8560 case ContextConsumer:
8561 return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
8562 case MemoComponent:
8563 {
8564 var _type2 = workInProgress.type;
8565 var _unresolvedProps3 = workInProgress.pendingProps;
8566 // Resolve outer props first, then resolve inner props.
8567 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
8568 {
8569 if (workInProgress.type !== workInProgress.elementType) {
8570 var outerPropTypes = _type2.propTypes;
8571 if (outerPropTypes) {
8572 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
8573 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
8574 }
8575 }
8576 }
8577 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
8578 return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
8579 }
8580 case SimpleMemoComponent:
8581 {
8582 return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
8583 }
8584 case IncompleteClassComponent:
8585 {
8586 var _Component3 = workInProgress.type;
8587 var _unresolvedProps4 = workInProgress.pendingProps;
8588 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
8589 return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
8590 }
8591 case DehydratedSuspenseComponent:
8592 {
8593 if (enableSuspenseServerRenderer) {
8594 return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
8595 }
8596 break;
8597 }
8598 case EventComponent:
8599 {
8600 if (enableEventAPI) {
8601 return updateEventComponent(current$$1, workInProgress, renderExpirationTime);
8602 }
8603 break;
8604 }
8605 case EventTarget:
8606 {
8607 if (enableEventAPI) {
8608 return updateEventTarget(current$$1, workInProgress, renderExpirationTime);
8609 }
8610 break;
8611 }
8612 }
8613 (function () {
8614 {
8615 {
8616 throw ReactError('Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
8617 }
8618 }
8619 })();
8620}
8621
8622var valueCursor = createCursor(null);
8623
8624var rendererSigil = void 0;
8625{
8626 // Use this to detect multiple renderers using the same context
8627 rendererSigil = {};
8628}
8629
8630var currentlyRenderingFiber = null;
8631var lastContextDependency = null;
8632var lastContextWithAllBitsObserved = null;
8633
8634var isDisallowedContextReadInDEV = false;
8635
8636function resetContextDependences() {
8637 // This is called right before React yields execution, to ensure `readContext`
8638 // cannot be called outside the render phase.
8639 currentlyRenderingFiber = null;
8640 lastContextDependency = null;
8641 lastContextWithAllBitsObserved = null;
8642 {
8643 isDisallowedContextReadInDEV = false;
8644 }
8645}
8646
8647function enterDisallowedContextReadInDEV() {
8648 {
8649 isDisallowedContextReadInDEV = true;
8650 }
8651}
8652
8653function exitDisallowedContextReadInDEV() {
8654 {
8655 isDisallowedContextReadInDEV = false;
8656 }
8657}
8658
8659function pushProvider(providerFiber, nextValue) {
8660 var context = providerFiber.type._context;
8661
8662 if (isPrimaryRenderer) {
8663 push(valueCursor, context._currentValue, providerFiber);
8664
8665 context._currentValue = nextValue;
8666 {
8667 !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
8668 context._currentRenderer = rendererSigil;
8669 }
8670 } else {
8671 push(valueCursor, context._currentValue2, providerFiber);
8672
8673 context._currentValue2 = nextValue;
8674 {
8675 !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
8676 context._currentRenderer2 = rendererSigil;
8677 }
8678 }
8679}
8680
8681function popProvider(providerFiber) {
8682 var currentValue = valueCursor.current;
8683
8684 pop(valueCursor, providerFiber);
8685
8686 var context = providerFiber.type._context;
8687 if (isPrimaryRenderer) {
8688 context._currentValue = currentValue;
8689 } else {
8690 context._currentValue2 = currentValue;
8691 }
8692}
8693
8694function calculateChangedBits(context, newValue, oldValue) {
8695 if (is(oldValue, newValue)) {
8696 // No change
8697 return 0;
8698 } else {
8699 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : maxSigned31BitInt;
8700
8701 {
8702 !((changedBits & maxSigned31BitInt) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
8703 }
8704 return changedBits | 0;
8705 }
8706}
8707
8708function scheduleWorkOnParentPath(parent, renderExpirationTime) {
8709 // Update the child expiration time of all the ancestors, including
8710 // the alternates.
8711 var node = parent;
8712 while (node !== null) {
8713 var alternate = node.alternate;
8714 if (node.childExpirationTime < renderExpirationTime) {
8715 node.childExpirationTime = renderExpirationTime;
8716 if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
8717 alternate.childExpirationTime = renderExpirationTime;
8718 }
8719 } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
8720 alternate.childExpirationTime = renderExpirationTime;
8721 } else {
8722 // Neither alternate was updated, which means the rest of the
8723 // ancestor path already has sufficient priority.
8724 break;
8725 }
8726 node = node.return;
8727 }
8728}
8729
8730function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
8731 var fiber = workInProgress.child;
8732 if (fiber !== null) {
8733 // Set the return pointer of the child to the work-in-progress fiber.
8734 fiber.return = workInProgress;
8735 }
8736 while (fiber !== null) {
8737 var nextFiber = void 0;
8738
8739 // Visit this fiber.
8740 var list = fiber.contextDependencies;
8741 if (list !== null) {
8742 nextFiber = fiber.child;
8743
8744 var dependency = list.first;
8745 while (dependency !== null) {
8746 // Check if the context matches.
8747 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
8748 // Match! Schedule an update on this fiber.
8749
8750 if (fiber.tag === ClassComponent) {
8751 // Schedule a force update on the work-in-progress.
8752 var update = createUpdate(renderExpirationTime);
8753 update.tag = ForceUpdate;
8754 // TODO: Because we don't have a work-in-progress, this will add the
8755 // update to the current fiber, too, which means it will persist even if
8756 // this render is thrown away. Since it's a race condition, not sure it's
8757 // worth fixing.
8758 enqueueUpdate(fiber, update);
8759 }
8760
8761 if (fiber.expirationTime < renderExpirationTime) {
8762 fiber.expirationTime = renderExpirationTime;
8763 }
8764 var alternate = fiber.alternate;
8765 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
8766 alternate.expirationTime = renderExpirationTime;
8767 }
8768
8769 scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
8770
8771 // Mark the expiration time on the list, too.
8772 if (list.expirationTime < renderExpirationTime) {
8773 list.expirationTime = renderExpirationTime;
8774 }
8775
8776 // Since we already found a match, we can stop traversing the
8777 // dependency list.
8778 break;
8779 }
8780 dependency = dependency.next;
8781 }
8782 } else if (fiber.tag === ContextProvider) {
8783 // Don't scan deeper if this is a matching provider
8784 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
8785 } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
8786 // If a dehydrated suspense component is in this subtree, we don't know
8787 // if it will have any context consumers in it. The best we can do is
8788 // mark it as having updates on its children.
8789 if (fiber.expirationTime < renderExpirationTime) {
8790 fiber.expirationTime = renderExpirationTime;
8791 }
8792 var _alternate = fiber.alternate;
8793 if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
8794 _alternate.expirationTime = renderExpirationTime;
8795 }
8796 // This is intentionally passing this fiber as the parent
8797 // because we want to schedule this fiber as having work
8798 // on its children. We'll use the childExpirationTime on
8799 // this fiber to indicate that a context has changed.
8800 scheduleWorkOnParentPath(fiber, renderExpirationTime);
8801 nextFiber = fiber.sibling;
8802 } else {
8803 // Traverse down.
8804 nextFiber = fiber.child;
8805 }
8806
8807 if (nextFiber !== null) {
8808 // Set the return pointer of the child to the work-in-progress fiber.
8809 nextFiber.return = fiber;
8810 } else {
8811 // No child. Traverse to next sibling.
8812 nextFiber = fiber;
8813 while (nextFiber !== null) {
8814 if (nextFiber === workInProgress) {
8815 // We're back to the root of this subtree. Exit.
8816 nextFiber = null;
8817 break;
8818 }
8819 var sibling = nextFiber.sibling;
8820 if (sibling !== null) {
8821 // Set the return pointer of the sibling to the work-in-progress fiber.
8822 sibling.return = nextFiber.return;
8823 nextFiber = sibling;
8824 break;
8825 }
8826 // No more siblings. Traverse up.
8827 nextFiber = nextFiber.return;
8828 }
8829 }
8830 fiber = nextFiber;
8831 }
8832}
8833
8834function prepareToReadContext(workInProgress, renderExpirationTime) {
8835 currentlyRenderingFiber = workInProgress;
8836 lastContextDependency = null;
8837 lastContextWithAllBitsObserved = null;
8838
8839 var currentDependencies = workInProgress.contextDependencies;
8840 if (currentDependencies !== null && currentDependencies.expirationTime >= renderExpirationTime) {
8841 // Context list has a pending update. Mark that this fiber performed work.
8842 markWorkInProgressReceivedUpdate();
8843 }
8844
8845 // Reset the work-in-progress list
8846 workInProgress.contextDependencies = null;
8847}
8848
8849function readContext(context, observedBits) {
8850 {
8851 // This warning would fire if you read context inside a Hook like useMemo.
8852 // Unlike the class check below, it's not enforced in production for perf.
8853 !!isDisallowedContextReadInDEV ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
8854 }
8855
8856 if (lastContextWithAllBitsObserved === context) {
8857 // Nothing to do. We already observe everything in this context.
8858 } else if (observedBits === false || observedBits === 0) {
8859 // Do not observe any updates.
8860 } else {
8861 var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types.
8862 if (typeof observedBits !== 'number' || observedBits === maxSigned31BitInt) {
8863 // Observe all updates.
8864 lastContextWithAllBitsObserved = context;
8865 resolvedObservedBits = maxSigned31BitInt;
8866 } else {
8867 resolvedObservedBits = observedBits;
8868 }
8869
8870 var contextItem = {
8871 context: context,
8872 observedBits: resolvedObservedBits,
8873 next: null
8874 };
8875
8876 if (lastContextDependency === null) {
8877 (function () {
8878 if (!(currentlyRenderingFiber !== null)) {
8879 {
8880 throw ReactError('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().');
8881 }
8882 }
8883 })();
8884
8885 // This is the first dependency for this component. Create a new list.
8886 lastContextDependency = contextItem;
8887 currentlyRenderingFiber.contextDependencies = {
8888 first: contextItem,
8889 expirationTime: NoWork
8890 };
8891 } else {
8892 // Append a new context item.
8893 lastContextDependency = lastContextDependency.next = contextItem;
8894 }
8895 }
8896 return isPrimaryRenderer ? context._currentValue : context._currentValue2;
8897}
8898
8899// UpdateQueue is a linked list of prioritized updates.
8900//
8901// Like fibers, update queues come in pairs: a current queue, which represents
8902// the visible state of the screen, and a work-in-progress queue, which can be
8903// mutated and processed asynchronously before it is committed — a form of
8904// double buffering. If a work-in-progress render is discarded before finishing,
8905// we create a new work-in-progress by cloning the current queue.
8906//
8907// Both queues share a persistent, singly-linked list structure. To schedule an
8908// update, we append it to the end of both queues. Each queue maintains a
8909// pointer to first update in the persistent list that hasn't been processed.
8910// The work-in-progress pointer always has a position equal to or greater than
8911// the current queue, since we always work on that one. The current queue's
8912// pointer is only updated during the commit phase, when we swap in the
8913// work-in-progress.
8914//
8915// For example:
8916//
8917// Current pointer: A - B - C - D - E - F
8918// Work-in-progress pointer: D - E - F
8919// ^
8920// The work-in-progress queue has
8921// processed more updates than current.
8922//
8923// The reason we append to both queues is because otherwise we might drop
8924// updates without ever processing them. For example, if we only add updates to
8925// the work-in-progress queue, some updates could be lost whenever a work-in
8926// -progress render restarts by cloning from current. Similarly, if we only add
8927// updates to the current queue, the updates will be lost whenever an already
8928// in-progress queue commits and swaps with the current queue. However, by
8929// adding to both queues, we guarantee that the update will be part of the next
8930// work-in-progress. (And because the work-in-progress queue becomes the
8931// current queue once it commits, there's no danger of applying the same
8932// update twice.)
8933//
8934// Prioritization
8935// --------------
8936//
8937// Updates are not sorted by priority, but by insertion; new updates are always
8938// appended to the end of the list.
8939//
8940// The priority is still important, though. When processing the update queue
8941// during the render phase, only the updates with sufficient priority are
8942// included in the result. If we skip an update because it has insufficient
8943// priority, it remains in the queue to be processed later, during a lower
8944// priority render. Crucially, all updates subsequent to a skipped update also
8945// remain in the queue *regardless of their priority*. That means high priority
8946// updates are sometimes processed twice, at two separate priorities. We also
8947// keep track of a base state, that represents the state before the first
8948// update in the queue is applied.
8949//
8950// For example:
8951//
8952// Given a base state of '', and the following queue of updates
8953//
8954// A1 - B2 - C1 - D2
8955//
8956// where the number indicates the priority, and the update is applied to the
8957// previous state by appending a letter, React will process these updates as
8958// two separate renders, one per distinct priority level:
8959//
8960// First render, at priority 1:
8961// Base state: ''
8962// Updates: [A1, C1]
8963// Result state: 'AC'
8964//
8965// Second render, at priority 2:
8966// Base state: 'A' <- The base state does not include C1,
8967// because B2 was skipped.
8968// Updates: [B2, C1, D2] <- C1 was rebased on top of B2
8969// Result state: 'ABCD'
8970//
8971// Because we process updates in insertion order, and rebase high priority
8972// updates when preceding updates are skipped, the final result is deterministic
8973// regardless of priority. Intermediate state may vary according to system
8974// resources, but the final state is always the same.
8975
8976var UpdateState = 0;
8977var ReplaceState = 1;
8978var ForceUpdate = 2;
8979var CaptureUpdate = 3;
8980
8981// Global state that is reset at the beginning of calling `processUpdateQueue`.
8982// It should only be read right after calling `processUpdateQueue`, via
8983// `checkHasForceUpdateAfterProcessing`.
8984var hasForceUpdate = false;
8985
8986var didWarnUpdateInsideUpdate = void 0;
8987var currentlyProcessingQueue = void 0;
8988var resetCurrentlyProcessingQueue = void 0;
8989{
8990 didWarnUpdateInsideUpdate = false;
8991 currentlyProcessingQueue = null;
8992 resetCurrentlyProcessingQueue = function () {
8993 currentlyProcessingQueue = null;
8994 };
8995}
8996
8997function createUpdateQueue(baseState) {
8998 var queue = {
8999 baseState: baseState,
9000 firstUpdate: null,
9001 lastUpdate: null,
9002 firstCapturedUpdate: null,
9003 lastCapturedUpdate: null,
9004 firstEffect: null,
9005 lastEffect: null,
9006 firstCapturedEffect: null,
9007 lastCapturedEffect: null
9008 };
9009 return queue;
9010}
9011
9012function cloneUpdateQueue(currentQueue) {
9013 var queue = {
9014 baseState: currentQueue.baseState,
9015 firstUpdate: currentQueue.firstUpdate,
9016 lastUpdate: currentQueue.lastUpdate,
9017
9018 // TODO: With resuming, if we bail out and resuse the child tree, we should
9019 // keep these effects.
9020 firstCapturedUpdate: null,
9021 lastCapturedUpdate: null,
9022
9023 firstEffect: null,
9024 lastEffect: null,
9025
9026 firstCapturedEffect: null,
9027 lastCapturedEffect: null
9028 };
9029 return queue;
9030}
9031
9032function createUpdate(expirationTime) {
9033 return {
9034 expirationTime: expirationTime,
9035
9036 tag: UpdateState,
9037 payload: null,
9038 callback: null,
9039
9040 next: null,
9041 nextEffect: null
9042 };
9043}
9044
9045function appendUpdateToQueue(queue, update) {
9046 // Append the update to the end of the list.
9047 if (queue.lastUpdate === null) {
9048 // Queue is empty
9049 queue.firstUpdate = queue.lastUpdate = update;
9050 } else {
9051 queue.lastUpdate.next = update;
9052 queue.lastUpdate = update;
9053 }
9054}
9055
9056function enqueueUpdate(fiber, update) {
9057 // Update queues are created lazily.
9058 var alternate = fiber.alternate;
9059 var queue1 = void 0;
9060 var queue2 = void 0;
9061 if (alternate === null) {
9062 // There's only one fiber.
9063 queue1 = fiber.updateQueue;
9064 queue2 = null;
9065 if (queue1 === null) {
9066 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
9067 }
9068 } else {
9069 // There are two owners.
9070 queue1 = fiber.updateQueue;
9071 queue2 = alternate.updateQueue;
9072 if (queue1 === null) {
9073 if (queue2 === null) {
9074 // Neither fiber has an update queue. Create new ones.
9075 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
9076 queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
9077 } else {
9078 // Only one fiber has an update queue. Clone to create a new one.
9079 queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
9080 }
9081 } else {
9082 if (queue2 === null) {
9083 // Only one fiber has an update queue. Clone to create a new one.
9084 queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
9085 } else {
9086 // Both owners have an update queue.
9087 }
9088 }
9089 }
9090 if (queue2 === null || queue1 === queue2) {
9091 // There's only a single queue.
9092 appendUpdateToQueue(queue1, update);
9093 } else {
9094 // There are two queues. We need to append the update to both queues,
9095 // while accounting for the persistent structure of the list — we don't
9096 // want the same update to be added multiple times.
9097 if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
9098 // One of the queues is not empty. We must add the update to both queues.
9099 appendUpdateToQueue(queue1, update);
9100 appendUpdateToQueue(queue2, update);
9101 } else {
9102 // Both queues are non-empty. The last update is the same in both lists,
9103 // because of structural sharing. So, only append to one of the lists.
9104 appendUpdateToQueue(queue1, update);
9105 // But we still need to update the `lastUpdate` pointer of queue2.
9106 queue2.lastUpdate = update;
9107 }
9108 }
9109
9110 {
9111 if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
9112 warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
9113 didWarnUpdateInsideUpdate = true;
9114 }
9115 }
9116}
9117
9118function enqueueCapturedUpdate(workInProgress, update) {
9119 // Captured updates go into a separate list, and only on the work-in-
9120 // progress queue.
9121 var workInProgressQueue = workInProgress.updateQueue;
9122 if (workInProgressQueue === null) {
9123 workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
9124 } else {
9125 // TODO: I put this here rather than createWorkInProgress so that we don't
9126 // clone the queue unnecessarily. There's probably a better way to
9127 // structure this.
9128 workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
9129 }
9130
9131 // Append the update to the end of the list.
9132 if (workInProgressQueue.lastCapturedUpdate === null) {
9133 // This is the first render phase update
9134 workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
9135 } else {
9136 workInProgressQueue.lastCapturedUpdate.next = update;
9137 workInProgressQueue.lastCapturedUpdate = update;
9138 }
9139}
9140
9141function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
9142 var current = workInProgress.alternate;
9143 if (current !== null) {
9144 // If the work-in-progress queue is equal to the current queue,
9145 // we need to clone it first.
9146 if (queue === current.updateQueue) {
9147 queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
9148 }
9149 }
9150 return queue;
9151}
9152
9153function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
9154 switch (update.tag) {
9155 case ReplaceState:
9156 {
9157 var _payload = update.payload;
9158 if (typeof _payload === 'function') {
9159 // Updater function
9160 {
9161 enterDisallowedContextReadInDEV();
9162 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
9163 _payload.call(instance, prevState, nextProps);
9164 }
9165 }
9166 var nextState = _payload.call(instance, prevState, nextProps);
9167 {
9168 exitDisallowedContextReadInDEV();
9169 }
9170 return nextState;
9171 }
9172 // State object
9173 return _payload;
9174 }
9175 case CaptureUpdate:
9176 {
9177 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
9178 }
9179 // Intentional fallthrough
9180 case UpdateState:
9181 {
9182 var _payload2 = update.payload;
9183 var partialState = void 0;
9184 if (typeof _payload2 === 'function') {
9185 // Updater function
9186 {
9187 enterDisallowedContextReadInDEV();
9188 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
9189 _payload2.call(instance, prevState, nextProps);
9190 }
9191 }
9192 partialState = _payload2.call(instance, prevState, nextProps);
9193 {
9194 exitDisallowedContextReadInDEV();
9195 }
9196 } else {
9197 // Partial state object
9198 partialState = _payload2;
9199 }
9200 if (partialState === null || partialState === undefined) {
9201 // Null and undefined are treated as no-ops.
9202 return prevState;
9203 }
9204 // Merge the partial state and the previous state.
9205 return _assign({}, prevState, partialState);
9206 }
9207 case ForceUpdate:
9208 {
9209 hasForceUpdate = true;
9210 return prevState;
9211 }
9212 }
9213 return prevState;
9214}
9215
9216function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
9217 hasForceUpdate = false;
9218
9219 queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
9220
9221 {
9222 currentlyProcessingQueue = queue;
9223 }
9224
9225 // These values may change as we process the queue.
9226 var newBaseState = queue.baseState;
9227 var newFirstUpdate = null;
9228 var newExpirationTime = NoWork;
9229
9230 // Iterate through the list of updates to compute the result.
9231 var update = queue.firstUpdate;
9232 var resultState = newBaseState;
9233 while (update !== null) {
9234 var updateExpirationTime = update.expirationTime;
9235 if (updateExpirationTime < renderExpirationTime) {
9236 // This update does not have sufficient priority. Skip it.
9237 if (newFirstUpdate === null) {
9238 // This is the first skipped update. It will be the first update in
9239 // the new list.
9240 newFirstUpdate = update;
9241 // Since this is the first update that was skipped, the current result
9242 // is the new base state.
9243 newBaseState = resultState;
9244 }
9245 // Since this update will remain in the list, update the remaining
9246 // expiration time.
9247 if (newExpirationTime < updateExpirationTime) {
9248 newExpirationTime = updateExpirationTime;
9249 }
9250 } else {
9251 // This update does have sufficient priority. Process it and compute
9252 // a new result.
9253 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
9254 var _callback = update.callback;
9255 if (_callback !== null) {
9256 workInProgress.effectTag |= Callback;
9257 // Set this to null, in case it was mutated during an aborted render.
9258 update.nextEffect = null;
9259 if (queue.lastEffect === null) {
9260 queue.firstEffect = queue.lastEffect = update;
9261 } else {
9262 queue.lastEffect.nextEffect = update;
9263 queue.lastEffect = update;
9264 }
9265 }
9266 }
9267 // Continue to the next update.
9268 update = update.next;
9269 }
9270
9271 // Separately, iterate though the list of captured updates.
9272 var newFirstCapturedUpdate = null;
9273 update = queue.firstCapturedUpdate;
9274 while (update !== null) {
9275 var _updateExpirationTime = update.expirationTime;
9276 if (_updateExpirationTime < renderExpirationTime) {
9277 // This update does not have sufficient priority. Skip it.
9278 if (newFirstCapturedUpdate === null) {
9279 // This is the first skipped captured update. It will be the first
9280 // update in the new list.
9281 newFirstCapturedUpdate = update;
9282 // If this is the first update that was skipped, the current result is
9283 // the new base state.
9284 if (newFirstUpdate === null) {
9285 newBaseState = resultState;
9286 }
9287 }
9288 // Since this update will remain in the list, update the remaining
9289 // expiration time.
9290 if (newExpirationTime < _updateExpirationTime) {
9291 newExpirationTime = _updateExpirationTime;
9292 }
9293 } else {
9294 // This update does have sufficient priority. Process it and compute
9295 // a new result.
9296 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
9297 var _callback2 = update.callback;
9298 if (_callback2 !== null) {
9299 workInProgress.effectTag |= Callback;
9300 // Set this to null, in case it was mutated during an aborted render.
9301 update.nextEffect = null;
9302 if (queue.lastCapturedEffect === null) {
9303 queue.firstCapturedEffect = queue.lastCapturedEffect = update;
9304 } else {
9305 queue.lastCapturedEffect.nextEffect = update;
9306 queue.lastCapturedEffect = update;
9307 }
9308 }
9309 }
9310 update = update.next;
9311 }
9312
9313 if (newFirstUpdate === null) {
9314 queue.lastUpdate = null;
9315 }
9316 if (newFirstCapturedUpdate === null) {
9317 queue.lastCapturedUpdate = null;
9318 } else {
9319 workInProgress.effectTag |= Callback;
9320 }
9321 if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
9322 // We processed every update, without skipping. That means the new base
9323 // state is the same as the result state.
9324 newBaseState = resultState;
9325 }
9326
9327 queue.baseState = newBaseState;
9328 queue.firstUpdate = newFirstUpdate;
9329 queue.firstCapturedUpdate = newFirstCapturedUpdate;
9330
9331 // Set the remaining expiration time to be whatever is remaining in the queue.
9332 // This should be fine because the only two other things that contribute to
9333 // expiration time are props and context. We're already in the middle of the
9334 // begin phase by the time we start processing the queue, so we've already
9335 // dealt with the props. Context in components that specify
9336 // shouldComponentUpdate is tricky; but we'll have to account for
9337 // that regardless.
9338 workInProgress.expirationTime = newExpirationTime;
9339 workInProgress.memoizedState = resultState;
9340
9341 {
9342 currentlyProcessingQueue = null;
9343 }
9344}
9345
9346function callCallback(callback, context) {
9347 (function () {
9348 if (!(typeof callback === 'function')) {
9349 {
9350 throw ReactError('Invalid argument passed as callback. Expected a function. Instead received: ' + callback);
9351 }
9352 }
9353 })();
9354 callback.call(context);
9355}
9356
9357function resetHasForceUpdateBeforeProcessing() {
9358 hasForceUpdate = false;
9359}
9360
9361function checkHasForceUpdateAfterProcessing() {
9362 return hasForceUpdate;
9363}
9364
9365function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
9366 // If the finished render included captured updates, and there are still
9367 // lower priority updates left over, we need to keep the captured updates
9368 // in the queue so that they are rebased and not dropped once we process the
9369 // queue again at the lower priority.
9370 if (finishedQueue.firstCapturedUpdate !== null) {
9371 // Join the captured update list to the end of the normal list.
9372 if (finishedQueue.lastUpdate !== null) {
9373 finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
9374 finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
9375 }
9376 // Clear the list of captured updates.
9377 finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
9378 }
9379
9380 // Commit the effects
9381 commitUpdateEffects(finishedQueue.firstEffect, instance);
9382 finishedQueue.firstEffect = finishedQueue.lastEffect = null;
9383
9384 commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
9385 finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
9386}
9387
9388function commitUpdateEffects(effect, instance) {
9389 while (effect !== null) {
9390 var _callback3 = effect.callback;
9391 if (_callback3 !== null) {
9392 effect.callback = null;
9393 callCallback(_callback3, instance);
9394 }
9395 effect = effect.nextEffect;
9396 }
9397}
9398
9399function createCapturedValue(value, source) {
9400 // If the value is an error, call this function immediately after it is thrown
9401 // so the stack is accurate.
9402 return {
9403 value: value,
9404 source: source,
9405 stack: getStackByFiberInDevAndProd(source)
9406 };
9407}
9408
9409function markUpdate(workInProgress) {
9410 // Tag the fiber with an update effect. This turns a Placement into
9411 // a PlacementAndUpdate.
9412 workInProgress.effectTag |= Update;
9413}
9414
9415function markRef$1(workInProgress) {
9416 workInProgress.effectTag |= Ref;
9417}
9418
9419var appendAllChildren = void 0;
9420var updateHostContainer = void 0;
9421var updateHostComponent$1 = void 0;
9422var updateHostText$1 = void 0;
9423if (supportsMutation) {
9424 // Mutation mode
9425
9426 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
9427 // We only have the top Fiber that was created but we need recurse down its
9428 // children to find all the terminal nodes.
9429 var node = workInProgress.child;
9430 while (node !== null) {
9431 if (node.tag === HostComponent || node.tag === HostText) {
9432 appendInitialChild(parent, node.stateNode);
9433 } else if (node.tag === HostPortal) {
9434 // If we have a portal child, then we don't want to traverse
9435 // down its children. Instead, we'll get insertions from each child in
9436 // the portal directly.
9437 } else if (node.child !== null) {
9438 node.child.return = node;
9439 node = node.child;
9440 continue;
9441 }
9442 if (node === workInProgress) {
9443 return;
9444 }
9445 while (node.sibling === null) {
9446 if (node.return === null || node.return === workInProgress) {
9447 return;
9448 }
9449 node = node.return;
9450 }
9451 node.sibling.return = node.return;
9452 node = node.sibling;
9453 }
9454 };
9455
9456 updateHostContainer = function (workInProgress) {
9457 // Noop
9458 };
9459 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
9460 // If we have an alternate, that means this is an update and we need to
9461 // schedule a side-effect to do the updates.
9462 var oldProps = current.memoizedProps;
9463 if (oldProps === newProps) {
9464 // In mutation mode, this is sufficient for a bailout because
9465 // we won't touch this node even if children changed.
9466 return;
9467 }
9468
9469 // If we get updated because one of our children updated, we don't
9470 // have newProps so we'll have to reuse them.
9471 // TODO: Split the update API as separate for the props vs. children.
9472 // Even better would be if children weren't special cased at all tho.
9473 var instance = workInProgress.stateNode;
9474 var currentHostContext = getHostContext();
9475 // TODO: Experiencing an error where oldProps is null. Suggests a host
9476 // component is hitting the resume path. Figure out why. Possibly
9477 // related to `hidden`.
9478 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
9479 // TODO: Type this specific to this type of component.
9480 workInProgress.updateQueue = updatePayload;
9481 // If the update payload indicates that there is a change or if there
9482 // is a new ref we mark this as an update. All the work is done in commitWork.
9483 if (updatePayload) {
9484 markUpdate(workInProgress);
9485 }
9486 };
9487 updateHostText$1 = function (current, workInProgress, oldText, newText) {
9488 // If the text differs, mark it as an update. All the work in done in commitWork.
9489 if (oldText !== newText) {
9490 markUpdate(workInProgress);
9491 }
9492 };
9493} else if (supportsPersistence) {
9494 // Persistent host tree mode
9495
9496 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
9497 // We only have the top Fiber that was created but we need recurse down its
9498 // children to find all the terminal nodes.
9499 var node = workInProgress.child;
9500 while (node !== null) {
9501 // eslint-disable-next-line no-labels
9502 branches: if (node.tag === HostComponent) {
9503 var instance = node.stateNode;
9504 if (needsVisibilityToggle && isHidden) {
9505 // This child is inside a timed out tree. Hide it.
9506 var props = node.memoizedProps;
9507 var type = node.type;
9508 instance = cloneHiddenInstance(instance, type, props, node);
9509 }
9510 appendInitialChild(parent, instance);
9511 } else if (node.tag === HostText) {
9512 var _instance = node.stateNode;
9513 if (needsVisibilityToggle && isHidden) {
9514 // This child is inside a timed out tree. Hide it.
9515 var text = node.memoizedProps;
9516 _instance = cloneHiddenTextInstance(_instance, text, node);
9517 }
9518 appendInitialChild(parent, _instance);
9519 } else if (node.tag === HostPortal) {
9520 // If we have a portal child, then we don't want to traverse
9521 // down its children. Instead, we'll get insertions from each child in
9522 // the portal directly.
9523 } else if (node.tag === SuspenseComponent) {
9524 if ((node.effectTag & Update) !== NoEffect) {
9525 // Need to toggle the visibility of the primary children.
9526 var newIsHidden = node.memoizedState !== null;
9527 if (newIsHidden) {
9528 var primaryChildParent = node.child;
9529 if (primaryChildParent !== null) {
9530 if (primaryChildParent.child !== null) {
9531 primaryChildParent.child.return = primaryChildParent;
9532 appendAllChildren(parent, primaryChildParent, true, newIsHidden);
9533 }
9534 var fallbackChildParent = primaryChildParent.sibling;
9535 if (fallbackChildParent !== null) {
9536 fallbackChildParent.return = node;
9537 node = fallbackChildParent;
9538 continue;
9539 }
9540 }
9541 }
9542 }
9543 if (node.child !== null) {
9544 // Continue traversing like normal
9545 node.child.return = node;
9546 node = node.child;
9547 continue;
9548 }
9549 } else if (node.child !== null) {
9550 node.child.return = node;
9551 node = node.child;
9552 continue;
9553 }
9554 // $FlowFixMe This is correct but Flow is confused by the labeled break.
9555 node = node;
9556 if (node === workInProgress) {
9557 return;
9558 }
9559 while (node.sibling === null) {
9560 if (node.return === null || node.return === workInProgress) {
9561 return;
9562 }
9563 node = node.return;
9564 }
9565 node.sibling.return = node.return;
9566 node = node.sibling;
9567 }
9568 };
9569
9570 // An unfortunate fork of appendAllChildren because we have two different parent types.
9571 var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
9572 // We only have the top Fiber that was created but we need recurse down its
9573 // children to find all the terminal nodes.
9574 var node = workInProgress.child;
9575 while (node !== null) {
9576 // eslint-disable-next-line no-labels
9577 branches: if (node.tag === HostComponent) {
9578 var instance = node.stateNode;
9579 if (needsVisibilityToggle && isHidden) {
9580 // This child is inside a timed out tree. Hide it.
9581 var props = node.memoizedProps;
9582 var type = node.type;
9583 instance = cloneHiddenInstance(instance, type, props, node);
9584 }
9585 appendChildToContainerChildSet(containerChildSet, instance);
9586 } else if (node.tag === HostText) {
9587 var _instance2 = node.stateNode;
9588 if (needsVisibilityToggle && isHidden) {
9589 // This child is inside a timed out tree. Hide it.
9590 var text = node.memoizedProps;
9591 _instance2 = cloneHiddenTextInstance(_instance2, text, node);
9592 }
9593 appendChildToContainerChildSet(containerChildSet, _instance2);
9594 } else if (node.tag === HostPortal) {
9595 // If we have a portal child, then we don't want to traverse
9596 // down its children. Instead, we'll get insertions from each child in
9597 // the portal directly.
9598 } else if (node.tag === SuspenseComponent) {
9599 if ((node.effectTag & Update) !== NoEffect) {
9600 // Need to toggle the visibility of the primary children.
9601 var newIsHidden = node.memoizedState !== null;
9602 if (newIsHidden) {
9603 var primaryChildParent = node.child;
9604 if (primaryChildParent !== null) {
9605 if (primaryChildParent.child !== null) {
9606 primaryChildParent.child.return = primaryChildParent;
9607 appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
9608 }
9609 var fallbackChildParent = primaryChildParent.sibling;
9610 if (fallbackChildParent !== null) {
9611 fallbackChildParent.return = node;
9612 node = fallbackChildParent;
9613 continue;
9614 }
9615 }
9616 }
9617 }
9618 if (node.child !== null) {
9619 // Continue traversing like normal
9620 node.child.return = node;
9621 node = node.child;
9622 continue;
9623 }
9624 } else if (node.child !== null) {
9625 node.child.return = node;
9626 node = node.child;
9627 continue;
9628 }
9629 // $FlowFixMe This is correct but Flow is confused by the labeled break.
9630 node = node;
9631 if (node === workInProgress) {
9632 return;
9633 }
9634 while (node.sibling === null) {
9635 if (node.return === null || node.return === workInProgress) {
9636 return;
9637 }
9638 node = node.return;
9639 }
9640 node.sibling.return = node.return;
9641 node = node.sibling;
9642 }
9643 };
9644 updateHostContainer = function (workInProgress) {
9645 var portalOrRoot = workInProgress.stateNode;
9646 var childrenUnchanged = workInProgress.firstEffect === null;
9647 if (childrenUnchanged) {
9648 // No changes, just reuse the existing instance.
9649 } else {
9650 var container = portalOrRoot.containerInfo;
9651 var newChildSet = createContainerChildSet(container);
9652 // If children might have changed, we have to add them all to the set.
9653 appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
9654 portalOrRoot.pendingChildren = newChildSet;
9655 // Schedule an update on the container to swap out the container.
9656 markUpdate(workInProgress);
9657 finalizeContainerChildren(container, newChildSet);
9658 }
9659 };
9660 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
9661 var currentInstance = current.stateNode;
9662 var oldProps = current.memoizedProps;
9663 // If there are no effects associated with this node, then none of our children had any updates.
9664 // This guarantees that we can reuse all of them.
9665 var childrenUnchanged = workInProgress.firstEffect === null;
9666 if (childrenUnchanged && oldProps === newProps) {
9667 // No changes, just reuse the existing instance.
9668 // Note that this might release a previous clone.
9669 workInProgress.stateNode = currentInstance;
9670 return;
9671 }
9672 var recyclableInstance = workInProgress.stateNode;
9673 var currentHostContext = getHostContext();
9674 var updatePayload = null;
9675 if (oldProps !== newProps) {
9676 updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
9677 }
9678 if (childrenUnchanged && updatePayload === null) {
9679 // No changes, just reuse the existing instance.
9680 // Note that this might release a previous clone.
9681 workInProgress.stateNode = currentInstance;
9682 return;
9683 }
9684 var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
9685 if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
9686 markUpdate(workInProgress);
9687 }
9688 workInProgress.stateNode = newInstance;
9689 if (childrenUnchanged) {
9690 // If there are no other effects in this tree, we need to flag this node as having one.
9691 // Even though we're not going to use it for anything.
9692 // Otherwise parents won't know that there are new children to propagate upwards.
9693 markUpdate(workInProgress);
9694 } else {
9695 // If children might have changed, we have to add them all to the set.
9696 appendAllChildren(newInstance, workInProgress, false, false);
9697 }
9698 };
9699 updateHostText$1 = function (current, workInProgress, oldText, newText) {
9700 if (oldText !== newText) {
9701 // If the text content differs, we'll create a new text instance for it.
9702 var rootContainerInstance = getRootHostContainer();
9703 var currentHostContext = getHostContext();
9704 workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress);
9705 // We'll have to mark it as having an effect, even though we won't use the effect for anything.
9706 // This lets the parents know that at least one of their children has changed.
9707 markUpdate(workInProgress);
9708 }
9709 };
9710} else {
9711 // No host operations
9712 updateHostContainer = function (workInProgress) {
9713 // Noop
9714 };
9715 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
9716 // Noop
9717 };
9718 updateHostText$1 = function (current, workInProgress, oldText, newText) {
9719 // Noop
9720 };
9721}
9722
9723function completeWork(current, workInProgress, renderExpirationTime) {
9724 var newProps = workInProgress.pendingProps;
9725
9726 switch (workInProgress.tag) {
9727 case IndeterminateComponent:
9728 break;
9729 case LazyComponent:
9730 break;
9731 case SimpleMemoComponent:
9732 case FunctionComponent:
9733 break;
9734 case ClassComponent:
9735 {
9736 var Component = workInProgress.type;
9737 if (isContextProvider(Component)) {
9738 popContext(workInProgress);
9739 }
9740 break;
9741 }
9742 case HostRoot:
9743 {
9744 popHostContainer(workInProgress);
9745 popTopLevelContextObject(workInProgress);
9746 var fiberRoot = workInProgress.stateNode;
9747 if (fiberRoot.pendingContext) {
9748 fiberRoot.context = fiberRoot.pendingContext;
9749 fiberRoot.pendingContext = null;
9750 }
9751 if (current === null || current.child === null) {
9752 // If we hydrated, pop so that we can delete any remaining children
9753 // that weren't hydrated.
9754 popHydrationState(workInProgress);
9755 // This resets the hacky state to fix isMounted before committing.
9756 // TODO: Delete this when we delete isMounted and findDOMNode.
9757 workInProgress.effectTag &= ~Placement;
9758 }
9759 updateHostContainer(workInProgress);
9760 break;
9761 }
9762 case HostComponent:
9763 {
9764 popHostContext(workInProgress);
9765 var rootContainerInstance = getRootHostContainer();
9766 var type = workInProgress.type;
9767 if (current !== null && workInProgress.stateNode != null) {
9768 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
9769
9770 if (current.ref !== workInProgress.ref) {
9771 markRef$1(workInProgress);
9772 }
9773 } else {
9774 if (!newProps) {
9775 (function () {
9776 if (!(workInProgress.stateNode !== null)) {
9777 {
9778 throw ReactError('We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.');
9779 }
9780 }
9781 })();
9782 // This can happen when we abort work.
9783 break;
9784 }
9785
9786 var currentHostContext = getHostContext();
9787 // TODO: Move createInstance to beginWork and keep it on a context
9788 // "stack" as the parent. Then append children as we go in beginWork
9789 // or completeWork depending on we want to add then top->down or
9790 // bottom->up. Top->down is faster in IE11.
9791 var wasHydrated = popHydrationState(workInProgress);
9792 if (wasHydrated) {
9793 // TODO: Move this and createInstance step into the beginPhase
9794 // to consolidate.
9795 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
9796 // If changes to the hydrated node needs to be applied at the
9797 // commit-phase we mark this as such.
9798 markUpdate(workInProgress);
9799 }
9800 } else {
9801 var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
9802
9803 appendAllChildren(instance, workInProgress, false, false);
9804
9805 // Certain renderers require commit-time effects for initial mount.
9806 // (eg DOM renderer supports auto-focus for certain elements).
9807 // Make sure such renderers get scheduled for later work.
9808 if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
9809 markUpdate(workInProgress);
9810 }
9811 workInProgress.stateNode = instance;
9812 }
9813
9814 if (workInProgress.ref !== null) {
9815 // If there is a ref on a host node we need to schedule a callback
9816 markRef$1(workInProgress);
9817 }
9818 }
9819 break;
9820 }
9821 case HostText:
9822 {
9823 var newText = newProps;
9824 if (current && workInProgress.stateNode != null) {
9825 var oldText = current.memoizedProps;
9826 // If we have an alternate, that means this is an update and we need
9827 // to schedule a side-effect to do the updates.
9828 updateHostText$1(current, workInProgress, oldText, newText);
9829 } else {
9830 if (typeof newText !== 'string') {
9831 (function () {
9832 if (!(workInProgress.stateNode !== null)) {
9833 {
9834 throw ReactError('We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.');
9835 }
9836 }
9837 })();
9838 // This can happen when we abort work.
9839 }
9840 var _rootContainerInstance = getRootHostContainer();
9841 var _currentHostContext = getHostContext();
9842 var _wasHydrated = popHydrationState(workInProgress);
9843 if (_wasHydrated) {
9844 if (prepareToHydrateHostTextInstance(workInProgress)) {
9845 markUpdate(workInProgress);
9846 }
9847 } else {
9848 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
9849 }
9850 }
9851 break;
9852 }
9853 case ForwardRef:
9854 break;
9855 case SuspenseComponent:
9856 {
9857 var nextState = workInProgress.memoizedState;
9858 if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
9859 // Something suspended. Re-render with the fallback children.
9860 workInProgress.expirationTime = renderExpirationTime;
9861 // Do not reset the effect list.
9862 return workInProgress;
9863 }
9864
9865 var nextDidTimeout = nextState !== null;
9866 var prevDidTimeout = current !== null && current.memoizedState !== null;
9867
9868 if (current === null) {
9869 // In cases where we didn't find a suitable hydration boundary we never
9870 // downgraded this to a DehydratedSuspenseComponent, but we still need to
9871 // pop the hydration state since we might be inside the insertion tree.
9872 popHydrationState(workInProgress);
9873 } else if (!nextDidTimeout && prevDidTimeout) {
9874 // We just switched from the fallback to the normal children. Delete
9875 // the fallback.
9876 // TODO: Would it be better to store the fallback fragment on
9877 var currentFallbackChild = current.child.sibling;
9878 if (currentFallbackChild !== null) {
9879 // Deletions go at the beginning of the return fiber's effect list
9880 var first = workInProgress.firstEffect;
9881 if (first !== null) {
9882 workInProgress.firstEffect = currentFallbackChild;
9883 currentFallbackChild.nextEffect = first;
9884 } else {
9885 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
9886 currentFallbackChild.nextEffect = null;
9887 }
9888 currentFallbackChild.effectTag = Deletion;
9889 }
9890 }
9891
9892 if (supportsPersistence) {
9893 if (nextDidTimeout) {
9894 // If this boundary just timed out, schedule an effect to attach a
9895 // retry listener to the proimse. This flag is also used to hide the
9896 // primary children.
9897 workInProgress.effectTag |= Update;
9898 }
9899 }
9900 if (supportsMutation) {
9901 if (nextDidTimeout || prevDidTimeout) {
9902 // If this boundary just timed out, schedule an effect to attach a
9903 // retry listener to the proimse. This flag is also used to hide the
9904 // primary children. In mutation mode, we also need the flag to
9905 // *unhide* children that were previously hidden, so check if the
9906 // is currently timed out, too.
9907 workInProgress.effectTag |= Update;
9908 }
9909 }
9910 break;
9911 }
9912 case Fragment:
9913 break;
9914 case Mode$1:
9915 break;
9916 case Profiler:
9917 break;
9918 case HostPortal:
9919 popHostContainer(workInProgress);
9920 updateHostContainer(workInProgress);
9921 break;
9922 case ContextProvider:
9923 // Pop provider fiber
9924 popProvider(workInProgress);
9925 break;
9926 case ContextConsumer:
9927 break;
9928 case MemoComponent:
9929 break;
9930 case IncompleteClassComponent:
9931 {
9932 // Same as class component case. I put it down here so that the tags are
9933 // sequential to ensure this switch is compiled to a jump table.
9934 var _Component = workInProgress.type;
9935 if (isContextProvider(_Component)) {
9936 popContext(workInProgress);
9937 }
9938 break;
9939 }
9940 case DehydratedSuspenseComponent:
9941 {
9942 if (enableSuspenseServerRenderer) {
9943 if (current === null) {
9944 var _wasHydrated2 = popHydrationState(workInProgress);
9945 (function () {
9946 if (!_wasHydrated2) {
9947 {
9948 throw ReactError('A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.');
9949 }
9950 }
9951 })();
9952 skipPastDehydratedSuspenseInstance(workInProgress);
9953 } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
9954 // This boundary did not suspend so it's now hydrated.
9955 // To handle any future suspense cases, we're going to now upgrade it
9956 // to a Suspense component. We detach it from the existing current fiber.
9957 current.alternate = null;
9958 workInProgress.alternate = null;
9959 workInProgress.tag = SuspenseComponent;
9960 workInProgress.memoizedState = null;
9961 workInProgress.stateNode = null;
9962 }
9963 }
9964 break;
9965 }
9966 case EventComponent:
9967 {
9968 if (enableEventAPI) {
9969 popHostContext(workInProgress);
9970 var _rootContainerInstance2 = getRootHostContainer();
9971 var responder = workInProgress.type.responder;
9972 // Update the props on the event component state node
9973 workInProgress.stateNode.props = newProps;
9974
9975 }
9976 break;
9977 }
9978 case EventTarget:
9979 {
9980 if (enableEventAPI) {
9981 popHostContext(workInProgress);
9982 var _type = workInProgress.type.type;
9983 var node = workInProgress.return;
9984 var parentHostInstance = null;
9985 // Traverse up the fiber tree till we find a host component fiber
9986 while (node !== null) {
9987 if (node.tag === HostComponent) {
9988 parentHostInstance = node.stateNode;
9989 break;
9990 }
9991 node = node.return;
9992 }
9993
9994 }
9995 break;
9996 }
9997 default:
9998 (function () {
9999 {
10000 {
10001 throw ReactError('Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
10002 }
10003 }
10004 })();
10005 }
10006
10007 return null;
10008}
10009
10010function shouldCaptureSuspense(workInProgress) {
10011 // In order to capture, the Suspense component must have a fallback prop.
10012 if (workInProgress.memoizedProps.fallback === undefined) {
10013 return false;
10014 }
10015 // If it was the primary children that just suspended, capture and render the
10016 // fallback. Otherwise, don't capture and bubble to the next boundary.
10017 var nextState = workInProgress.memoizedState;
10018 return nextState === null;
10019}
10020
10021// This module is forked in different environments.
10022// By default, return `true` to log errors to the console.
10023// Forks can return `false` if this isn't desirable.
10024function showErrorDialog(capturedError) {
10025 return true;
10026}
10027
10028function logCapturedError(capturedError) {
10029 var logError = showErrorDialog(capturedError);
10030
10031 // Allow injected showErrorDialog() to prevent default console.error logging.
10032 // This enables renderers like ReactNative to better manage redbox behavior.
10033 if (logError === false) {
10034 return;
10035 }
10036
10037 var error = capturedError.error;
10038 {
10039 var componentName = capturedError.componentName,
10040 componentStack = capturedError.componentStack,
10041 errorBoundaryName = capturedError.errorBoundaryName,
10042 errorBoundaryFound = capturedError.errorBoundaryFound,
10043 willRetry = capturedError.willRetry;
10044
10045 // Browsers support silencing uncaught errors by calling
10046 // `preventDefault()` in window `error` handler.
10047 // We record this information as an expando on the error.
10048
10049 if (error != null && error._suppressLogging) {
10050 if (errorBoundaryFound && willRetry) {
10051 // The error is recoverable and was silenced.
10052 // Ignore it and don't print the stack addendum.
10053 // This is handy for testing error boundaries without noise.
10054 return;
10055 }
10056 // The error is fatal. Since the silencing might have
10057 // been accidental, we'll surface it anyway.
10058 // However, the browser would have silenced the original error
10059 // so we'll print it first, and then print the stack addendum.
10060 console.error(error);
10061 // For a more detailed description of this block, see:
10062 // https://github.com/facebook/react/pull/13384
10063 }
10064
10065 var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:';
10066
10067 var errorBoundaryMessage = void 0;
10068 // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
10069 if (errorBoundaryFound && errorBoundaryName) {
10070 if (willRetry) {
10071 errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.');
10072 } else {
10073 errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.';
10074 }
10075 } else {
10076 errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
10077 }
10078 var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage);
10079
10080 // In development, we provide our own message with just the component stack.
10081 // We don't include the original error message and JS stack because the browser
10082 // has already printed it. Even if the application swallows the error, it is still
10083 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
10084 console.error(combinedMessage);
10085 }
10086}
10087
10088var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
10089{
10090 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
10091}
10092
10093var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
10094
10095function logError(boundary, errorInfo) {
10096 var source = errorInfo.source;
10097 var stack = errorInfo.stack;
10098 if (stack === null && source !== null) {
10099 stack = getStackByFiberInDevAndProd(source);
10100 }
10101
10102 var capturedError = {
10103 componentName: source !== null ? getComponentName(source.type) : null,
10104 componentStack: stack !== null ? stack : '',
10105 error: errorInfo.value,
10106 errorBoundary: null,
10107 errorBoundaryName: null,
10108 errorBoundaryFound: false,
10109 willRetry: false
10110 };
10111
10112 if (boundary !== null && boundary.tag === ClassComponent) {
10113 capturedError.errorBoundary = boundary.stateNode;
10114 capturedError.errorBoundaryName = getComponentName(boundary.type);
10115 capturedError.errorBoundaryFound = true;
10116 capturedError.willRetry = true;
10117 }
10118
10119 try {
10120 logCapturedError(capturedError);
10121 } catch (e) {
10122 // This method must not throw, or React internal state will get messed up.
10123 // If console.error is overridden, or logCapturedError() shows a dialog that throws,
10124 // we want to report this error outside of the normal stack as a last resort.
10125 // https://github.com/facebook/react/issues/13188
10126 setTimeout(function () {
10127 throw e;
10128 });
10129 }
10130}
10131
10132var callComponentWillUnmountWithTimer = function (current$$1, instance) {
10133 startPhaseTimer(current$$1, 'componentWillUnmount');
10134 instance.props = current$$1.memoizedProps;
10135 instance.state = current$$1.memoizedState;
10136 instance.componentWillUnmount();
10137 stopPhaseTimer();
10138};
10139
10140// Capture errors so they don't interrupt unmounting.
10141function safelyCallComponentWillUnmount(current$$1, instance) {
10142 {
10143 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
10144 if (hasCaughtError()) {
10145 var unmountError = clearCaughtError();
10146 captureCommitPhaseError$$1(current$$1, unmountError);
10147 }
10148 }
10149}
10150
10151function safelyDetachRef(current$$1) {
10152 var ref = current$$1.ref;
10153 if (ref !== null) {
10154 if (typeof ref === 'function') {
10155 {
10156 invokeGuardedCallback(null, ref, null, null);
10157 if (hasCaughtError()) {
10158 var refError = clearCaughtError();
10159 captureCommitPhaseError$$1(current$$1, refError);
10160 }
10161 }
10162 } else {
10163 ref.current = null;
10164 }
10165 }
10166}
10167
10168function safelyCallDestroy(current$$1, destroy) {
10169 {
10170 invokeGuardedCallback(null, destroy, null);
10171 if (hasCaughtError()) {
10172 var error = clearCaughtError();
10173 captureCommitPhaseError$$1(current$$1, error);
10174 }
10175 }
10176}
10177
10178function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
10179 switch (finishedWork.tag) {
10180 case FunctionComponent:
10181 case ForwardRef:
10182 case SimpleMemoComponent:
10183 {
10184 commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
10185 return;
10186 }
10187 case ClassComponent:
10188 {
10189 if (finishedWork.effectTag & Snapshot) {
10190 if (current$$1 !== null) {
10191 var prevProps = current$$1.memoizedProps;
10192 var prevState = current$$1.memoizedState;
10193 startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
10194 var instance = finishedWork.stateNode;
10195 // We could update instance props and state here,
10196 // but instead we rely on them being set during last render.
10197 // TODO: revisit this when we implement resuming.
10198 {
10199 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
10200 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10201 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10202 }
10203 }
10204 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
10205 {
10206 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
10207 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
10208 didWarnSet.add(finishedWork.type);
10209 warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
10210 }
10211 }
10212 instance.__reactInternalSnapshotBeforeUpdate = snapshot;
10213 stopPhaseTimer();
10214 }
10215 }
10216 return;
10217 }
10218 case HostRoot:
10219 case HostComponent:
10220 case HostText:
10221 case HostPortal:
10222 case IncompleteClassComponent:
10223 // Nothing to do for these component types
10224 return;
10225 default:
10226 {
10227 (function () {
10228 {
10229 {
10230 throw ReactError('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
10231 }
10232 }
10233 })();
10234 }
10235 }
10236}
10237
10238function commitHookEffectList(unmountTag, mountTag, finishedWork) {
10239 var updateQueue = finishedWork.updateQueue;
10240 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
10241 if (lastEffect !== null) {
10242 var firstEffect = lastEffect.next;
10243 var effect = firstEffect;
10244 do {
10245 if ((effect.tag & unmountTag) !== NoEffect$1) {
10246 // Unmount
10247 var destroy = effect.destroy;
10248 effect.destroy = undefined;
10249 if (destroy !== undefined) {
10250 destroy();
10251 }
10252 }
10253 if ((effect.tag & mountTag) !== NoEffect$1) {
10254 // Mount
10255 var create = effect.create;
10256 effect.destroy = create();
10257
10258 {
10259 var _destroy = effect.destroy;
10260 if (_destroy !== undefined && typeof _destroy !== 'function') {
10261 var addendum = void 0;
10262 if (_destroy === null) {
10263 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
10264 } else if (typeof _destroy.then === 'function') {
10265 addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + '}, [someId]); // Or [] if effect doesn\'t need props or state\n\n' + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
10266 } else {
10267 addendum = ' You returned: ' + _destroy;
10268 }
10269 warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
10270 }
10271 }
10272 }
10273 effect = effect.next;
10274 } while (effect !== firstEffect);
10275 }
10276}
10277
10278function commitPassiveHookEffects(finishedWork) {
10279 commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
10280 commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
10281}
10282
10283function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
10284 switch (finishedWork.tag) {
10285 case FunctionComponent:
10286 case ForwardRef:
10287 case SimpleMemoComponent:
10288 {
10289 commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
10290 break;
10291 }
10292 case ClassComponent:
10293 {
10294 var instance = finishedWork.stateNode;
10295 if (finishedWork.effectTag & Update) {
10296 if (current$$1 === null) {
10297 startPhaseTimer(finishedWork, 'componentDidMount');
10298 // We could update instance props and state here,
10299 // but instead we rely on them being set during last render.
10300 // TODO: revisit this when we implement resuming.
10301 {
10302 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
10303 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10304 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10305 }
10306 }
10307 instance.componentDidMount();
10308 stopPhaseTimer();
10309 } else {
10310 var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
10311 var prevState = current$$1.memoizedState;
10312 startPhaseTimer(finishedWork, 'componentDidUpdate');
10313 // We could update instance props and state here,
10314 // but instead we rely on them being set during last render.
10315 // TODO: revisit this when we implement resuming.
10316 {
10317 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
10318 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10319 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10320 }
10321 }
10322 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
10323 stopPhaseTimer();
10324 }
10325 }
10326 var updateQueue = finishedWork.updateQueue;
10327 if (updateQueue !== null) {
10328 {
10329 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
10330 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10331 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
10332 }
10333 }
10334 // We could update instance props and state here,
10335 // but instead we rely on them being set during last render.
10336 // TODO: revisit this when we implement resuming.
10337 commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
10338 }
10339 return;
10340 }
10341 case HostRoot:
10342 {
10343 var _updateQueue = finishedWork.updateQueue;
10344 if (_updateQueue !== null) {
10345 var _instance = null;
10346 if (finishedWork.child !== null) {
10347 switch (finishedWork.child.tag) {
10348 case HostComponent:
10349 _instance = getPublicInstance(finishedWork.child.stateNode);
10350 break;
10351 case ClassComponent:
10352 _instance = finishedWork.child.stateNode;
10353 break;
10354 }
10355 }
10356 commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
10357 }
10358 return;
10359 }
10360 case HostComponent:
10361 {
10362 var _instance2 = finishedWork.stateNode;
10363
10364 // Renderers may schedule work to be done after host components are mounted
10365 // (eg DOM renderer may schedule auto-focus for inputs and form controls).
10366 // These effects should only be committed when components are first mounted,
10367 // aka when there is no current/alternate.
10368 if (current$$1 === null && finishedWork.effectTag & Update) {
10369 var type = finishedWork.type;
10370 var props = finishedWork.memoizedProps;
10371
10372 }
10373
10374 return;
10375 }
10376 case HostText:
10377 {
10378 // We have no life-cycles associated with text.
10379 return;
10380 }
10381 case HostPortal:
10382 {
10383 // We have no life-cycles associated with portals.
10384 return;
10385 }
10386 case Profiler:
10387 {
10388 if (enableProfilerTimer) {
10389 var onRender = finishedWork.memoizedProps.onRender;
10390
10391 if (enableSchedulerTracing) {
10392 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
10393 } else {
10394 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
10395 }
10396 }
10397 return;
10398 }
10399 case SuspenseComponent:
10400 case IncompleteClassComponent:
10401 break;
10402 default:
10403 {
10404 (function () {
10405 {
10406 {
10407 throw ReactError('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
10408 }
10409 }
10410 })();
10411 }
10412 }
10413}
10414
10415function hideOrUnhideAllChildren(finishedWork, isHidden) {
10416 if (supportsMutation) {
10417 // We only have the top Fiber that was inserted but we need to recurse down its
10418 var node = finishedWork;
10419 while (true) {
10420 if (node.tag === HostComponent) {
10421 var instance = node.stateNode;
10422 if (isHidden) {
10423 hideInstance(instance);
10424 } else {
10425 unhideInstance(node.stateNode, node.memoizedProps);
10426 }
10427 } else if (node.tag === HostText) {
10428 var _instance3 = node.stateNode;
10429 if (isHidden) {
10430
10431 } else {
10432 unhideTextInstance(_instance3, node.memoizedProps);
10433 }
10434 } else if (node.tag === SuspenseComponent && node.memoizedState !== null) {
10435 // Found a nested Suspense component that timed out. Skip over the
10436 var fallbackChildFragment = node.child.sibling;
10437 fallbackChildFragment.return = node;
10438 node = fallbackChildFragment;
10439 continue;
10440 } else if (node.child !== null) {
10441 node.child.return = node;
10442 node = node.child;
10443 continue;
10444 }
10445 if (node === finishedWork) {
10446 return;
10447 }
10448 while (node.sibling === null) {
10449 if (node.return === null || node.return === finishedWork) {
10450 return;
10451 }
10452 node = node.return;
10453 }
10454 node.sibling.return = node.return;
10455 node = node.sibling;
10456 }
10457 }
10458}
10459
10460function commitAttachRef(finishedWork) {
10461 var ref = finishedWork.ref;
10462 if (ref !== null) {
10463 var instance = finishedWork.stateNode;
10464 var instanceToUse = void 0;
10465 switch (finishedWork.tag) {
10466 case HostComponent:
10467 instanceToUse = getPublicInstance(instance);
10468 break;
10469 default:
10470 instanceToUse = instance;
10471 }
10472 if (typeof ref === 'function') {
10473 ref(instanceToUse);
10474 } else {
10475 {
10476 if (!ref.hasOwnProperty('current')) {
10477 warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
10478 }
10479 }
10480
10481 ref.current = instanceToUse;
10482 }
10483 }
10484}
10485
10486function commitDetachRef(current$$1) {
10487 var currentRef = current$$1.ref;
10488 if (currentRef !== null) {
10489 if (typeof currentRef === 'function') {
10490 currentRef(null);
10491 } else {
10492 currentRef.current = null;
10493 }
10494 }
10495}
10496
10497// User-originating errors (lifecycles and refs) should not interrupt
10498// deletion, so don't let them throw. Host-originating errors should
10499// interrupt deletion, so it's okay
10500function commitUnmount(current$$1) {
10501 onCommitUnmount(current$$1);
10502
10503 switch (current$$1.tag) {
10504 case FunctionComponent:
10505 case ForwardRef:
10506 case MemoComponent:
10507 case SimpleMemoComponent:
10508 {
10509 var updateQueue = current$$1.updateQueue;
10510 if (updateQueue !== null) {
10511 var lastEffect = updateQueue.lastEffect;
10512 if (lastEffect !== null) {
10513 var firstEffect = lastEffect.next;
10514 var effect = firstEffect;
10515 do {
10516 var destroy = effect.destroy;
10517 if (destroy !== undefined) {
10518 safelyCallDestroy(current$$1, destroy);
10519 }
10520 effect = effect.next;
10521 } while (effect !== firstEffect);
10522 }
10523 }
10524 break;
10525 }
10526 case ClassComponent:
10527 {
10528 safelyDetachRef(current$$1);
10529 var instance = current$$1.stateNode;
10530 if (typeof instance.componentWillUnmount === 'function') {
10531 safelyCallComponentWillUnmount(current$$1, instance);
10532 }
10533 return;
10534 }
10535 case HostComponent:
10536 {
10537 safelyDetachRef(current$$1);
10538 return;
10539 }
10540 case HostPortal:
10541 {
10542 // TODO: this is recursive.
10543 // We are also not using this parent because
10544 // the portal will get pushed immediately.
10545 if (supportsMutation) {
10546 unmountHostComponents(current$$1);
10547 } else if (supportsPersistence) {
10548 emptyPortalContainer(current$$1);
10549 }
10550 return;
10551 }
10552 }
10553}
10554
10555function commitNestedUnmounts(root) {
10556 // While we're inside a removed host node we don't want to call
10557 // removeChild on the inner nodes because they're removed by the top
10558 // call anyway. We also want to call componentWillUnmount on all
10559 // composites before this host node is removed from the tree. Therefore
10560 var node = root;
10561 while (true) {
10562 commitUnmount(node);
10563 // Visit children because they may contain more composite or host nodes.
10564 // Skip portals because commitUnmount() currently visits them recursively.
10565 if (node.child !== null && (
10566 // If we use mutation we drill down into portals using commitUnmount above.
10567 // If we don't use mutation we drill down into portals here instead.
10568 !supportsMutation || node.tag !== HostPortal)) {
10569 node.child.return = node;
10570 node = node.child;
10571 continue;
10572 }
10573 if (node === root) {
10574 return;
10575 }
10576 while (node.sibling === null) {
10577 if (node.return === null || node.return === root) {
10578 return;
10579 }
10580 node = node.return;
10581 }
10582 node.sibling.return = node.return;
10583 node = node.sibling;
10584 }
10585}
10586
10587function detachFiber(current$$1) {
10588 // Cut off the return pointers to disconnect it from the tree. Ideally, we
10589 // should clear the child pointer of the parent alternate to let this
10590 // get GC:ed but we don't know which for sure which parent is the current
10591 // one so we'll settle for GC:ing the subtree of this child. This child
10592 // itself will be GC:ed when the parent updates the next time.
10593 current$$1.return = null;
10594 current$$1.child = null;
10595 current$$1.memoizedState = null;
10596 current$$1.updateQueue = null;
10597 var alternate = current$$1.alternate;
10598 if (alternate !== null) {
10599 alternate.return = null;
10600 alternate.child = null;
10601 alternate.memoizedState = null;
10602 alternate.updateQueue = null;
10603 }
10604}
10605
10606function emptyPortalContainer(current$$1) {
10607 if (!supportsPersistence) {
10608 return;
10609 }
10610
10611 var portal = current$$1.stateNode;
10612 var containerInfo = portal.containerInfo;
10613
10614 var emptyChildSet = createContainerChildSet(containerInfo);
10615 replaceContainerChildren(containerInfo, emptyChildSet);
10616}
10617
10618function commitContainer(finishedWork) {
10619 if (!supportsPersistence) {
10620 return;
10621 }
10622
10623 switch (finishedWork.tag) {
10624 case ClassComponent:
10625 case HostComponent:
10626 case HostText:
10627 {
10628 return;
10629 }
10630 case HostRoot:
10631 case HostPortal:
10632 {
10633 var portalOrRoot = finishedWork.stateNode;
10634 var containerInfo = portalOrRoot.containerInfo,
10635 _pendingChildren = portalOrRoot.pendingChildren;
10636
10637 replaceContainerChildren(containerInfo, _pendingChildren);
10638 return;
10639 }
10640 default:
10641 {
10642 (function () {
10643 {
10644 {
10645 throw ReactError('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
10646 }
10647 }
10648 })();
10649 }
10650 }
10651}
10652
10653function getHostParentFiber(fiber) {
10654 var parent = fiber.return;
10655 while (parent !== null) {
10656 if (isHostParent(parent)) {
10657 return parent;
10658 }
10659 parent = parent.return;
10660 }
10661 (function () {
10662 {
10663 {
10664 throw ReactError('Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.');
10665 }
10666 }
10667 })();
10668}
10669
10670function isHostParent(fiber) {
10671 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
10672}
10673
10674function getHostSibling(fiber) {
10675 // We're going to search forward into the tree until we find a sibling host
10676 // node. Unfortunately, if multiple insertions are done in a row we have to
10677 // search past them. This leads to exponential search for the next sibling.
10678 var node = fiber;
10679 siblings: while (true) {
10680 // If we didn't find anything, let's try the next sibling.
10681 while (node.sibling === null) {
10682 if (node.return === null || isHostParent(node.return)) {
10683 // If we pop out of the root or hit the parent the fiber we are the
10684 // last sibling.
10685 return null;
10686 }
10687 node = node.return;
10688 }
10689 node.sibling.return = node.return;
10690 node = node.sibling;
10691 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
10692 // If it is not host node and, we might have a host node inside it.
10693 // Try to search down until we find one.
10694 if (node.effectTag & Placement) {
10695 // If we don't have a child, try the siblings instead.
10696 continue siblings;
10697 }
10698 // If we don't have a child, try the siblings instead.
10699 // We also skip portals because they are not part of this host tree.
10700 if (node.child === null || node.tag === HostPortal) {
10701 continue siblings;
10702 } else {
10703 node.child.return = node;
10704 node = node.child;
10705 }
10706 }
10707 // Check if this host node is stable or about to be placed.
10708 if (!(node.effectTag & Placement)) {
10709 // Found it!
10710 return node.stateNode;
10711 }
10712 }
10713}
10714
10715function commitPlacement(finishedWork) {
10716 if (!supportsMutation) {
10717 return;
10718 }
10719
10720 // Recursively insert all host nodes into the parent.
10721 var parentFiber = getHostParentFiber(finishedWork);
10722
10723 // Note: these two variables *must* always be updated together.
10724 var parent = void 0;
10725 var isContainer = void 0;
10726
10727 switch (parentFiber.tag) {
10728 case HostComponent:
10729 parent = parentFiber.stateNode;
10730 isContainer = false;
10731 break;
10732 case HostRoot:
10733 parent = parentFiber.stateNode.containerInfo;
10734 isContainer = true;
10735 break;
10736 case HostPortal:
10737 parent = parentFiber.stateNode.containerInfo;
10738 isContainer = true;
10739 break;
10740 default:
10741 (function () {
10742 {
10743 {
10744 throw ReactError('Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
10745 }
10746 }
10747 })();
10748 }
10749 if (parentFiber.effectTag & ContentReset) {
10750 // Reset the text content of the parent before doing any insertions
10751 parentFiber.effectTag &= ~ContentReset;
10752 }
10753
10754 var before = getHostSibling(finishedWork);
10755 // We only have the top Fiber that was inserted but we need to recurse down its
10756 // children to find all the terminal nodes.
10757 var node = finishedWork;
10758 while (true) {
10759 if (node.tag === HostComponent || node.tag === HostText) {
10760 if (before) {
10761 if (isContainer) {
10762 insertInContainerBefore(parent, node.stateNode, before);
10763 } else {
10764 insertBefore(parent, node.stateNode, before);
10765 }
10766 } else {
10767 if (isContainer) {
10768 appendChildToContainer(parent, node.stateNode);
10769 } else {
10770 appendChild(parent, node.stateNode);
10771 }
10772 }
10773 } else if (node.tag === HostPortal) {
10774 // If the insertion itself is a portal, then we don't want to traverse
10775 // down its children. Instead, we'll get insertions from each child in
10776 // the portal directly.
10777 } else if (node.child !== null) {
10778 node.child.return = node;
10779 node = node.child;
10780 continue;
10781 }
10782 if (node === finishedWork) {
10783 return;
10784 }
10785 while (node.sibling === null) {
10786 if (node.return === null || node.return === finishedWork) {
10787 return;
10788 }
10789 node = node.return;
10790 }
10791 node.sibling.return = node.return;
10792 node = node.sibling;
10793 }
10794}
10795
10796function unmountHostComponents(current$$1) {
10797 // We only have the top Fiber that was deleted but we need to recurse down its
10798 var node = current$$1;
10799
10800 // Each iteration, currentParent is populated with node's host parent if not
10801 // currentParentIsValid.
10802 var currentParentIsValid = false;
10803
10804 // Note: these two variables *must* always be updated together.
10805 var currentParent = void 0;
10806 var currentParentIsContainer = void 0;
10807
10808 while (true) {
10809 if (!currentParentIsValid) {
10810 var parent = node.return;
10811 findParent: while (true) {
10812 (function () {
10813 if (!(parent !== null)) {
10814 {
10815 throw ReactError('Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.');
10816 }
10817 }
10818 })();
10819 switch (parent.tag) {
10820 case HostComponent:
10821 currentParent = parent.stateNode;
10822 currentParentIsContainer = false;
10823 break findParent;
10824 case HostRoot:
10825 currentParent = parent.stateNode.containerInfo;
10826 currentParentIsContainer = true;
10827 break findParent;
10828 case HostPortal:
10829 currentParent = parent.stateNode.containerInfo;
10830 currentParentIsContainer = true;
10831 break findParent;
10832 }
10833 parent = parent.return;
10834 }
10835 currentParentIsValid = true;
10836 }
10837
10838 if (node.tag === HostComponent || node.tag === HostText) {
10839 commitNestedUnmounts(node);
10840 // After all the children have unmounted, it is now safe to remove the
10841 // node from the tree.
10842 if (currentParentIsContainer) {
10843 removeChildFromContainer(currentParent, node.stateNode);
10844 } else {
10845 removeChild(currentParent, node.stateNode);
10846 }
10847 // Don't visit children because we already visited them.
10848 } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
10849 // Delete the dehydrated suspense boundary and all of its content.
10850 if (currentParentIsContainer) {
10851 clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
10852 } else {
10853 clearSuspenseBoundary(currentParent, node.stateNode);
10854 }
10855 } else if (node.tag === HostPortal) {
10856 if (node.child !== null) {
10857 // When we go into a portal, it becomes the parent to remove from.
10858 // We will reassign it back when we pop the portal on the way up.
10859 currentParent = node.stateNode.containerInfo;
10860 currentParentIsContainer = true;
10861 // Visit children because portals might contain host components.
10862 node.child.return = node;
10863 node = node.child;
10864 continue;
10865 }
10866 } else {
10867 commitUnmount(node);
10868 // Visit children because we may find more host components below.
10869 if (node.child !== null) {
10870 node.child.return = node;
10871 node = node.child;
10872 continue;
10873 }
10874 }
10875 if (node === current$$1) {
10876 return;
10877 }
10878 while (node.sibling === null) {
10879 if (node.return === null || node.return === current$$1) {
10880 return;
10881 }
10882 node = node.return;
10883 if (node.tag === HostPortal) {
10884 // When we go out of the portal, we need to restore the parent.
10885 // Since we don't keep a stack of them, we will search for it.
10886 currentParentIsValid = false;
10887 }
10888 }
10889 node.sibling.return = node.return;
10890 node = node.sibling;
10891 }
10892}
10893
10894function commitDeletion(current$$1) {
10895 if (supportsMutation) {
10896 // Recursively delete all host nodes from the parent.
10897 // Detach refs and call componentWillUnmount() on the whole subtree.
10898 unmountHostComponents(current$$1);
10899 } else {
10900 // Detach refs and call componentWillUnmount() on the whole subtree.
10901 commitNestedUnmounts(current$$1);
10902 }
10903 detachFiber(current$$1);
10904}
10905
10906function commitWork(current$$1, finishedWork) {
10907 if (!supportsMutation) {
10908 switch (finishedWork.tag) {
10909 case FunctionComponent:
10910 case ForwardRef:
10911 case MemoComponent:
10912 case SimpleMemoComponent:
10913 {
10914 // Note: We currently never use MountMutation, but useLayout uses
10915 // UnmountMutation.
10916 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
10917 return;
10918 }
10919 case Profiler:
10920 {
10921 return;
10922 }
10923 case SuspenseComponent:
10924 {
10925 commitSuspenseComponent(finishedWork);
10926 return;
10927 }
10928 }
10929
10930 commitContainer(finishedWork);
10931 return;
10932 }
10933
10934 switch (finishedWork.tag) {
10935 case FunctionComponent:
10936 case ForwardRef:
10937 case MemoComponent:
10938 case SimpleMemoComponent:
10939 {
10940 // Note: We currently never use MountMutation, but useLayout uses
10941 // UnmountMutation.
10942 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
10943 return;
10944 }
10945 case ClassComponent:
10946 {
10947 return;
10948 }
10949 case HostComponent:
10950 {
10951 var instance = finishedWork.stateNode;
10952 if (instance != null) {
10953 // Commit the work prepared earlier.
10954 var newProps = finishedWork.memoizedProps;
10955 // For hydration we reuse the update path but we treat the oldProps
10956 // as the newProps. The updatePayload will contain the real change in
10957 // this case.
10958 var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
10959 var type = finishedWork.type;
10960 // TODO: Type the updateQueue to be specific to host components.
10961 var updatePayload = finishedWork.updateQueue;
10962 finishedWork.updateQueue = null;
10963 if (updatePayload !== null) {
10964 commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
10965 }
10966 }
10967 return;
10968 }
10969 case HostText:
10970 {
10971 (function () {
10972 if (!(finishedWork.stateNode !== null)) {
10973 {
10974 throw ReactError('This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.');
10975 }
10976 }
10977 })();
10978 var textInstance = finishedWork.stateNode;
10979 var newText = finishedWork.memoizedProps;
10980 // For hydration we reuse the update path but we treat the oldProps
10981 // as the newProps. The updatePayload will contain the real change in
10982 // this case.
10983 var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
10984 return;
10985 }
10986 case HostRoot:
10987 {
10988 return;
10989 }
10990 case Profiler:
10991 {
10992 return;
10993 }
10994 case SuspenseComponent:
10995 {
10996 commitSuspenseComponent(finishedWork);
10997 return;
10998 }
10999 case IncompleteClassComponent:
11000 {
11001 return;
11002 }
11003 default:
11004 {
11005 (function () {
11006 {
11007 {
11008 throw ReactError('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
11009 }
11010 }
11011 })();
11012 }
11013 }
11014}
11015
11016function commitSuspenseComponent(finishedWork) {
11017 var newState = finishedWork.memoizedState;
11018
11019 var newDidTimeout = void 0;
11020 var primaryChildParent = finishedWork;
11021 if (newState === null) {
11022 newDidTimeout = false;
11023 } else {
11024 newDidTimeout = true;
11025 primaryChildParent = finishedWork.child;
11026 if (newState.timedOutAt === NoWork) {
11027 // If the children had not already timed out, record the time.
11028 // This is used to compute the elapsed time during subsequent
11029 // attempts to render the children.
11030 newState.timedOutAt = requestCurrentTime$$1();
11031 }
11032 }
11033
11034 if (supportsMutation && primaryChildParent !== null) {
11035 hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
11036 }
11037
11038 // If this boundary just timed out, then it will have a set of thenables.
11039 // For each thenable, attach a listener so that when it resolves, React
11040 // attempts to re-render the boundary in the primary (pre-timeout) state.
11041 var thenables = finishedWork.updateQueue;
11042 if (thenables !== null) {
11043 finishedWork.updateQueue = null;
11044 var retryCache = finishedWork.stateNode;
11045 if (retryCache === null) {
11046 retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
11047 }
11048 thenables.forEach(function (thenable) {
11049 // Memoize using the boundary fiber to prevent redundant listeners.
11050 var retry = resolveRetryThenable$$1.bind(null, finishedWork, thenable);
11051 if (enableSchedulerTracing) {
11052 retry = tracing.unstable_wrap(retry);
11053 }
11054 if (!retryCache.has(thenable)) {
11055 retryCache.add(thenable);
11056 thenable.then(retry, retry);
11057 }
11058 });
11059 }
11060}
11061
11062function commitResetTextContent(current$$1) {
11063 if (!supportsMutation) {
11064 return;
11065 }
11066 resetTextContent(current$$1.stateNode);
11067}
11068
11069var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
11070var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
11071
11072function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
11073 var update = createUpdate(expirationTime);
11074 // Unmount the root by rendering null.
11075 update.tag = CaptureUpdate;
11076 // Caution: React DevTools currently depends on this property
11077 // being called "element".
11078 update.payload = { element: null };
11079 var error = errorInfo.value;
11080 update.callback = function () {
11081 onUncaughtError$$1(error);
11082 logError(fiber, errorInfo);
11083 };
11084 return update;
11085}
11086
11087function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
11088 var update = createUpdate(expirationTime);
11089 update.tag = CaptureUpdate;
11090 var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
11091 if (typeof getDerivedStateFromError === 'function') {
11092 var error = errorInfo.value;
11093 update.payload = function () {
11094 return getDerivedStateFromError(error);
11095 };
11096 }
11097
11098 var inst = fiber.stateNode;
11099 if (inst !== null && typeof inst.componentDidCatch === 'function') {
11100 update.callback = function callback() {
11101 if (typeof getDerivedStateFromError !== 'function') {
11102 // To preserve the preexisting retry behavior of error boundaries,
11103 // we keep track of which ones already failed during this batch.
11104 // This gets reset before we yield back to the browser.
11105 // TODO: Warn in strict mode if getDerivedStateFromError is
11106 // not defined.
11107 markLegacyErrorBoundaryAsFailed$$1(this);
11108 }
11109 var error = errorInfo.value;
11110 var stack = errorInfo.stack;
11111 logError(fiber, errorInfo);
11112 this.componentDidCatch(error, {
11113 componentStack: stack !== null ? stack : ''
11114 });
11115 {
11116 if (typeof getDerivedStateFromError !== 'function') {
11117 // If componentDidCatch is the only error boundary method defined,
11118 // then it needs to call setState to recover from errors.
11119 // If no state update is scheduled then the boundary will swallow the error.
11120 !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown') : void 0;
11121 }
11122 }
11123 };
11124 }
11125 return update;
11126}
11127
11128function attachPingListener(root, renderExpirationTime, thenable) {
11129 // Attach a listener to the promise to "ping" the root and retry. But
11130 // only if one does not already exist for the current render expiration
11131 // time (which acts like a "thread ID" here).
11132 var pingCache = root.pingCache;
11133 var threadIDs = void 0;
11134 if (pingCache === null) {
11135 pingCache = root.pingCache = new PossiblyWeakMap();
11136 threadIDs = new Set();
11137 pingCache.set(thenable, threadIDs);
11138 } else {
11139 threadIDs = pingCache.get(thenable);
11140 if (threadIDs === undefined) {
11141 threadIDs = new Set();
11142 pingCache.set(thenable, threadIDs);
11143 }
11144 }
11145 if (!threadIDs.has(renderExpirationTime)) {
11146 // Memoize using the thread ID to prevent redundant listeners.
11147 threadIDs.add(renderExpirationTime);
11148 var ping = pingSuspendedRoot$$1.bind(null, root, thenable, renderExpirationTime);
11149 if (enableSchedulerTracing) {
11150 ping = tracing.unstable_wrap(ping);
11151 }
11152 thenable.then(ping, ping);
11153 }
11154}
11155
11156function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
11157 // The source fiber did not complete.
11158 sourceFiber.effectTag |= Incomplete;
11159 // Its effect list is no longer valid.
11160 sourceFiber.firstEffect = sourceFiber.lastEffect = null;
11161
11162 if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
11163 // This is a thenable.
11164 var thenable = value;
11165
11166 // Find the earliest timeout threshold of all the placeholders in the
11167 // ancestor path. We could avoid this traversal by storing the thresholds on
11168 // the stack, but we choose not to because we only hit this path if we're
11169 // IO-bound (i.e. if something suspends). Whereas the stack is used even in
11170 // the non-IO- bound case.
11171 var _workInProgress = returnFiber;
11172 var earliestTimeoutMs = -1;
11173 var startTimeMs = -1;
11174 do {
11175 if (_workInProgress.tag === SuspenseComponent) {
11176 var current$$1 = _workInProgress.alternate;
11177 if (current$$1 !== null) {
11178 var currentState = current$$1.memoizedState;
11179 if (currentState !== null) {
11180 // Reached a boundary that already timed out. Do not search
11181 // any further.
11182 var timedOutAt = currentState.timedOutAt;
11183 startTimeMs = expirationTimeToMs(timedOutAt);
11184 // Do not search any further.
11185 break;
11186 }
11187 }
11188 var defaultSuspenseTimeout = 150;
11189 if (earliestTimeoutMs === -1 || defaultSuspenseTimeout < earliestTimeoutMs) {
11190 earliestTimeoutMs = defaultSuspenseTimeout;
11191 }
11192 }
11193 // If there is a DehydratedSuspenseComponent we don't have to do anything because
11194 // if something suspends inside it, we will simply leave that as dehydrated. It
11195 // will never timeout.
11196 _workInProgress = _workInProgress.return;
11197 } while (_workInProgress !== null);
11198
11199 // Schedule the nearest Suspense to re-render the timed out view.
11200 _workInProgress = returnFiber;
11201 do {
11202 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress)) {
11203 // Found the nearest boundary.
11204
11205 // Stash the promise on the boundary fiber. If the boundary times out, we'll
11206 var thenables = _workInProgress.updateQueue;
11207 if (thenables === null) {
11208 var updateQueue = new Set();
11209 updateQueue.add(thenable);
11210 _workInProgress.updateQueue = updateQueue;
11211 } else {
11212 thenables.add(thenable);
11213 }
11214
11215 // If the boundary is outside of concurrent mode, we should *not*
11216 // suspend the commit. Pretend as if the suspended component rendered
11217 // null and keep rendering. In the commit phase, we'll schedule a
11218 // subsequent synchronous update to re-render the Suspense.
11219 //
11220 // Note: It doesn't matter whether the component that suspended was
11221 // inside a concurrent mode tree. If the Suspense is outside of it, we
11222 // should *not* suspend the commit.
11223 if ((_workInProgress.mode & ConcurrentMode) === NoEffect) {
11224 _workInProgress.effectTag |= DidCapture;
11225
11226 // We're going to commit this fiber even though it didn't complete.
11227 // But we shouldn't call any lifecycle methods or callbacks. Remove
11228 // all lifecycle effect tags.
11229 sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
11230
11231 if (sourceFiber.tag === ClassComponent) {
11232 var currentSourceFiber = sourceFiber.alternate;
11233 if (currentSourceFiber === null) {
11234 // This is a new mount. Change the tag so it's not mistaken for a
11235 // completed class component. For example, we should not call
11236 // componentWillUnmount if it is deleted.
11237 sourceFiber.tag = IncompleteClassComponent;
11238 } else {
11239 // When we try rendering again, we should not reuse the current fiber,
11240 // since it's known to be in an inconsistent state. Use a force updte to
11241 // prevent a bail out.
11242 var update = createUpdate(Sync);
11243 update.tag = ForceUpdate;
11244 enqueueUpdate(sourceFiber, update);
11245 }
11246 }
11247
11248 // The source fiber did not complete. Mark it with Sync priority to
11249 // indicate that it still has pending work.
11250 sourceFiber.expirationTime = Sync;
11251
11252 // Exit without suspending.
11253 return;
11254 }
11255
11256 // Confirmed that the boundary is in a concurrent mode tree. Continue
11257 // with the normal suspend path.
11258
11259 attachPingListener(root, renderExpirationTime, thenable);
11260
11261 var absoluteTimeoutMs = void 0;
11262 if (earliestTimeoutMs === -1) {
11263 // If no explicit threshold is given, default to an arbitrarily large
11264 // value. The actual size doesn't matter because the threshold for the
11265 // whole tree will be clamped to the expiration time.
11266 absoluteTimeoutMs = maxSigned31BitInt;
11267 } else {
11268 if (startTimeMs === -1) {
11269 // This suspend happened outside of any already timed-out
11270 // placeholders. We don't know exactly when the update was
11271 // scheduled, but we can infer an approximate start time based on
11272 // the expiration time and the priority.
11273 startTimeMs = inferStartTimeFromExpirationTime$$1(root, renderExpirationTime);
11274 }
11275 absoluteTimeoutMs = startTimeMs + earliestTimeoutMs;
11276 }
11277
11278 // Mark the earliest timeout in the suspended fiber's ancestor path.
11279 // After completing the root, we'll take the largest of all the
11280 // suspended fiber's timeouts and use it to compute a timeout for the
11281 // whole tree.
11282 renderDidSuspend$$1(root, absoluteTimeoutMs, renderExpirationTime);
11283
11284 _workInProgress.effectTag |= ShouldCapture;
11285 _workInProgress.expirationTime = renderExpirationTime;
11286 return;
11287 } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
11288 attachPingListener(root, renderExpirationTime, thenable);
11289
11290 // Since we already have a current fiber, we can eagerly add a retry listener.
11291 var retryCache = _workInProgress.memoizedState;
11292 if (retryCache === null) {
11293 retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
11294 var _current = _workInProgress.alternate;
11295 (function () {
11296 if (!_current) {
11297 {
11298 throw ReactError('A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.');
11299 }
11300 }
11301 })();
11302 _current.memoizedState = retryCache;
11303 }
11304 // Memoize using the boundary fiber to prevent redundant listeners.
11305 if (!retryCache.has(thenable)) {
11306 retryCache.add(thenable);
11307 var retry = resolveRetryThenable$$1.bind(null, _workInProgress, thenable);
11308 if (enableSchedulerTracing) {
11309 retry = tracing.unstable_wrap(retry);
11310 }
11311 thenable.then(retry, retry);
11312 }
11313 _workInProgress.effectTag |= ShouldCapture;
11314 _workInProgress.expirationTime = renderExpirationTime;
11315 return;
11316 }
11317 // This boundary already captured during this render. Continue to the next
11318 // boundary.
11319 _workInProgress = _workInProgress.return;
11320 } while (_workInProgress !== null);
11321 // No boundary was found. Fallthrough to error mode.
11322 // TODO: Use invariant so the message is stripped in prod?
11323 value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber));
11324 }
11325
11326 // We didn't find a boundary that could handle this type of exception. Start
11327 // over and traverse parent path again, this time treating the exception
11328 // as an error.
11329 renderDidError$$1();
11330 value = createCapturedValue(value, sourceFiber);
11331 var workInProgress = returnFiber;
11332 do {
11333 switch (workInProgress.tag) {
11334 case HostRoot:
11335 {
11336 var _errorInfo = value;
11337 workInProgress.effectTag |= ShouldCapture;
11338 workInProgress.expirationTime = renderExpirationTime;
11339 var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
11340 enqueueCapturedUpdate(workInProgress, _update);
11341 return;
11342 }
11343 case ClassComponent:
11344 // Capture and retry
11345 var errorInfo = value;
11346 var ctor = workInProgress.type;
11347 var instance = workInProgress.stateNode;
11348 if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary$$1(instance))) {
11349 workInProgress.effectTag |= ShouldCapture;
11350 workInProgress.expirationTime = renderExpirationTime;
11351 // Schedule the error boundary to re-render using updated state
11352 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
11353 enqueueCapturedUpdate(workInProgress, _update2);
11354 return;
11355 }
11356 break;
11357 default:
11358 break;
11359 }
11360 workInProgress = workInProgress.return;
11361 } while (workInProgress !== null);
11362}
11363
11364function unwindWork(workInProgress, renderExpirationTime) {
11365 switch (workInProgress.tag) {
11366 case ClassComponent:
11367 {
11368 var Component = workInProgress.type;
11369 if (isContextProvider(Component)) {
11370 popContext(workInProgress);
11371 }
11372 var effectTag = workInProgress.effectTag;
11373 if (effectTag & ShouldCapture) {
11374 workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
11375 return workInProgress;
11376 }
11377 return null;
11378 }
11379 case HostRoot:
11380 {
11381 popHostContainer(workInProgress);
11382 popTopLevelContextObject(workInProgress);
11383 var _effectTag = workInProgress.effectTag;
11384 (function () {
11385 if (!((_effectTag & DidCapture) === NoEffect)) {
11386 {
11387 throw ReactError('The root failed to unmount after an error. This is likely a bug in React. Please file an issue.');
11388 }
11389 }
11390 })();
11391 workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
11392 return workInProgress;
11393 }
11394 case HostComponent:
11395 {
11396 // TODO: popHydrationState
11397 popHostContext(workInProgress);
11398 return null;
11399 }
11400 case SuspenseComponent:
11401 {
11402 var _effectTag2 = workInProgress.effectTag;
11403 if (_effectTag2 & ShouldCapture) {
11404 workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
11405 // Captured a suspense effect. Re-render the boundary.
11406 return workInProgress;
11407 }
11408 return null;
11409 }
11410 case DehydratedSuspenseComponent:
11411 {
11412 if (enableSuspenseServerRenderer) {
11413 // TODO: popHydrationState
11414 var _effectTag3 = workInProgress.effectTag;
11415 if (_effectTag3 & ShouldCapture) {
11416 workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
11417 // Captured a suspense effect. Re-render the boundary.
11418 return workInProgress;
11419 }
11420 }
11421 return null;
11422 }
11423 case HostPortal:
11424 popHostContainer(workInProgress);
11425 return null;
11426 case ContextProvider:
11427 popProvider(workInProgress);
11428 return null;
11429 case EventComponent:
11430 case EventTarget:
11431 if (enableEventAPI) {
11432 popHostContext(workInProgress);
11433 }
11434 return null;
11435 default:
11436 return null;
11437 }
11438}
11439
11440function unwindInterruptedWork(interruptedWork) {
11441 switch (interruptedWork.tag) {
11442 case ClassComponent:
11443 {
11444 var childContextTypes = interruptedWork.type.childContextTypes;
11445 if (childContextTypes !== null && childContextTypes !== undefined) {
11446 popContext(interruptedWork);
11447 }
11448 break;
11449 }
11450 case HostRoot:
11451 {
11452 popHostContainer(interruptedWork);
11453 popTopLevelContextObject(interruptedWork);
11454 break;
11455 }
11456 case HostComponent:
11457 {
11458 popHostContext(interruptedWork);
11459 break;
11460 }
11461 case HostPortal:
11462 popHostContainer(interruptedWork);
11463 break;
11464 case ContextProvider:
11465 popProvider(interruptedWork);
11466 break;
11467 default:
11468 break;
11469 }
11470}
11471
11472// Intentionally not named imports because Rollup would use dynamic dispatch for
11473// CommonJS interop named imports.
11474// Intentionally not named imports because Rollup would use dynamic dispatch for
11475// CommonJS interop named imports.
11476var scheduleCallback$1 = Scheduler.unstable_scheduleCallback;
11477var cancelCallback$1 = Scheduler.unstable_cancelCallback;
11478var shouldYield$2 = Scheduler.unstable_shouldYield;
11479var now$2 = Scheduler.unstable_now;
11480var getCurrentPriorityLevel$1 = Scheduler.unstable_getCurrentPriorityLevel;
11481var NormalPriority$1 = Scheduler.unstable_NormalPriority;
11482var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
11483var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
11484var ReactShouldWarnActingUpdates = ReactSharedInternals.ReactShouldWarnActingUpdates;
11485
11486
11487var didWarnAboutStateTransition = void 0;
11488var didWarnSetStateChildContext = void 0;
11489var warnAboutUpdateOnUnmounted = void 0;
11490var warnAboutInvalidUpdates = void 0;
11491
11492if (enableSchedulerTracing) {
11493 // Provide explicit error message when production+profiling bundle of e.g. react-dom
11494 // is used with production (non-profiling) bundle of scheduler/tracing
11495 (function () {
11496 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
11497 {
11498 throw ReactError('It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling');
11499 }
11500 }
11501 })();
11502}
11503
11504{
11505 didWarnAboutStateTransition = false;
11506 didWarnSetStateChildContext = false;
11507 var didWarnStateUpdateForUnmountedComponent = {};
11508
11509 warnAboutUpdateOnUnmounted = function (fiber, isClass) {
11510 // We show the whole stack but dedupe on the top component's name because
11511 // the problematic code almost always lies inside that component.
11512 var componentName = getComponentName(fiber.type) || 'ReactComponent';
11513 if (didWarnStateUpdateForUnmountedComponent[componentName]) {
11514 return;
11515 }
11516 warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', isClass ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
11517 didWarnStateUpdateForUnmountedComponent[componentName] = true;
11518 };
11519
11520 warnAboutInvalidUpdates = function (instance) {
11521 switch (phase) {
11522 case 'getChildContext':
11523 if (didWarnSetStateChildContext) {
11524 return;
11525 }
11526 warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
11527 didWarnSetStateChildContext = true;
11528 break;
11529 case 'render':
11530 if (didWarnAboutStateTransition) {
11531 return;
11532 }
11533 warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as within ' + '`render`). Render methods should be a pure function of props and state.');
11534 didWarnAboutStateTransition = true;
11535 break;
11536 }
11537 };
11538}
11539
11540// Represents the expiration time that incoming updates should use. (If this
11541// is NoWork, use the default strategy: async updates in async mode, sync
11542// updates in sync mode.)
11543var expirationContext = NoWork;
11544
11545var isWorking = false;
11546
11547// The next work in progress fiber that we're currently working on.
11548var nextUnitOfWork = null;
11549var nextRoot = null;
11550// The time at which we're currently rendering work.
11551var nextRenderExpirationTime = NoWork;
11552var nextLatestAbsoluteTimeoutMs = -1;
11553var nextRenderDidError = false;
11554
11555// The next fiber with an effect that we're currently committing.
11556var nextEffect = null;
11557
11558var isCommitting$1 = false;
11559var rootWithPendingPassiveEffects = null;
11560var passiveEffectCallbackHandle = null;
11561var passiveEffectCallback = null;
11562
11563var legacyErrorBoundariesThatAlreadyFailed = null;
11564
11565// Used for performance tracking.
11566var interruptedBy = null;
11567
11568var stashedWorkInProgressProperties = void 0;
11569var replayUnitOfWork = void 0;
11570var mayReplayFailedUnitOfWork = void 0;
11571var isReplayingFailedUnitOfWork = void 0;
11572var originalReplayError = void 0;
11573var rethrowOriginalError = void 0;
11574if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
11575 stashedWorkInProgressProperties = null;
11576 mayReplayFailedUnitOfWork = true;
11577 isReplayingFailedUnitOfWork = false;
11578 originalReplayError = null;
11579 replayUnitOfWork = function (failedUnitOfWork, thrownValue, isYieldy) {
11580 if (thrownValue !== null && typeof thrownValue === 'object' && typeof thrownValue.then === 'function') {
11581 // Don't replay promises. Treat everything else like an error.
11582 // TODO: Need to figure out a different strategy if/when we add
11583 // support for catching other types.
11584 return;
11585 }
11586
11587 // Restore the original state of the work-in-progress
11588 if (stashedWorkInProgressProperties === null) {
11589 // This should never happen. Don't throw because this code is DEV-only.
11590 warningWithoutStack$1(false, 'Could not replay rendering after an error. This is likely a bug in React. ' + 'Please file an issue.');
11591 return;
11592 }
11593 assignFiberPropertiesInDEV(failedUnitOfWork, stashedWorkInProgressProperties);
11594
11595 switch (failedUnitOfWork.tag) {
11596 case HostRoot:
11597 popHostContainer(failedUnitOfWork);
11598 popTopLevelContextObject(failedUnitOfWork);
11599 break;
11600 case HostComponent:
11601 popHostContext(failedUnitOfWork);
11602 break;
11603 case ClassComponent:
11604 {
11605 var Component = failedUnitOfWork.type;
11606 if (isContextProvider(Component)) {
11607 popContext(failedUnitOfWork);
11608 }
11609 break;
11610 }
11611 case HostPortal:
11612 popHostContainer(failedUnitOfWork);
11613 break;
11614 case ContextProvider:
11615 popProvider(failedUnitOfWork);
11616 break;
11617 }
11618 // Replay the begin phase.
11619 isReplayingFailedUnitOfWork = true;
11620 originalReplayError = thrownValue;
11621 invokeGuardedCallback(null, workLoop, null, isYieldy);
11622 isReplayingFailedUnitOfWork = false;
11623 originalReplayError = null;
11624 if (hasCaughtError()) {
11625 var replayError = clearCaughtError();
11626 if (replayError != null && thrownValue != null) {
11627 try {
11628 // Reading the expando property is intentionally
11629 // inside `try` because it might be a getter or Proxy.
11630 if (replayError._suppressLogging) {
11631 // Also suppress logging for the original error.
11632 thrownValue._suppressLogging = true;
11633 }
11634 } catch (inner) {
11635 // Ignore.
11636 }
11637 }
11638 } else {
11639 // If the begin phase did not fail the second time, set this pointer
11640 // back to the original value.
11641 nextUnitOfWork = failedUnitOfWork;
11642 }
11643 };
11644 rethrowOriginalError = function () {
11645 throw originalReplayError;
11646 };
11647}
11648
11649function resetStack() {
11650 if (nextUnitOfWork !== null) {
11651 var interruptedWork = nextUnitOfWork.return;
11652 while (interruptedWork !== null) {
11653 unwindInterruptedWork(interruptedWork);
11654 interruptedWork = interruptedWork.return;
11655 }
11656 }
11657
11658 {
11659 ReactStrictModeWarnings.discardPendingWarnings();
11660 checkThatStackIsEmpty();
11661 }
11662
11663 nextRoot = null;
11664 nextRenderExpirationTime = NoWork;
11665 nextLatestAbsoluteTimeoutMs = -1;
11666 nextRenderDidError = false;
11667 nextUnitOfWork = null;
11668}
11669
11670function commitAllHostEffects() {
11671 while (nextEffect !== null) {
11672 {
11673 setCurrentFiber(nextEffect);
11674 }
11675 recordEffect();
11676
11677 var effectTag = nextEffect.effectTag;
11678
11679 if (effectTag & ContentReset) {
11680 commitResetTextContent(nextEffect);
11681 }
11682
11683 if (effectTag & Ref) {
11684 var current$$1 = nextEffect.alternate;
11685 if (current$$1 !== null) {
11686 commitDetachRef(current$$1);
11687 }
11688 }
11689
11690 // The following switch statement is only concerned about placement,
11691 // updates, and deletions. To avoid needing to add a case for every
11692 // possible bitmap value, we remove the secondary effects from the
11693 // effect tag and switch on that value.
11694 var primaryEffectTag = effectTag & (Placement | Update | Deletion);
11695 switch (primaryEffectTag) {
11696 case Placement:
11697 {
11698 commitPlacement(nextEffect);
11699 // Clear the "placement" from effect tag so that we know that this is inserted, before
11700 // any life-cycles like componentDidMount gets called.
11701 // TODO: findDOMNode doesn't rely on this any more but isMounted
11702 // does and isMounted is deprecated anyway so we should be able
11703 // to kill this.
11704 nextEffect.effectTag &= ~Placement;
11705 break;
11706 }
11707 case PlacementAndUpdate:
11708 {
11709 // Placement
11710 commitPlacement(nextEffect);
11711 // Clear the "placement" from effect tag so that we know that this is inserted, before
11712 // any life-cycles like componentDidMount gets called.
11713 nextEffect.effectTag &= ~Placement;
11714
11715 // Update
11716 var _current = nextEffect.alternate;
11717 commitWork(_current, nextEffect);
11718 break;
11719 }
11720 case Update:
11721 {
11722 var _current2 = nextEffect.alternate;
11723 commitWork(_current2, nextEffect);
11724 break;
11725 }
11726 case Deletion:
11727 {
11728 commitDeletion(nextEffect);
11729 break;
11730 }
11731 }
11732 nextEffect = nextEffect.nextEffect;
11733 }
11734
11735 {
11736 resetCurrentFiber();
11737 }
11738}
11739
11740function commitBeforeMutationLifecycles() {
11741 while (nextEffect !== null) {
11742 {
11743 setCurrentFiber(nextEffect);
11744 }
11745
11746 var effectTag = nextEffect.effectTag;
11747 if (effectTag & Snapshot) {
11748 recordEffect();
11749 var current$$1 = nextEffect.alternate;
11750 commitBeforeMutationLifeCycles(current$$1, nextEffect);
11751 }
11752
11753 nextEffect = nextEffect.nextEffect;
11754 }
11755
11756 {
11757 resetCurrentFiber();
11758 }
11759}
11760
11761function commitAllLifeCycles(finishedRoot, committedExpirationTime) {
11762 {
11763 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
11764 ReactStrictModeWarnings.flushLegacyContextWarning();
11765
11766 if (warnAboutDeprecatedLifecycles) {
11767 ReactStrictModeWarnings.flushPendingDeprecationWarnings();
11768 }
11769 }
11770 while (nextEffect !== null) {
11771 {
11772 setCurrentFiber(nextEffect);
11773 }
11774 var effectTag = nextEffect.effectTag;
11775
11776 if (effectTag & (Update | Callback)) {
11777 recordEffect();
11778 var current$$1 = nextEffect.alternate;
11779 commitLifeCycles(finishedRoot, current$$1, nextEffect, committedExpirationTime);
11780 }
11781
11782 if (effectTag & Ref) {
11783 recordEffect();
11784 commitAttachRef(nextEffect);
11785 }
11786
11787 if (effectTag & Passive) {
11788 rootWithPendingPassiveEffects = finishedRoot;
11789 }
11790
11791 nextEffect = nextEffect.nextEffect;
11792 }
11793 {
11794 resetCurrentFiber();
11795 }
11796}
11797
11798function commitPassiveEffects(root, firstEffect) {
11799 rootWithPendingPassiveEffects = null;
11800 passiveEffectCallbackHandle = null;
11801 passiveEffectCallback = null;
11802
11803 // Set this to true to prevent re-entrancy
11804 var previousIsRendering = isRendering;
11805 isRendering = true;
11806
11807 var effect = firstEffect;
11808 do {
11809 {
11810 setCurrentFiber(effect);
11811 }
11812
11813 if (effect.effectTag & Passive) {
11814 var didError = false;
11815 var error = void 0;
11816 {
11817 isInPassiveEffectDEV = true;
11818 invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
11819 isInPassiveEffectDEV = false;
11820 if (hasCaughtError()) {
11821 didError = true;
11822 error = clearCaughtError();
11823 }
11824 }
11825 if (didError) {
11826 captureCommitPhaseError$1(effect, error);
11827 }
11828 }
11829 effect = effect.nextEffect;
11830 } while (effect !== null);
11831 {
11832 resetCurrentFiber();
11833 }
11834
11835 isRendering = previousIsRendering;
11836
11837 // Check if work was scheduled by one of the effects
11838 var rootExpirationTime = root.expirationTime;
11839 if (rootExpirationTime !== NoWork) {
11840 requestWork(root, rootExpirationTime);
11841 }
11842 // Flush any sync work that was scheduled by effects
11843 if (!isBatchingUpdates && !isRendering) {
11844 performSyncWork();
11845 }
11846
11847 {
11848 if (rootWithPendingPassiveEffects === root) {
11849 nestedPassiveEffectCountDEV++;
11850 } else {
11851 nestedPassiveEffectCountDEV = 0;
11852 }
11853 }
11854}
11855
11856function isAlreadyFailedLegacyErrorBoundary$1(instance) {
11857 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
11858}
11859
11860function markLegacyErrorBoundaryAsFailed$1(instance) {
11861 if (legacyErrorBoundariesThatAlreadyFailed === null) {
11862 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
11863 } else {
11864 legacyErrorBoundariesThatAlreadyFailed.add(instance);
11865 }
11866}
11867
11868function flushPassiveEffects$1() {
11869 var didFlushEffects = passiveEffectCallback !== null;
11870 if (passiveEffectCallbackHandle !== null) {
11871 cancelCallback$1(passiveEffectCallbackHandle);
11872 }
11873 if (passiveEffectCallback !== null) {
11874 // We call the scheduled callback instead of commitPassiveEffects directly
11875 // to ensure tracing works correctly.
11876 passiveEffectCallback();
11877 }
11878 return didFlushEffects;
11879}
11880
11881function commitRoot(root, finishedWork) {
11882 isWorking = true;
11883 isCommitting$1 = true;
11884 startCommitTimer();
11885
11886 (function () {
11887 if (!(root.current !== finishedWork)) {
11888 {
11889 throw ReactError('Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.');
11890 }
11891 }
11892 })();
11893 var committedExpirationTime = root.pendingCommitExpirationTime;
11894 (function () {
11895 if (!(committedExpirationTime !== NoWork)) {
11896 {
11897 throw ReactError('Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.');
11898 }
11899 }
11900 })();
11901 root.pendingCommitExpirationTime = NoWork;
11902
11903 // Update the pending priority levels to account for the work that we are
11904 // about to commit. This needs to happen before calling the lifecycles, since
11905 // they may schedule additional updates.
11906 var updateExpirationTimeBeforeCommit = finishedWork.expirationTime;
11907 var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime;
11908 var earliestRemainingTimeBeforeCommit = childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit;
11909 markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
11910
11911 var prevInteractions = null;
11912 if (enableSchedulerTracing) {
11913 // Restore any pending interactions at this point,
11914 // So that cascading work triggered during the render phase will be accounted for.
11915 prevInteractions = tracing.__interactionsRef.current;
11916 tracing.__interactionsRef.current = root.memoizedInteractions;
11917 }
11918
11919 // Reset this to null before calling lifecycles
11920 ReactCurrentOwner$1.current = null;
11921
11922 var firstEffect = void 0;
11923 if (finishedWork.effectTag > PerformedWork) {
11924 // A fiber's effect list consists only of its children, not itself. So if
11925 // the root has an effect, we need to add it to the end of the list. The
11926 // resulting list is the set that would belong to the root's parent, if
11927 // it had one; that is, all the effects in the tree including the root.
11928 if (finishedWork.lastEffect !== null) {
11929 finishedWork.lastEffect.nextEffect = finishedWork;
11930 firstEffect = finishedWork.firstEffect;
11931 } else {
11932 firstEffect = finishedWork;
11933 }
11934 } else {
11935 // There is no effect on the root.
11936 firstEffect = finishedWork.firstEffect;
11937 }
11938
11939 prepareForCommit(root.containerInfo);
11940
11941 // Invoke instances of getSnapshotBeforeUpdate before mutation.
11942 nextEffect = firstEffect;
11943 startCommitSnapshotEffectsTimer();
11944 while (nextEffect !== null) {
11945 var didError = false;
11946 var error = void 0;
11947 {
11948 invokeGuardedCallback(null, commitBeforeMutationLifecycles, null);
11949 if (hasCaughtError()) {
11950 didError = true;
11951 error = clearCaughtError();
11952 }
11953 }
11954 if (didError) {
11955 (function () {
11956 if (!(nextEffect !== null)) {
11957 {
11958 throw ReactError('Should have next effect. This error is likely caused by a bug in React. Please file an issue.');
11959 }
11960 }
11961 })();
11962 captureCommitPhaseError$1(nextEffect, error);
11963 // Clean-up
11964 if (nextEffect !== null) {
11965 nextEffect = nextEffect.nextEffect;
11966 }
11967 }
11968 }
11969 stopCommitSnapshotEffectsTimer();
11970
11971 if (enableProfilerTimer) {
11972 // Mark the current commit time to be shared by all Profilers in this batch.
11973 // This enables them to be grouped later.
11974 recordCommitTime();
11975 }
11976
11977 // Commit all the side-effects within a tree. We'll do this in two passes.
11978 // The first pass performs all the host insertions, updates, deletions and
11979 // ref unmounts.
11980 nextEffect = firstEffect;
11981 startCommitHostEffectsTimer();
11982 while (nextEffect !== null) {
11983 var _didError = false;
11984 var _error = void 0;
11985 {
11986 invokeGuardedCallback(null, commitAllHostEffects, null);
11987 if (hasCaughtError()) {
11988 _didError = true;
11989 _error = clearCaughtError();
11990 }
11991 }
11992 if (_didError) {
11993 (function () {
11994 if (!(nextEffect !== null)) {
11995 {
11996 throw ReactError('Should have next effect. This error is likely caused by a bug in React. Please file an issue.');
11997 }
11998 }
11999 })();
12000 captureCommitPhaseError$1(nextEffect, _error);
12001 // Clean-up
12002 if (nextEffect !== null) {
12003 nextEffect = nextEffect.nextEffect;
12004 }
12005 }
12006 }
12007 stopCommitHostEffectsTimer();
12008
12009 resetAfterCommit(root.containerInfo);
12010
12011 // The work-in-progress tree is now the current tree. This must come after
12012 // the first pass of the commit phase, so that the previous tree is still
12013 // current during componentWillUnmount, but before the second pass, so that
12014 // the finished work is current during componentDidMount/Update.
12015 root.current = finishedWork;
12016
12017 // In the second pass we'll perform all life-cycles and ref callbacks.
12018 // Life-cycles happen as a separate pass so that all placements, updates,
12019 // and deletions in the entire tree have already been invoked.
12020 // This pass also triggers any renderer-specific initial effects.
12021 nextEffect = firstEffect;
12022 startCommitLifeCyclesTimer();
12023 while (nextEffect !== null) {
12024 var _didError2 = false;
12025 var _error2 = void 0;
12026 {
12027 invokeGuardedCallback(null, commitAllLifeCycles, null, root, committedExpirationTime);
12028 if (hasCaughtError()) {
12029 _didError2 = true;
12030 _error2 = clearCaughtError();
12031 }
12032 }
12033 if (_didError2) {
12034 (function () {
12035 if (!(nextEffect !== null)) {
12036 {
12037 throw ReactError('Should have next effect. This error is likely caused by a bug in React. Please file an issue.');
12038 }
12039 }
12040 })();
12041 captureCommitPhaseError$1(nextEffect, _error2);
12042 if (nextEffect !== null) {
12043 nextEffect = nextEffect.nextEffect;
12044 }
12045 }
12046 }
12047
12048 if (firstEffect !== null && rootWithPendingPassiveEffects !== null) {
12049 // This commit included a passive effect. These do not need to fire until
12050 // after the next paint. Schedule an callback to fire them in an async
12051 // event. To ensure serial execution, the callback will be flushed early if
12052 // we enter rootWithPendingPassiveEffects commit phase before then.
12053 var callback = commitPassiveEffects.bind(null, root, firstEffect);
12054 if (enableSchedulerTracing) {
12055 // TODO: Avoid this extra callback by mutating the tracing ref directly,
12056 // like we do at the beginning of commitRoot. I've opted not to do that
12057 // here because that code is still in flux.
12058 callback = tracing.unstable_wrap(callback);
12059 }
12060 passiveEffectCallbackHandle = scheduleCallback$1(NormalPriority$1, callback);
12061 passiveEffectCallback = callback;
12062 }
12063
12064 isCommitting$1 = false;
12065 isWorking = false;
12066 stopCommitLifeCyclesTimer();
12067 stopCommitTimer();
12068 onCommitRoot(finishedWork.stateNode);
12069 if (true && ReactFiberInstrumentation_1.debugTool) {
12070 ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork);
12071 }
12072
12073 var updateExpirationTimeAfterCommit = finishedWork.expirationTime;
12074 var childExpirationTimeAfterCommit = finishedWork.childExpirationTime;
12075 var earliestRemainingTimeAfterCommit = childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit;
12076 if (earliestRemainingTimeAfterCommit === NoWork) {
12077 // If there's no remaining work, we can clear the set of already failed
12078 // error boundaries.
12079 legacyErrorBoundariesThatAlreadyFailed = null;
12080 }
12081 onCommit(root, earliestRemainingTimeAfterCommit);
12082
12083 if (enableSchedulerTracing) {
12084 tracing.__interactionsRef.current = prevInteractions;
12085
12086 var subscriber = void 0;
12087
12088 try {
12089 subscriber = tracing.__subscriberRef.current;
12090 if (subscriber !== null && root.memoizedInteractions.size > 0) {
12091 var threadID = computeThreadID(committedExpirationTime, root.interactionThreadID);
12092 subscriber.onWorkStopped(root.memoizedInteractions, threadID);
12093 }
12094 } catch (error) {
12095 // It's not safe for commitRoot() to throw.
12096 // Store the error for now and we'll re-throw in finishRendering().
12097 if (!hasUnhandledError) {
12098 hasUnhandledError = true;
12099 unhandledError = error;
12100 }
12101 } finally {
12102 // Clear completed interactions from the pending Map.
12103 // Unless the render was suspended or cascading work was scheduled,
12104 // In which case– leave pending interactions until the subsequent render.
12105 var pendingInteractionMap = root.pendingInteractionMap;
12106 pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
12107 // Only decrement the pending interaction count if we're done.
12108 // If there's still work at the current priority,
12109 // That indicates that we are waiting for suspense data.
12110 if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
12111 pendingInteractionMap.delete(scheduledExpirationTime);
12112
12113 scheduledInteractions.forEach(function (interaction) {
12114 interaction.__count--;
12115
12116 if (subscriber !== null && interaction.__count === 0) {
12117 try {
12118 subscriber.onInteractionScheduledWorkCompleted(interaction);
12119 } catch (error) {
12120 // It's not safe for commitRoot() to throw.
12121 // Store the error for now and we'll re-throw in finishRendering().
12122 if (!hasUnhandledError) {
12123 hasUnhandledError = true;
12124 unhandledError = error;
12125 }
12126 }
12127 }
12128 });
12129 }
12130 });
12131 }
12132 }
12133}
12134
12135function resetChildExpirationTime(workInProgress, renderTime) {
12136 if (renderTime !== Never && workInProgress.childExpirationTime === Never) {
12137 // The children of this component are hidden. Don't bubble their
12138 // expiration times.
12139 return;
12140 }
12141
12142 var newChildExpirationTime = NoWork;
12143
12144 // Bubble up the earliest expiration time.
12145 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
12146 // We're in profiling mode.
12147 // Let's use this same traversal to update the render durations.
12148 var actualDuration = workInProgress.actualDuration;
12149 var treeBaseDuration = workInProgress.selfBaseDuration;
12150
12151 // When a fiber is cloned, its actualDuration is reset to 0.
12152 // This value will only be updated if work is done on the fiber (i.e. it doesn't bailout).
12153 // When work is done, it should bubble to the parent's actualDuration.
12154 // If the fiber has not been cloned though, (meaning no work was done),
12155 // Then this value will reflect the amount of time spent working on a previous render.
12156 // In that case it should not bubble.
12157 // We determine whether it was cloned by comparing the child pointer.
12158 var shouldBubbleActualDurations = workInProgress.alternate === null || workInProgress.child !== workInProgress.alternate.child;
12159
12160 var child = workInProgress.child;
12161 while (child !== null) {
12162 var childUpdateExpirationTime = child.expirationTime;
12163 var childChildExpirationTime = child.childExpirationTime;
12164 if (childUpdateExpirationTime > newChildExpirationTime) {
12165 newChildExpirationTime = childUpdateExpirationTime;
12166 }
12167 if (childChildExpirationTime > newChildExpirationTime) {
12168 newChildExpirationTime = childChildExpirationTime;
12169 }
12170 if (shouldBubbleActualDurations) {
12171 actualDuration += child.actualDuration;
12172 }
12173 treeBaseDuration += child.treeBaseDuration;
12174 child = child.sibling;
12175 }
12176 workInProgress.actualDuration = actualDuration;
12177 workInProgress.treeBaseDuration = treeBaseDuration;
12178 } else {
12179 var _child = workInProgress.child;
12180 while (_child !== null) {
12181 var _childUpdateExpirationTime = _child.expirationTime;
12182 var _childChildExpirationTime = _child.childExpirationTime;
12183 if (_childUpdateExpirationTime > newChildExpirationTime) {
12184 newChildExpirationTime = _childUpdateExpirationTime;
12185 }
12186 if (_childChildExpirationTime > newChildExpirationTime) {
12187 newChildExpirationTime = _childChildExpirationTime;
12188 }
12189 _child = _child.sibling;
12190 }
12191 }
12192
12193 workInProgress.childExpirationTime = newChildExpirationTime;
12194}
12195
12196function completeUnitOfWork(workInProgress) {
12197 // Attempt to complete the current unit of work, then move to the
12198 // next sibling. If there are no more siblings, return to the
12199 // parent fiber.
12200 while (true) {
12201 // The current, flushed, state of this fiber is the alternate.
12202 // Ideally nothing should rely on this, but relying on it here
12203 // means that we don't need an additional field on the work in
12204 // progress.
12205 var current$$1 = workInProgress.alternate;
12206 {
12207 setCurrentFiber(workInProgress);
12208 }
12209
12210 var returnFiber = workInProgress.return;
12211 var siblingFiber = workInProgress.sibling;
12212
12213 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
12214 if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
12215 // Don't replay if it fails during completion phase.
12216 mayReplayFailedUnitOfWork = false;
12217 }
12218 // This fiber completed.
12219 // Remember we're completing this unit so we can find a boundary if it fails.
12220 nextUnitOfWork = workInProgress;
12221 if (enableProfilerTimer) {
12222 if (workInProgress.mode & ProfileMode) {
12223 startProfilerTimer(workInProgress);
12224 }
12225 nextUnitOfWork = completeWork(current$$1, workInProgress, nextRenderExpirationTime);
12226 if (workInProgress.mode & ProfileMode) {
12227 // Update render duration assuming we didn't error.
12228 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
12229 }
12230 } else {
12231 nextUnitOfWork = completeWork(current$$1, workInProgress, nextRenderExpirationTime);
12232 }
12233 if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
12234 // We're out of completion phase so replaying is fine now.
12235 mayReplayFailedUnitOfWork = true;
12236 }
12237 stopWorkTimer(workInProgress);
12238 resetChildExpirationTime(workInProgress, nextRenderExpirationTime);
12239 {
12240 resetCurrentFiber();
12241 }
12242
12243 if (nextUnitOfWork !== null) {
12244 // Completing this fiber spawned new work. Work on that next.
12245 return nextUnitOfWork;
12246 }
12247
12248 if (returnFiber !== null &&
12249 // Do not append effects to parents if a sibling failed to complete
12250 (returnFiber.effectTag & Incomplete) === NoEffect) {
12251 // Append all the effects of the subtree and this fiber onto the effect
12252 // list of the parent. The completion order of the children affects the
12253 // side-effect order.
12254 if (returnFiber.firstEffect === null) {
12255 returnFiber.firstEffect = workInProgress.firstEffect;
12256 }
12257 if (workInProgress.lastEffect !== null) {
12258 if (returnFiber.lastEffect !== null) {
12259 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
12260 }
12261 returnFiber.lastEffect = workInProgress.lastEffect;
12262 }
12263
12264 // If this fiber had side-effects, we append it AFTER the children's
12265 // side-effects. We can perform certain side-effects earlier if
12266 // needed, by doing multiple passes over the effect list. We don't want
12267 // to schedule our own side-effect on our own list because if end up
12268 // reusing children we'll schedule this effect onto itself since we're
12269 // at the end.
12270 var effectTag = workInProgress.effectTag;
12271 // Skip both NoWork and PerformedWork tags when creating the effect list.
12272 // PerformedWork effect is read by React DevTools but shouldn't be committed.
12273 if (effectTag > PerformedWork) {
12274 if (returnFiber.lastEffect !== null) {
12275 returnFiber.lastEffect.nextEffect = workInProgress;
12276 } else {
12277 returnFiber.firstEffect = workInProgress;
12278 }
12279 returnFiber.lastEffect = workInProgress;
12280 }
12281 }
12282
12283 if (true && ReactFiberInstrumentation_1.debugTool) {
12284 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
12285 }
12286
12287 if (siblingFiber !== null) {
12288 // If there is more work to do in this returnFiber, do that next.
12289 return siblingFiber;
12290 } else if (returnFiber !== null) {
12291 // If there's no more work in this returnFiber. Complete the returnFiber.
12292 workInProgress = returnFiber;
12293 continue;
12294 } else {
12295 // We've reached the root.
12296 return null;
12297 }
12298 } else {
12299 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
12300 // Record the render duration for the fiber that errored.
12301 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
12302
12303 // Include the time spent working on failed children before continuing.
12304 var actualDuration = workInProgress.actualDuration;
12305 var child = workInProgress.child;
12306 while (child !== null) {
12307 actualDuration += child.actualDuration;
12308 child = child.sibling;
12309 }
12310 workInProgress.actualDuration = actualDuration;
12311 }
12312
12313 // This fiber did not complete because something threw. Pop values off
12314 // the stack without entering the complete phase. If this is a boundary,
12315 // capture values if possible.
12316 var next = unwindWork(workInProgress, nextRenderExpirationTime);
12317 // Because this fiber did not complete, don't reset its expiration time.
12318 if (workInProgress.effectTag & DidCapture) {
12319 // Restarting an error boundary
12320 stopFailedWorkTimer(workInProgress);
12321 } else {
12322 stopWorkTimer(workInProgress);
12323 }
12324
12325 {
12326 resetCurrentFiber();
12327 }
12328
12329 if (next !== null) {
12330 stopWorkTimer(workInProgress);
12331 if (true && ReactFiberInstrumentation_1.debugTool) {
12332 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
12333 }
12334
12335 // If completing this work spawned new work, do that next. We'll come
12336 // back here again.
12337 // Since we're restarting, remove anything that is not a host effect
12338 // from the effect tag.
12339 next.effectTag &= HostEffectMask;
12340 return next;
12341 }
12342
12343 if (returnFiber !== null) {
12344 // Mark the parent fiber as incomplete and clear its effect list.
12345 returnFiber.firstEffect = returnFiber.lastEffect = null;
12346 returnFiber.effectTag |= Incomplete;
12347 }
12348
12349 if (true && ReactFiberInstrumentation_1.debugTool) {
12350 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
12351 }
12352
12353 if (siblingFiber !== null) {
12354 // If there is more work to do in this returnFiber, do that next.
12355 return siblingFiber;
12356 } else if (returnFiber !== null) {
12357 // If there's no more work in this returnFiber. Complete the returnFiber.
12358 workInProgress = returnFiber;
12359 continue;
12360 } else {
12361 return null;
12362 }
12363 }
12364 }
12365
12366 // Without this explicit null return Flow complains of invalid return type
12367 // TODO Remove the above while(true) loop
12368 // eslint-disable-next-line no-unreachable
12369 return null;
12370}
12371
12372function performUnitOfWork(workInProgress) {
12373 // The current, flushed, state of this fiber is the alternate.
12374 // Ideally nothing should rely on this, but relying on it here
12375 // means that we don't need an additional field on the work in
12376 // progress.
12377 var current$$1 = workInProgress.alternate;
12378
12379 // See if beginning this work spawns more work.
12380 startWorkTimer(workInProgress);
12381 {
12382 setCurrentFiber(workInProgress);
12383 }
12384
12385 if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
12386 stashedWorkInProgressProperties = assignFiberPropertiesInDEV(stashedWorkInProgressProperties, workInProgress);
12387 }
12388
12389 var next = void 0;
12390 if (enableProfilerTimer) {
12391 if (workInProgress.mode & ProfileMode) {
12392 startProfilerTimer(workInProgress);
12393 }
12394
12395 next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
12396 workInProgress.memoizedProps = workInProgress.pendingProps;
12397
12398 if (workInProgress.mode & ProfileMode) {
12399 // Record the render duration assuming we didn't bailout (or error).
12400 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
12401 }
12402 } else {
12403 next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
12404 workInProgress.memoizedProps = workInProgress.pendingProps;
12405 }
12406
12407 {
12408 resetCurrentFiber();
12409 if (isReplayingFailedUnitOfWork) {
12410 // Currently replaying a failed unit of work. This should be unreachable,
12411 // because the render phase is meant to be idempotent, and it should
12412 // have thrown again. Since it didn't, rethrow the original error, so
12413 // React's internal stack is not misaligned.
12414 rethrowOriginalError();
12415 }
12416 }
12417 if (true && ReactFiberInstrumentation_1.debugTool) {
12418 ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress);
12419 }
12420
12421 if (next === null) {
12422 // If this doesn't spawn new work, complete the current work.
12423 next = completeUnitOfWork(workInProgress);
12424 }
12425
12426 ReactCurrentOwner$1.current = null;
12427
12428 return next;
12429}
12430
12431function workLoop(isYieldy) {
12432 if (!isYieldy) {
12433 // Flush work without yielding
12434 while (nextUnitOfWork !== null) {
12435 nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
12436 }
12437 } else {
12438 // Flush asynchronous work until there's a higher priority event
12439 while (nextUnitOfWork !== null && !shouldYield$2()) {
12440 nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
12441 }
12442 }
12443}
12444
12445function renderRoot(root, isYieldy) {
12446 (function () {
12447 if (!!isWorking) {
12448 {
12449 throw ReactError('renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.');
12450 }
12451 }
12452 })();
12453
12454 flushPassiveEffects$1();
12455
12456 isWorking = true;
12457 var previousDispatcher = ReactCurrentDispatcher.current;
12458 ReactCurrentDispatcher.current = ContextOnlyDispatcher;
12459
12460 var expirationTime = root.nextExpirationTimeToWorkOn;
12461
12462 // Check if we're starting from a fresh stack, or if we're resuming from
12463 // previously yielded work.
12464 if (expirationTime !== nextRenderExpirationTime || root !== nextRoot || nextUnitOfWork === null) {
12465 // Reset the stack and start working from the root.
12466 resetStack();
12467 nextRoot = root;
12468 nextRenderExpirationTime = expirationTime;
12469 nextUnitOfWork = createWorkInProgress(nextRoot.current, null, nextRenderExpirationTime);
12470 root.pendingCommitExpirationTime = NoWork;
12471
12472 if (enableSchedulerTracing) {
12473 // Determine which interactions this batch of work currently includes,
12474 // So that we can accurately attribute time spent working on it,
12475 var interactions = new Set();
12476 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
12477 if (scheduledExpirationTime >= expirationTime) {
12478 scheduledInteractions.forEach(function (interaction) {
12479 return interactions.add(interaction);
12480 });
12481 }
12482 });
12483
12484 // Store the current set of interactions on the FiberRoot for a few reasons:
12485 // We can re-use it in hot functions like renderRoot() without having to recalculate it.
12486 // We will also use it in commitWork() to pass to any Profiler onRender() hooks.
12487 // This also provides DevTools with a way to access it when the onCommitRoot() hook is called.
12488 root.memoizedInteractions = interactions;
12489
12490 if (interactions.size > 0) {
12491 var subscriber = tracing.__subscriberRef.current;
12492 if (subscriber !== null) {
12493 var threadID = computeThreadID(expirationTime, root.interactionThreadID);
12494 try {
12495 subscriber.onWorkStarted(interactions, threadID);
12496 } catch (error) {
12497 // Work thrown by an interaction tracing subscriber should be rethrown,
12498 // But only once it's safe (to avoid leaving the scheduler in an invalid state).
12499 // Store the error for now and we'll re-throw in finishRendering().
12500 if (!hasUnhandledError) {
12501 hasUnhandledError = true;
12502 unhandledError = error;
12503 }
12504 }
12505 }
12506 }
12507 }
12508 }
12509
12510 var prevInteractions = null;
12511 if (enableSchedulerTracing) {
12512 // We're about to start new traced work.
12513 // Restore pending interactions so cascading work triggered during the render phase will be accounted for.
12514 prevInteractions = tracing.__interactionsRef.current;
12515 tracing.__interactionsRef.current = root.memoizedInteractions;
12516 }
12517
12518 var didFatal = false;
12519
12520 startWorkLoopTimer(nextUnitOfWork);
12521
12522 do {
12523 try {
12524 workLoop(isYieldy);
12525 } catch (thrownValue) {
12526 resetContextDependences();
12527 resetHooks();
12528
12529 // Reset in case completion throws.
12530 // This is only used in DEV and when replaying is on.
12531 var mayReplay = void 0;
12532 if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
12533 mayReplay = mayReplayFailedUnitOfWork;
12534 mayReplayFailedUnitOfWork = true;
12535 }
12536
12537 if (nextUnitOfWork === null) {
12538 // This is a fatal error.
12539 didFatal = true;
12540 onUncaughtError$1(thrownValue);
12541 } else {
12542 if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) {
12543 // Record the time spent rendering before an error was thrown.
12544 // This avoids inaccurate Profiler durations in the case of a suspended render.
12545 stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true);
12546 }
12547
12548 {
12549 // Reset global debug state
12550 // We assume this is defined in DEV
12551 resetCurrentlyProcessingQueue();
12552 }
12553
12554 if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
12555 if (mayReplay) {
12556 var failedUnitOfWork = nextUnitOfWork;
12557 replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy);
12558 }
12559 }
12560
12561 // TODO: we already know this isn't true in some cases.
12562 // At least this shows a nicer error message until we figure out the cause.
12563 // https://github.com/facebook/react/issues/12449#issuecomment-386727431
12564 (function () {
12565 if (!(nextUnitOfWork !== null)) {
12566 {
12567 throw ReactError('Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it.');
12568 }
12569 }
12570 })();
12571
12572 var sourceFiber = nextUnitOfWork;
12573 var returnFiber = sourceFiber.return;
12574 if (returnFiber === null) {
12575 // This is the root. The root could capture its own errors. However,
12576 // we don't know if it errors before or after we pushed the host
12577 // context. This information is needed to avoid a stack mismatch.
12578 // Because we're not sure, treat this as a fatal error. We could track
12579 // which phase it fails in, but doesn't seem worth it. At least
12580 // for now.
12581 didFatal = true;
12582 onUncaughtError$1(thrownValue);
12583 } else {
12584 throwException(root, returnFiber, sourceFiber, thrownValue, nextRenderExpirationTime);
12585 nextUnitOfWork = completeUnitOfWork(sourceFiber);
12586 continue;
12587 }
12588 }
12589 }
12590 break;
12591 } while (true);
12592
12593 if (enableSchedulerTracing) {
12594 // Traced work is done for now; restore the previous interactions.
12595 tracing.__interactionsRef.current = prevInteractions;
12596 }
12597
12598 // We're done performing work. Time to clean up.
12599 isWorking = false;
12600 ReactCurrentDispatcher.current = previousDispatcher;
12601 resetContextDependences();
12602 resetHooks();
12603
12604 // Yield back to main thread.
12605 if (didFatal) {
12606 var _didCompleteRoot = false;
12607 stopWorkLoopTimer(interruptedBy, _didCompleteRoot);
12608 interruptedBy = null;
12609 // There was a fatal error.
12610 {
12611 resetStackAfterFatalErrorInDev();
12612 }
12613 // `nextRoot` points to the in-progress root. A non-null value indicates
12614 // that we're in the middle of an async render. Set it to null to indicate
12615 // there's no more work to be done in the current batch.
12616 nextRoot = null;
12617 onFatal(root);
12618 return;
12619 }
12620
12621 if (nextUnitOfWork !== null) {
12622 // There's still remaining async work in this tree, but we ran out of time
12623 // in the current frame. Yield back to the renderer. Unless we're
12624 // interrupted by a higher priority update, we'll continue later from where
12625 // we left off.
12626 var _didCompleteRoot2 = false;
12627 stopWorkLoopTimer(interruptedBy, _didCompleteRoot2);
12628 interruptedBy = null;
12629 onYield(root);
12630 return;
12631 }
12632
12633 // We completed the whole tree.
12634 var didCompleteRoot = true;
12635 stopWorkLoopTimer(interruptedBy, didCompleteRoot);
12636 var rootWorkInProgress = root.current.alternate;
12637 (function () {
12638 if (!(rootWorkInProgress !== null)) {
12639 {
12640 throw ReactError('Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue.');
12641 }
12642 }
12643 })();
12644
12645 // `nextRoot` points to the in-progress root. A non-null value indicates
12646 // that we're in the middle of an async render. Set it to null to indicate
12647 // there's no more work to be done in the current batch.
12648 nextRoot = null;
12649 interruptedBy = null;
12650
12651 if (nextRenderDidError) {
12652 // There was an error
12653 if (hasLowerPriorityWork(root, expirationTime)) {
12654 // There's lower priority work. If so, it may have the effect of fixing
12655 // the exception that was just thrown. Exit without committing. This is
12656 // similar to a suspend, but without a timeout because we're not waiting
12657 // for a promise to resolve. React will restart at the lower
12658 // priority level.
12659 markSuspendedPriorityLevel(root, expirationTime);
12660 var suspendedExpirationTime = expirationTime;
12661 var rootExpirationTime = root.expirationTime;
12662 onSuspend(root, rootWorkInProgress, suspendedExpirationTime, rootExpirationTime, -1 // Indicates no timeout
12663 );
12664 return;
12665 } else if (
12666 // There's no lower priority work, but we're rendering asynchronously.
12667 // Synchronously attempt to render the same level one more time. This is
12668 // similar to a suspend, but without a timeout because we're not waiting
12669 // for a promise to resolve.
12670 !root.didError && isYieldy) {
12671 root.didError = true;
12672 var _suspendedExpirationTime = root.nextExpirationTimeToWorkOn = expirationTime;
12673 var _rootExpirationTime = root.expirationTime = Sync;
12674 onSuspend(root, rootWorkInProgress, _suspendedExpirationTime, _rootExpirationTime, -1 // Indicates no timeout
12675 );
12676 return;
12677 }
12678 }
12679
12680 if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) {
12681 // The tree was suspended.
12682 var _suspendedExpirationTime2 = expirationTime;
12683 markSuspendedPriorityLevel(root, _suspendedExpirationTime2);
12684
12685 // Find the earliest uncommitted expiration time in the tree, including
12686 // work that is suspended. The timeout threshold cannot be longer than
12687 // the overall expiration.
12688 var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, expirationTime);
12689 var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
12690 if (earliestExpirationTimeMs < nextLatestAbsoluteTimeoutMs) {
12691 nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs;
12692 }
12693
12694 // Subtract the current time from the absolute timeout to get the number
12695 // of milliseconds until the timeout. In other words, convert an absolute
12696 // timestamp to a relative time. This is the value that is passed
12697 // to `setTimeout`.
12698 var currentTimeMs = expirationTimeToMs(requestCurrentTime$1());
12699 var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs;
12700 msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout;
12701
12702 // TODO: Account for the Just Noticeable Difference
12703
12704 var _rootExpirationTime2 = root.expirationTime;
12705 onSuspend(root, rootWorkInProgress, _suspendedExpirationTime2, _rootExpirationTime2, msUntilTimeout);
12706 return;
12707 }
12708
12709 // Ready to commit.
12710 onComplete(root, rootWorkInProgress, expirationTime);
12711}
12712
12713function captureCommitPhaseError$1(sourceFiber, value) {
12714 var expirationTime = Sync;
12715 var fiber = sourceFiber.return;
12716 while (fiber !== null) {
12717 switch (fiber.tag) {
12718 case ClassComponent:
12719 var ctor = fiber.type;
12720 var instance = fiber.stateNode;
12721 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary$1(instance)) {
12722 var errorInfo = createCapturedValue(value, sourceFiber);
12723 var update = createClassErrorUpdate(fiber, errorInfo, expirationTime);
12724 enqueueUpdate(fiber, update);
12725 scheduleWork$1(fiber, expirationTime);
12726 return;
12727 }
12728 break;
12729 case HostRoot:
12730 {
12731 var _errorInfo = createCapturedValue(value, sourceFiber);
12732 var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime);
12733 enqueueUpdate(fiber, _update);
12734 scheduleWork$1(fiber, expirationTime);
12735 return;
12736 }
12737 }
12738 fiber = fiber.return;
12739 }
12740
12741 if (sourceFiber.tag === HostRoot) {
12742 // Error was thrown at the root. There is no parent, so the root
12743 // itself should capture it.
12744 var rootFiber = sourceFiber;
12745 var _errorInfo2 = createCapturedValue(value, rootFiber);
12746 var _update2 = createRootErrorUpdate(rootFiber, _errorInfo2, expirationTime);
12747 enqueueUpdate(rootFiber, _update2);
12748 scheduleWork$1(rootFiber, expirationTime);
12749 }
12750}
12751
12752function computeThreadID(expirationTime, interactionThreadID) {
12753 // Interaction threads are unique per root and expiration time.
12754 return expirationTime * 1000 + interactionThreadID;
12755}
12756
12757function computeExpirationForFiber$1(currentTime, fiber) {
12758 var expirationTime = void 0;
12759 if (expirationContext !== NoWork) {
12760 // An explicit expiration context was set;
12761 expirationTime = expirationContext;
12762 } else if (isWorking) {
12763 if (isCommitting$1) {
12764 // Updates that occur during the commit phase should have sync priority
12765 // by default.
12766 expirationTime = Sync;
12767 } else {
12768 // Updates during the render phase should expire at the same time as
12769 // the work that is being rendered.
12770 expirationTime = nextRenderExpirationTime;
12771 }
12772 } else {
12773 // No explicit expiration context was set, and we're not currently
12774 // performing work. Calculate a new expiration time.
12775 if (fiber.mode & ConcurrentMode) {
12776 if (isBatchingInteractiveUpdates) {
12777 // This is an interactive update
12778 expirationTime = computeInteractiveExpiration(currentTime);
12779 } else {
12780 // This is an async update
12781 expirationTime = computeAsyncExpiration(currentTime);
12782 }
12783 // If we're in the middle of rendering a tree, do not update at the same
12784 // expiration time that is already rendering.
12785 if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
12786 expirationTime -= 1;
12787 }
12788 } else {
12789 // This is a sync update
12790 expirationTime = Sync;
12791 }
12792 }
12793 return expirationTime;
12794}
12795
12796function renderDidSuspend$1(root, absoluteTimeoutMs, suspendedTime) {
12797 // Schedule the timeout.
12798 if (absoluteTimeoutMs >= 0 && nextLatestAbsoluteTimeoutMs < absoluteTimeoutMs) {
12799 nextLatestAbsoluteTimeoutMs = absoluteTimeoutMs;
12800 }
12801}
12802
12803function renderDidError$1() {
12804 nextRenderDidError = true;
12805}
12806
12807function inferStartTimeFromExpirationTime$1(root, expirationTime) {
12808 // We don't know exactly when the update was scheduled, but we can infer an
12809 // approximate start time from the expiration time. First, find the earliest
12810 // uncommitted expiration time in the tree, including work that is suspended.
12811 // Then subtract the offset used to compute an async update's expiration time.
12812 // This will cause high priority (interactive) work to expire earlier than
12813 // necessary, but we can account for this by adjusting for the Just
12814 // Noticeable Difference.
12815 var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, expirationTime);
12816 var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
12817 return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
12818}
12819
12820function pingSuspendedRoot$1(root, thenable, pingTime) {
12821 // A promise that previously suspended React from committing has resolved.
12822 // If React is still suspended, try again at the previous level (pingTime).
12823
12824 var pingCache = root.pingCache;
12825 if (pingCache !== null) {
12826 // The thenable resolved, so we no longer need to memoize, because it will
12827 // never be thrown again.
12828 pingCache.delete(thenable);
12829 }
12830
12831 if (nextRoot !== null && nextRenderExpirationTime === pingTime) {
12832 // Received a ping at the same priority level at which we're currently
12833 // rendering. Restart from the root.
12834 nextRoot = null;
12835 } else {
12836 // Confirm that the root is still suspended at this level. Otherwise exit.
12837 if (isPriorityLevelSuspended(root, pingTime)) {
12838 // Ping at the original level
12839 markPingedPriorityLevel(root, pingTime);
12840 var rootExpirationTime = root.expirationTime;
12841 if (rootExpirationTime !== NoWork) {
12842 requestWork(root, rootExpirationTime);
12843 }
12844 }
12845 }
12846}
12847
12848function retryTimedOutBoundary$1(boundaryFiber) {
12849 var currentTime = requestCurrentTime$1();
12850 var retryTime = computeExpirationForFiber$1(currentTime, boundaryFiber);
12851 var root = scheduleWorkToRoot(boundaryFiber, retryTime);
12852 if (root !== null) {
12853 markPendingPriorityLevel(root, retryTime);
12854 var rootExpirationTime = root.expirationTime;
12855 if (rootExpirationTime !== NoWork) {
12856 requestWork(root, rootExpirationTime);
12857 }
12858 }
12859}
12860
12861function resolveRetryThenable$1(boundaryFiber, thenable) {
12862 // The boundary fiber (a Suspense component) previously timed out and was
12863 // rendered in its fallback state. One of the promises that suspended it has
12864 // resolved, which means at least part of the tree was likely unblocked. Try
12865 var retryCache = void 0;
12866 if (enableSuspenseServerRenderer) {
12867 switch (boundaryFiber.tag) {
12868 case SuspenseComponent:
12869 retryCache = boundaryFiber.stateNode;
12870 break;
12871 case DehydratedSuspenseComponent:
12872 retryCache = boundaryFiber.memoizedState;
12873 break;
12874 default:
12875 (function () {
12876 {
12877 {
12878 throw ReactError('Pinged unknown suspense boundary type. This is probably a bug in React.');
12879 }
12880 }
12881 })();
12882 }
12883 } else {
12884 retryCache = boundaryFiber.stateNode;
12885 }
12886 if (retryCache !== null) {
12887 // The thenable resolved, so we no longer need to memoize, because it will
12888 // never be thrown again.
12889 retryCache.delete(thenable);
12890 }
12891
12892 retryTimedOutBoundary$1(boundaryFiber);
12893}
12894
12895function scheduleWorkToRoot(fiber, expirationTime) {
12896 recordScheduleUpdate();
12897
12898 {
12899 if (fiber.tag === ClassComponent) {
12900 var instance = fiber.stateNode;
12901 warnAboutInvalidUpdates(instance);
12902 }
12903 }
12904
12905 // Update the source fiber's expiration time
12906 if (fiber.expirationTime < expirationTime) {
12907 fiber.expirationTime = expirationTime;
12908 }
12909 var alternate = fiber.alternate;
12910 if (alternate !== null && alternate.expirationTime < expirationTime) {
12911 alternate.expirationTime = expirationTime;
12912 }
12913 // Walk the parent path to the root and update the child expiration time.
12914 var node = fiber.return;
12915 var root = null;
12916 if (node === null && fiber.tag === HostRoot) {
12917 root = fiber.stateNode;
12918 } else {
12919 while (node !== null) {
12920 alternate = node.alternate;
12921 if (node.childExpirationTime < expirationTime) {
12922 node.childExpirationTime = expirationTime;
12923 if (alternate !== null && alternate.childExpirationTime < expirationTime) {
12924 alternate.childExpirationTime = expirationTime;
12925 }
12926 } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
12927 alternate.childExpirationTime = expirationTime;
12928 }
12929 if (node.return === null && node.tag === HostRoot) {
12930 root = node.stateNode;
12931 break;
12932 }
12933 node = node.return;
12934 }
12935 }
12936
12937 if (enableSchedulerTracing) {
12938 if (root !== null) {
12939 var interactions = tracing.__interactionsRef.current;
12940 if (interactions.size > 0) {
12941 var pendingInteractionMap = root.pendingInteractionMap;
12942 var pendingInteractions = pendingInteractionMap.get(expirationTime);
12943 if (pendingInteractions != null) {
12944 interactions.forEach(function (interaction) {
12945 if (!pendingInteractions.has(interaction)) {
12946 // Update the pending async work count for previously unscheduled interaction.
12947 interaction.__count++;
12948 }
12949
12950 pendingInteractions.add(interaction);
12951 });
12952 } else {
12953 pendingInteractionMap.set(expirationTime, new Set(interactions));
12954
12955 // Update the pending async work count for the current interactions.
12956 interactions.forEach(function (interaction) {
12957 interaction.__count++;
12958 });
12959 }
12960
12961 var subscriber = tracing.__subscriberRef.current;
12962 if (subscriber !== null) {
12963 var threadID = computeThreadID(expirationTime, root.interactionThreadID);
12964 subscriber.onWorkScheduled(interactions, threadID);
12965 }
12966 }
12967 }
12968 }
12969 return root;
12970}
12971
12972// in a test-like environment, we want to warn if dispatchAction() is
12973// called outside of a TestUtils.act(...)/batchedUpdates/render call.
12974// so we have a a step counter for when we descend/ascend from
12975// act() calls, and test on it for when to warn
12976// It's a tuple with a single value. Look for shared/createAct to
12977// see how we change the value inside act() calls
12978
12979function warnIfNotCurrentlyActingUpdatesInDev$1(fiber) {
12980 {
12981 if (isBatchingUpdates === false && isRendering === false && ReactShouldWarnActingUpdates.current === false) {
12982 warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see in the browser." + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
12983 }
12984 }
12985}
12986
12987function scheduleWork$1(fiber, expirationTime) {
12988 var root = scheduleWorkToRoot(fiber, expirationTime);
12989 if (root === null) {
12990 {
12991 switch (fiber.tag) {
12992 case ClassComponent:
12993 warnAboutUpdateOnUnmounted(fiber, true);
12994 break;
12995 case FunctionComponent:
12996 case ForwardRef:
12997 case MemoComponent:
12998 case SimpleMemoComponent:
12999 warnAboutUpdateOnUnmounted(fiber, false);
13000 break;
13001 }
13002 }
13003 return;
13004 }
13005
13006 if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime > nextRenderExpirationTime) {
13007 // This is an interruption. (Used for performance tracking.)
13008 interruptedBy = fiber;
13009 resetStack();
13010 }
13011 markPendingPriorityLevel(root, expirationTime);
13012 if (
13013 // If we're in the render phase, we don't need to schedule this root
13014 // for an update, because we'll do it before we exit...
13015 !isWorking || isCommitting$1 ||
13016 // ...unless this is a different root than the one we're rendering.
13017 nextRoot !== root) {
13018 var rootExpirationTime = root.expirationTime;
13019 requestWork(root, rootExpirationTime);
13020 }
13021 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
13022 // Reset this back to zero so subsequent updates don't throw.
13023 nestedUpdateCount = 0;
13024 (function () {
13025 {
13026 {
13027 throw ReactError('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.');
13028 }
13029 }
13030 })();
13031 }
13032 {
13033 if (isInPassiveEffectDEV && nestedPassiveEffectCountDEV > NESTED_PASSIVE_UPDATE_LIMIT) {
13034 nestedPassiveEffectCountDEV = 0;
13035 warning$1(false, 'Maximum update depth exceeded. This can happen when a ' + 'component calls setState inside useEffect, but ' + "useEffect either doesn't have a dependency array, or " + 'one of the dependencies changes on every render.');
13036 }
13037 }
13038}
13039
13040// TODO: Everything below this is written as if it has been lifted to the
13041// renderers. I'll do this in a follow-up.
13042
13043// Linked-list of roots
13044var firstScheduledRoot = null;
13045var lastScheduledRoot = null;
13046
13047var callbackExpirationTime = NoWork;
13048var callbackID = void 0;
13049var isRendering = false;
13050var nextFlushedRoot = null;
13051var nextFlushedExpirationTime = NoWork;
13052var hasUnhandledError = false;
13053var unhandledError = null;
13054
13055var isBatchingUpdates = false;
13056var isUnbatchingUpdates = false;
13057var isBatchingInteractiveUpdates = false;
13058
13059var completedBatches = null;
13060
13061var originalStartTimeMs = now$2();
13062var currentRendererTime = msToExpirationTime(originalStartTimeMs);
13063var currentSchedulerTime = currentRendererTime;
13064
13065// Use these to prevent an infinite loop of nested updates
13066var NESTED_UPDATE_LIMIT = 50;
13067var nestedUpdateCount = 0;
13068var lastCommittedRootDuringThisBatch = null;
13069
13070// Similar, but for useEffect infinite loops. These are DEV-only.
13071var NESTED_PASSIVE_UPDATE_LIMIT = 50;
13072var nestedPassiveEffectCountDEV = void 0;
13073var isInPassiveEffectDEV = void 0;
13074{
13075 nestedPassiveEffectCountDEV = 0;
13076 isInPassiveEffectDEV = false;
13077}
13078
13079function recomputeCurrentRendererTime() {
13080 var currentTimeMs = now$2() - originalStartTimeMs;
13081 currentRendererTime = msToExpirationTime(currentTimeMs);
13082}
13083
13084function scheduleCallbackWithExpirationTime(root, expirationTime) {
13085 if (callbackExpirationTime !== NoWork) {
13086 // A callback is already scheduled. Check its expiration time (timeout).
13087 if (expirationTime < callbackExpirationTime) {
13088 // Existing callback has sufficient timeout. Exit.
13089 return;
13090 } else {
13091 if (callbackID !== null) {
13092 // Existing callback has insufficient timeout. Cancel and schedule a
13093 // new one.
13094 cancelCallback$1(callbackID);
13095 }
13096 }
13097 // The request callback timer is already running. Don't start a new one.
13098 } else {
13099 startRequestCallbackTimer();
13100 }
13101
13102 callbackExpirationTime = expirationTime;
13103 var currentMs = now$2() - originalStartTimeMs;
13104 var expirationTimeMs = expirationTimeToMs(expirationTime);
13105 var timeout = expirationTimeMs - currentMs;
13106 var priorityLevel = getCurrentPriorityLevel$1();
13107 callbackID = scheduleCallback$1(priorityLevel, performAsyncWork, { timeout: timeout });
13108}
13109
13110// For every call to renderRoot, one of onFatal, onComplete, onSuspend, and
13111// onYield is called upon exiting. We use these in lieu of returning a tuple.
13112// I've also chosen not to inline them into renderRoot because these will
13113// eventually be lifted into the renderer.
13114function onFatal(root) {
13115 root.finishedWork = null;
13116}
13117
13118function onComplete(root, finishedWork, expirationTime) {
13119 root.pendingCommitExpirationTime = expirationTime;
13120 root.finishedWork = finishedWork;
13121}
13122
13123function onSuspend(root, finishedWork, suspendedExpirationTime, rootExpirationTime, msUntilTimeout) {
13124 root.expirationTime = rootExpirationTime;
13125 if (msUntilTimeout === 0 && (disableYielding || !shouldYield$2())) {
13126 // Don't wait an additional tick. Commit the tree immediately.
13127 root.pendingCommitExpirationTime = suspendedExpirationTime;
13128 root.finishedWork = finishedWork;
13129 } else if (msUntilTimeout > 0) {
13130 // Wait `msUntilTimeout` milliseconds before committing.
13131 root.timeoutHandle = scheduleTimeout(onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), msUntilTimeout);
13132 }
13133}
13134
13135function onYield(root) {
13136 root.finishedWork = null;
13137}
13138
13139function onTimeout(root, finishedWork, suspendedExpirationTime) {
13140 // The root timed out. Commit it.
13141 root.pendingCommitExpirationTime = suspendedExpirationTime;
13142 root.finishedWork = finishedWork;
13143 // Read the current time before entering the commit phase. We can be
13144 // certain this won't cause tearing related to batching of event updates
13145 // because we're at the top of a timer event.
13146 recomputeCurrentRendererTime();
13147 currentSchedulerTime = currentRendererTime;
13148 flushRoot$1(root, suspendedExpirationTime);
13149}
13150
13151function onCommit(root, expirationTime) {
13152 root.expirationTime = expirationTime;
13153 root.finishedWork = null;
13154}
13155
13156function requestCurrentTime$1() {
13157 // requestCurrentTime is called by the scheduler to compute an expiration
13158 // time.
13159 //
13160 // Expiration times are computed by adding to the current time (the start
13161 // time). However, if two updates are scheduled within the same event, we
13162 // should treat their start times as simultaneous, even if the actual clock
13163 // time has advanced between the first and second call.
13164
13165 // In other words, because expiration times determine how updates are batched,
13166 // we want all updates of like priority that occur within the same event to
13167 // receive the same expiration time. Otherwise we get tearing.
13168 //
13169 // We keep track of two separate times: the current "renderer" time and the
13170 // current "scheduler" time. The renderer time can be updated whenever; it
13171 // only exists to minimize the calls performance.now.
13172 //
13173 // But the scheduler time can only be updated if there's no pending work, or
13174 // if we know for certain that we're not in the middle of an event.
13175
13176 if (isRendering) {
13177 // We're already rendering. Return the most recently read time.
13178 return currentSchedulerTime;
13179 }
13180 // Check if there's pending work.
13181 findHighestPriorityRoot();
13182 if (nextFlushedExpirationTime === NoWork || nextFlushedExpirationTime === Never) {
13183 // If there's no pending work, or if the pending work is offscreen, we can
13184 // read the current time without risk of tearing.
13185 recomputeCurrentRendererTime();
13186 currentSchedulerTime = currentRendererTime;
13187 return currentSchedulerTime;
13188 }
13189 // There's already pending work. We might be in the middle of a browser
13190 // event. If we were to read the current time, it could cause multiple updates
13191 // within the same event to receive different expiration times, leading to
13192 // tearing. Return the last read time. During the next idle callback, the
13193 // time will be updated.
13194 return currentSchedulerTime;
13195}
13196
13197// requestWork is called by the scheduler whenever a root receives an update.
13198// It's up to the renderer to call renderRoot at some point in the future.
13199function requestWork(root, expirationTime) {
13200 addRootToSchedule(root, expirationTime);
13201 if (isRendering) {
13202 // Prevent reentrancy. Remaining work will be scheduled at the end of
13203 // the currently rendering batch.
13204 return;
13205 }
13206
13207 if (isBatchingUpdates) {
13208 // Flush work at the end of the batch.
13209 if (isUnbatchingUpdates) {
13210 // ...unless we're inside unbatchedUpdates, in which case we should
13211 // flush it now.
13212 nextFlushedRoot = root;
13213 nextFlushedExpirationTime = Sync;
13214 performWorkOnRoot(root, Sync, false);
13215 }
13216 return;
13217 }
13218
13219 // TODO: Get rid of Sync and use current time?
13220 if (expirationTime === Sync) {
13221 performSyncWork();
13222 } else {
13223 scheduleCallbackWithExpirationTime(root, expirationTime);
13224 }
13225}
13226
13227function addRootToSchedule(root, expirationTime) {
13228 // Add the root to the schedule.
13229 // Check if this root is already part of the schedule.
13230 if (root.nextScheduledRoot === null) {
13231 // This root is not already scheduled. Add it.
13232 root.expirationTime = expirationTime;
13233 if (lastScheduledRoot === null) {
13234 firstScheduledRoot = lastScheduledRoot = root;
13235 root.nextScheduledRoot = root;
13236 } else {
13237 lastScheduledRoot.nextScheduledRoot = root;
13238 lastScheduledRoot = root;
13239 lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
13240 }
13241 } else {
13242 // This root is already scheduled, but its priority may have increased.
13243 var remainingExpirationTime = root.expirationTime;
13244 if (expirationTime > remainingExpirationTime) {
13245 // Update the priority.
13246 root.expirationTime = expirationTime;
13247 }
13248 }
13249}
13250
13251function findHighestPriorityRoot() {
13252 var highestPriorityWork = NoWork;
13253 var highestPriorityRoot = null;
13254 if (lastScheduledRoot !== null) {
13255 var previousScheduledRoot = lastScheduledRoot;
13256 var root = firstScheduledRoot;
13257 while (root !== null) {
13258 var remainingExpirationTime = root.expirationTime;
13259 if (remainingExpirationTime === NoWork) {
13260 // This root no longer has work. Remove it from the scheduler.
13261
13262 // TODO: This check is redudant, but Flow is confused by the branch
13263 // below where we set lastScheduledRoot to null, even though we break
13264 // from the loop right after.
13265 (function () {
13266 if (!(previousScheduledRoot !== null && lastScheduledRoot !== null)) {
13267 {
13268 throw ReactError('Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue.');
13269 }
13270 }
13271 })();
13272 if (root === root.nextScheduledRoot) {
13273 // This is the only root in the list.
13274 root.nextScheduledRoot = null;
13275 firstScheduledRoot = lastScheduledRoot = null;
13276 break;
13277 } else if (root === firstScheduledRoot) {
13278 // This is the first root in the list.
13279 var next = root.nextScheduledRoot;
13280 firstScheduledRoot = next;
13281 lastScheduledRoot.nextScheduledRoot = next;
13282 root.nextScheduledRoot = null;
13283 } else if (root === lastScheduledRoot) {
13284 // This is the last root in the list.
13285 lastScheduledRoot = previousScheduledRoot;
13286 lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
13287 root.nextScheduledRoot = null;
13288 break;
13289 } else {
13290 previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot;
13291 root.nextScheduledRoot = null;
13292 }
13293 root = previousScheduledRoot.nextScheduledRoot;
13294 } else {
13295 if (remainingExpirationTime > highestPriorityWork) {
13296 // Update the priority, if it's higher
13297 highestPriorityWork = remainingExpirationTime;
13298 highestPriorityRoot = root;
13299 }
13300 if (root === lastScheduledRoot) {
13301 break;
13302 }
13303 if (highestPriorityWork === Sync) {
13304 // Sync is highest priority by definition so
13305 // we can stop searching.
13306 break;
13307 }
13308 previousScheduledRoot = root;
13309 root = root.nextScheduledRoot;
13310 }
13311 }
13312 }
13313
13314 nextFlushedRoot = highestPriorityRoot;
13315 nextFlushedExpirationTime = highestPriorityWork;
13316}
13317
13318function performAsyncWork(didTimeout) {
13319 if (didTimeout) {
13320 // The callback timed out. That means at least one update has expired.
13321 // Iterate through the root schedule. If they contain expired work, set
13322 // the next render expiration time to the current time. This has the effect
13323 // of flushing all expired work in a single batch, instead of flushing each
13324 // level one at a time.
13325 if (firstScheduledRoot !== null) {
13326 recomputeCurrentRendererTime();
13327 var root = firstScheduledRoot;
13328 do {
13329 didExpireAtExpirationTime(root, currentRendererTime);
13330 // The root schedule is circular, so this is never null.
13331 root = root.nextScheduledRoot;
13332 } while (root !== firstScheduledRoot);
13333 }
13334 }
13335
13336 // Keep working on roots until there's no more work, or until there's a higher
13337 // priority event.
13338 findHighestPriorityRoot();
13339
13340 if (disableYielding) {
13341 // Just do it all
13342 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork) {
13343 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
13344 findHighestPriorityRoot();
13345 }
13346 } else {
13347 recomputeCurrentRendererTime();
13348 currentSchedulerTime = currentRendererTime;
13349
13350 if (enableUserTimingAPI) {
13351 var didExpire = nextFlushedExpirationTime > currentRendererTime;
13352 var timeout = expirationTimeToMs(nextFlushedExpirationTime);
13353 stopRequestCallbackTimer(didExpire, timeout);
13354 }
13355
13356 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && !(shouldYield$2() && currentRendererTime > nextFlushedExpirationTime)) {
13357 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, currentRendererTime > nextFlushedExpirationTime);
13358 findHighestPriorityRoot();
13359 recomputeCurrentRendererTime();
13360 currentSchedulerTime = currentRendererTime;
13361 }
13362 }
13363
13364 // We're done flushing work. Either we ran out of time in this callback,
13365 // or there's no more work left with sufficient priority.
13366
13367 // If we're inside a callback, set this to false since we just completed it.
13368 callbackExpirationTime = NoWork;
13369 callbackID = null;
13370
13371 // If there's work left over, schedule a new callback.
13372 if (nextFlushedExpirationTime !== NoWork) {
13373 scheduleCallbackWithExpirationTime(nextFlushedRoot, nextFlushedExpirationTime);
13374 }
13375
13376 // Clean-up.
13377 finishRendering();
13378}
13379
13380function performSyncWork() {
13381 performWork(Sync);
13382}
13383
13384function performWork(minExpirationTime) {
13385 // Keep working on roots until there's no more work, or until there's a higher
13386 // priority event.
13387 findHighestPriorityRoot();
13388
13389 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && minExpirationTime <= nextFlushedExpirationTime) {
13390 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
13391 findHighestPriorityRoot();
13392 }
13393
13394 // We're done flushing work. Either we ran out of time in this callback,
13395 // or there's no more work left with sufficient priority.
13396
13397 // If there's work left over, schedule a new callback.
13398 if (nextFlushedExpirationTime !== NoWork) {
13399 scheduleCallbackWithExpirationTime(nextFlushedRoot, nextFlushedExpirationTime);
13400 }
13401
13402 // Clean-up.
13403 finishRendering();
13404}
13405
13406function flushRoot$1(root, expirationTime) {
13407 (function () {
13408 if (!!isRendering) {
13409 {
13410 throw ReactError('work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method.');
13411 }
13412 }
13413 })();
13414 // Perform work on root as if the given expiration time is the current time.
13415 // This has the effect of synchronously flushing all work up to and
13416 // including the given time.
13417 nextFlushedRoot = root;
13418 nextFlushedExpirationTime = expirationTime;
13419 performWorkOnRoot(root, expirationTime, false);
13420 // Flush any sync work that was scheduled by lifecycles
13421 performSyncWork();
13422}
13423
13424function finishRendering() {
13425 nestedUpdateCount = 0;
13426 lastCommittedRootDuringThisBatch = null;
13427
13428 {
13429 if (rootWithPendingPassiveEffects === null) {
13430 nestedPassiveEffectCountDEV = 0;
13431 }
13432 }
13433
13434 if (completedBatches !== null) {
13435 var batches = completedBatches;
13436 completedBatches = null;
13437 for (var i = 0; i < batches.length; i++) {
13438 var batch = batches[i];
13439 try {
13440 batch._onComplete();
13441 } catch (error) {
13442 if (!hasUnhandledError) {
13443 hasUnhandledError = true;
13444 unhandledError = error;
13445 }
13446 }
13447 }
13448 }
13449
13450 if (hasUnhandledError) {
13451 var error = unhandledError;
13452 unhandledError = null;
13453 hasUnhandledError = false;
13454 throw error;
13455 }
13456}
13457
13458function performWorkOnRoot(root, expirationTime, isYieldy) {
13459 (function () {
13460 if (!!isRendering) {
13461 {
13462 throw ReactError('performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.');
13463 }
13464 }
13465 })();
13466
13467 isRendering = true;
13468
13469 // Check if this is async work or sync/expired work.
13470 if (!isYieldy) {
13471 // Flush work without yielding.
13472 // TODO: Non-yieldy work does not necessarily imply expired work. A renderer
13473 // may want to perform some work without yielding, but also without
13474 // requiring the root to complete (by triggering placeholders).
13475
13476 var finishedWork = root.finishedWork;
13477 if (finishedWork !== null) {
13478 // This root is already complete. We can commit it.
13479 completeRoot(root, finishedWork, expirationTime);
13480 } else {
13481 root.finishedWork = null;
13482 // If this root previously suspended, clear its existing timeout, since
13483 // we're about to try rendering again.
13484 var timeoutHandle = root.timeoutHandle;
13485 if (timeoutHandle !== noTimeout) {
13486 root.timeoutHandle = noTimeout;
13487 // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
13488 cancelTimeout(timeoutHandle);
13489 }
13490 renderRoot(root, isYieldy);
13491 finishedWork = root.finishedWork;
13492 if (finishedWork !== null) {
13493 // We've completed the root. Commit it.
13494 completeRoot(root, finishedWork, expirationTime);
13495 }
13496 }
13497 } else {
13498 // Flush async work.
13499 var _finishedWork = root.finishedWork;
13500 if (_finishedWork !== null) {
13501 // This root is already complete. We can commit it.
13502 completeRoot(root, _finishedWork, expirationTime);
13503 } else {
13504 root.finishedWork = null;
13505 // If this root previously suspended, clear its existing timeout, since
13506 // we're about to try rendering again.
13507 var _timeoutHandle = root.timeoutHandle;
13508 if (_timeoutHandle !== noTimeout) {
13509 root.timeoutHandle = noTimeout;
13510 // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
13511 cancelTimeout(_timeoutHandle);
13512 }
13513 renderRoot(root, isYieldy);
13514 _finishedWork = root.finishedWork;
13515 if (_finishedWork !== null) {
13516 // We've completed the root. Check the if we should yield one more time
13517 // before committing.
13518 if (!shouldYield$2()) {
13519 // Still time left. Commit the root.
13520 completeRoot(root, _finishedWork, expirationTime);
13521 } else {
13522 // There's no time left. Mark this root as complete. We'll come
13523 // back and commit it later.
13524 root.finishedWork = _finishedWork;
13525 }
13526 }
13527 }
13528 }
13529
13530 isRendering = false;
13531}
13532
13533function completeRoot(root, finishedWork, expirationTime) {
13534 // Check if there's a batch that matches this expiration time.
13535 var firstBatch = root.firstBatch;
13536 if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) {
13537 if (completedBatches === null) {
13538 completedBatches = [firstBatch];
13539 } else {
13540 completedBatches.push(firstBatch);
13541 }
13542 if (firstBatch._defer) {
13543 // This root is blocked from committing by a batch. Unschedule it until
13544 // we receive another update.
13545 root.finishedWork = finishedWork;
13546 root.expirationTime = NoWork;
13547 return;
13548 }
13549 }
13550
13551 // Commit the root.
13552 root.finishedWork = null;
13553
13554 // Check if this is a nested update (a sync update scheduled during the
13555 // commit phase).
13556 if (root === lastCommittedRootDuringThisBatch) {
13557 // If the next root is the same as the previous root, this is a nested
13558 // update. To prevent an infinite loop, increment the nested update count.
13559 nestedUpdateCount++;
13560 } else {
13561 // Reset whenever we switch roots.
13562 lastCommittedRootDuringThisBatch = root;
13563 nestedUpdateCount = 0;
13564 }
13565 commitRoot(root, finishedWork);
13566}
13567
13568function onUncaughtError$1(error) {
13569 (function () {
13570 if (!(nextFlushedRoot !== null)) {
13571 {
13572 throw ReactError('Should be working on a root. This error is likely caused by a bug in React. Please file an issue.');
13573 }
13574 }
13575 })();
13576 // Unschedule this root so we don't work on it again until there's
13577 // another update.
13578 nextFlushedRoot.expirationTime = NoWork;
13579 if (!hasUnhandledError) {
13580 hasUnhandledError = true;
13581 unhandledError = error;
13582 }
13583}
13584
13585// TODO: Ahaha Andrew is bad at spellling
13586// DEV stuff
13587var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher;
13588var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
13589var ReactShouldWarnActingUpdates$1 = ReactSharedInternals.ReactShouldWarnActingUpdates;
13590
13591var NotWorking = 0;
13592var LegacyUnbatchedPhase = 2;
13593var RenderPhase = 4;
13594var CommitPhase = 5;
13595
13596var RootIncomplete = 0;
13597var RootErrored = 1;
13598var RootSuspended = 2;
13599var RootCompleted = 3;
13600
13601// The phase of work we're currently in
13602var workPhase = NotWorking;
13603// The root we're working on
13604var workInProgressRoot = null;
13605// The fiber we're working on
13606var workInProgress = null;
13607// The expiration time we're rendering
13608var renderExpirationTime$1 = NoWork;
13609// Whether to root completed, errored, suspended, etc.
13610var workInProgressRootExitStatus = RootIncomplete;
13611var workInProgressRootAbsoluteTimeoutMs = -1;
13612
13613var nextEffect$1 = null;
13614var hasUncaughtError = false;
13615var firstUncaughtError = null;
13616var legacyErrorBoundariesThatAlreadyFailed$1 = null;
13617
13618var rootDoesHavePassiveEffects = false;
13619var rootWithPendingPassiveEffects$1 = null;
13620var pendingPassiveEffectsExpirationTime = NoWork;
13621
13622var rootsWithPendingDiscreteUpdates = null;
13623
13624// Use these to prevent an infinite loop of nested updates
13625var NESTED_UPDATE_LIMIT$1 = 50;
13626var nestedUpdateCount$1 = 0;
13627var rootWithNestedUpdates = null;
13628
13629var NESTED_PASSIVE_UPDATE_LIMIT$1 = 50;
13630var nestedPassiveUpdateCount = 0;
13631
13632var interruptedBy$1 = null;
13633
13634// Expiration times are computed by adding to the current time (the start
13635// time). However, if two updates are scheduled within the same event, we
13636// should treat their start times as simultaneous, even if the actual clock
13637// time has advanced between the first and second call.
13638
13639// In other words, because expiration times determine how updates are batched,
13640// we want all updates of like priority that occur within the same event to
13641// receive the same expiration time. Otherwise we get tearing.
13642var currentEventTime = NoWork;
13643
13644function requestCurrentTime$2() {
13645 if (workPhase === RenderPhase || workPhase === CommitPhase) {
13646 // We're inside React, so it's fine to read the actual time.
13647 return msToExpirationTime(now$1());
13648 }
13649 // We're not inside React, so we may be in the middle of a browser event.
13650 if (currentEventTime !== NoWork) {
13651 // Use the same start time for all updates until we enter React again.
13652 return currentEventTime;
13653 }
13654 // This is the first update since React yielded. Compute a new start time.
13655 currentEventTime = msToExpirationTime(now$1());
13656 return currentEventTime;
13657}
13658
13659function computeExpirationForFiber$2(currentTime, fiber) {
13660 if ((fiber.mode & ConcurrentMode) === NoContext) {
13661 return Sync;
13662 }
13663
13664 if (workPhase === RenderPhase) {
13665 // Use whatever time we're already rendering
13666 return renderExpirationTime$1;
13667 }
13668
13669 // Compute an expiration time based on the Scheduler priority.
13670 var expirationTime = void 0;
13671 var priorityLevel = getCurrentPriorityLevel();
13672 switch (priorityLevel) {
13673 case ImmediatePriority:
13674 expirationTime = Sync;
13675 break;
13676 case UserBlockingPriority:
13677 // TODO: Rename this to computeUserBlockingExpiration
13678 expirationTime = computeInteractiveExpiration(currentTime);
13679 break;
13680 case NormalPriority:
13681 case LowPriority:
13682 // TODO: Handle LowPriority
13683 // TODO: Rename this to... something better.
13684 expirationTime = computeAsyncExpiration(currentTime);
13685 break;
13686 case IdlePriority:
13687 expirationTime = Never;
13688 break;
13689 default:
13690 (function () {
13691 {
13692 {
13693 throw ReactError('Expected a valid priority level');
13694 }
13695 }
13696 })();
13697 }
13698
13699 // If we're in the middle of rendering a tree, do not update at the same
13700 // expiration time that is already rendering.
13701 if (workInProgressRoot !== null && expirationTime === renderExpirationTime$1) {
13702 // This is a trick to move this update into a separate batch
13703 expirationTime -= 1;
13704 }
13705
13706 return expirationTime;
13707}
13708
13709
13710
13711function scheduleUpdateOnFiber(fiber, expirationTime) {
13712 checkForNestedUpdates();
13713 warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
13714
13715 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
13716 if (root === null) {
13717 warnAboutUpdateOnUnmountedFiberInDEV(fiber);
13718 return;
13719 }
13720
13721 root.pingTime = NoWork;
13722
13723 checkForInterruption(fiber, expirationTime);
13724 recordScheduleUpdate();
13725
13726 if (expirationTime === Sync) {
13727 if (workPhase === LegacyUnbatchedPhase) {
13728 // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
13729 // root inside of batchedUpdates should be synchronous, but layout updates
13730 // should be deferred until the end of the batch.
13731 var callback = renderRoot$1(root, Sync, true);
13732 while (callback !== null) {
13733 callback = callback(true);
13734 }
13735 } else {
13736 scheduleCallbackForRoot(root, ImmediatePriority, Sync);
13737 if (workPhase === NotWorking) {
13738 // Flush the synchronous work now, wnless we're already working or inside
13739 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
13740 // scheduleCallbackForFiber to preserve the ability to schedule a callback
13741 // without immediately flushing it. We only do this for user-initated
13742 // updates, to preserve historical behavior of sync mode.
13743 flushImmediateQueue();
13744 }
13745 }
13746 } else {
13747 // TODO: computeExpirationForFiber also reads the priority. Pass the
13748 // priority as an argument to that function and this one.
13749 var priorityLevel = getCurrentPriorityLevel();
13750 if (priorityLevel === UserBlockingPriority) {
13751 // This is the result of a discrete event. Track the lowest priority
13752 // discrete update per root so we can flush them early, if needed.
13753 if (rootsWithPendingDiscreteUpdates === null) {
13754 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
13755 } else {
13756 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
13757 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
13758 rootsWithPendingDiscreteUpdates.set(root, expirationTime);
13759 }
13760 }
13761 }
13762 scheduleCallbackForRoot(root, priorityLevel, expirationTime);
13763 }
13764}
13765var scheduleWork$2 = scheduleUpdateOnFiber;
13766
13767// This is split into a separate function so we can mark a fiber with pending
13768// work without treating it as a typical update that originates from an event;
13769// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
13770// on a fiber.
13771function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
13772 // Update the source fiber's expiration time
13773 if (fiber.expirationTime < expirationTime) {
13774 fiber.expirationTime = expirationTime;
13775 }
13776 var alternate = fiber.alternate;
13777 if (alternate !== null && alternate.expirationTime < expirationTime) {
13778 alternate.expirationTime = expirationTime;
13779 }
13780 // Walk the parent path to the root and update the child expiration time.
13781 var node = fiber.return;
13782 var root = null;
13783 if (node === null && fiber.tag === HostRoot) {
13784 root = fiber.stateNode;
13785 } else {
13786 while (node !== null) {
13787 alternate = node.alternate;
13788 if (node.childExpirationTime < expirationTime) {
13789 node.childExpirationTime = expirationTime;
13790 if (alternate !== null && alternate.childExpirationTime < expirationTime) {
13791 alternate.childExpirationTime = expirationTime;
13792 }
13793 } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
13794 alternate.childExpirationTime = expirationTime;
13795 }
13796 if (node.return === null && node.tag === HostRoot) {
13797 root = node.stateNode;
13798 break;
13799 }
13800 node = node.return;
13801 }
13802 }
13803
13804 if (root !== null) {
13805 // Update the first and last pending expiration times in this root
13806 var firstPendingTime = root.firstPendingTime;
13807 if (expirationTime > firstPendingTime) {
13808 root.firstPendingTime = expirationTime;
13809 }
13810 var lastPendingTime = root.lastPendingTime;
13811 if (lastPendingTime === NoWork || expirationTime < lastPendingTime) {
13812 root.lastPendingTime = expirationTime;
13813 }
13814 }
13815
13816 return root;
13817}
13818
13819// Use this function, along with runRootCallback, to ensure that only a single
13820// callback per root is scheduled. It's still possible to call renderRoot
13821// directly, but scheduling via this function helps avoid excessive callbacks.
13822// It works by storing the callback node and expiration time on the root. When a
13823// new callback comes in, it compares the expiration time to determine if it
13824// should cancel the previous one. It also relies on commitRoot scheduling a
13825// callback to render the next level, because that means we don't need a
13826// separate callback per expiration time.
13827function scheduleCallbackForRoot(root, priorityLevel, expirationTime) {
13828 var existingCallbackExpirationTime = root.callbackExpirationTime;
13829 if (existingCallbackExpirationTime < expirationTime) {
13830 // New callback has higher priority than the existing one.
13831 var existingCallbackNode = root.callbackNode;
13832 if (existingCallbackNode !== null) {
13833 cancelCallback(existingCallbackNode);
13834 }
13835 root.callbackExpirationTime = expirationTime;
13836 var options = expirationTime === Sync ? null : { timeout: expirationTimeToMs(expirationTime) };
13837 root.callbackNode = scheduleCallback(priorityLevel, runRootCallback.bind(null, root, renderRoot$1.bind(null, root, expirationTime)), options);
13838 if (enableUserTimingAPI && expirationTime !== Sync && workPhase !== RenderPhase && workPhase !== CommitPhase) {
13839 // Scheduled an async callback, and we're not already working. Add an
13840 // entry to the flamegraph that shows we're waiting for a callback
13841 // to fire.
13842 startRequestCallbackTimer();
13843 }
13844 }
13845
13846 var timeoutHandle = root.timeoutHandle;
13847 if (timeoutHandle !== noTimeout) {
13848 // The root previous suspended and scheduled a timeout to commit a fallback
13849 // state. Now that we have additional work, cancel the timeout.
13850 root.timeoutHandle = noTimeout;
13851 // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
13852 cancelTimeout(timeoutHandle);
13853 }
13854
13855 // Add the current set of interactions to the pending set associated with
13856 // this root.
13857 schedulePendingInteraction(root, expirationTime);
13858}
13859
13860function runRootCallback(root, callback, isSync) {
13861 var prevCallbackNode = root.callbackNode;
13862 var continuation = null;
13863 try {
13864 continuation = callback(isSync);
13865 if (continuation !== null) {
13866 return runRootCallback.bind(null, root, continuation);
13867 } else {
13868 return null;
13869 }
13870 } finally {
13871 // If the callback exits without returning a continuation, remove the
13872 // corresponding callback node from the root. Unless the callback node
13873 // has changed, which implies that it was already cancelled by a high
13874 // priority update.
13875 if (continuation === null && prevCallbackNode === root.callbackNode) {
13876 root.callbackNode = null;
13877 root.callbackExpirationTime = NoWork;
13878 }
13879 }
13880}
13881
13882
13883
13884
13885
13886function resolveLocksOnRoot(root, expirationTime) {
13887 var firstBatch = root.firstBatch;
13888 if (firstBatch !== null && firstBatch._defer && firstBatch._expirationTime >= expirationTime) {
13889 root.finishedWork = root.current.alternate;
13890 root.pendingCommitExpirationTime = expirationTime;
13891 scheduleCallback(NormalPriority, function () {
13892 firstBatch._onComplete();
13893 return null;
13894 });
13895 return true;
13896 } else {
13897 return false;
13898 }
13899}
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915function prepareFreshStack(root, expirationTime) {
13916 root.pendingCommitExpirationTime = NoWork;
13917
13918 if (workInProgress !== null) {
13919 var interruptedWork = workInProgress.return;
13920 while (interruptedWork !== null) {
13921 unwindInterruptedWork(interruptedWork);
13922 interruptedWork = interruptedWork.return;
13923 }
13924 }
13925 workInProgressRoot = root;
13926 workInProgress = createWorkInProgress(root.current, null, expirationTime);
13927 renderExpirationTime$1 = expirationTime;
13928 workInProgressRootExitStatus = RootIncomplete;
13929 workInProgressRootAbsoluteTimeoutMs = -1;
13930
13931 {
13932 ReactStrictModeWarnings.discardPendingWarnings();
13933 }
13934}
13935
13936function renderRoot$1(root, expirationTime, isSync) {
13937 (function () {
13938 if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) {
13939 {
13940 throw ReactError('Should not already be working.');
13941 }
13942 }
13943 })();
13944
13945 if (enableUserTimingAPI && expirationTime !== Sync) {
13946 var didExpire = isSync;
13947 var timeoutMs = expirationTimeToMs(expirationTime);
13948 stopRequestCallbackTimer(didExpire, timeoutMs);
13949 }
13950
13951 if (root.firstPendingTime < expirationTime) {
13952 // If there's no work left at this expiration time, exit immediately. This
13953 // happens when multiple callbacks are scheduled for a single root, but an
13954 // earlier callback flushes the work of a later one.
13955 return null;
13956 }
13957
13958 if (root.pendingCommitExpirationTime === expirationTime) {
13959 // There's already a pending commit at this expiration time.
13960 root.pendingCommitExpirationTime = NoWork;
13961 return commitRoot$1.bind(null, root, expirationTime);
13962 }
13963
13964 flushPassiveEffects$2();
13965
13966 // If the root or expiration time have changed, throw out the existing stack
13967 // and prepare a fresh one. Otherwise we'll continue where we left off.
13968 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) {
13969 prepareFreshStack(root, expirationTime);
13970 startWorkOnPendingInteraction(root, expirationTime);
13971 }
13972
13973 // If we have a work-in-progress fiber, it means there's still work to do
13974 // in this root.
13975 if (workInProgress !== null) {
13976 var prevWorkPhase = workPhase;
13977 workPhase = RenderPhase;
13978 var prevDispatcher = ReactCurrentDispatcher$2.current;
13979 if (prevDispatcher === null) {
13980 // The React isomorphic package does not include a default dispatcher.
13981 // Instead the first renderer will lazily attach one, in order to give
13982 // nicer error messages.
13983 prevDispatcher = ContextOnlyDispatcher;
13984 }
13985 ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
13986 var prevInteractions = null;
13987 if (enableSchedulerTracing) {
13988 prevInteractions = tracing.__interactionsRef.current;
13989 tracing.__interactionsRef.current = root.memoizedInteractions;
13990 }
13991
13992 startWorkLoopTimer(workInProgress);
13993 do {
13994 try {
13995 if (isSync) {
13996 if (expirationTime !== Sync) {
13997 // An async update expired. There may be other expired updates on
13998 // this root. We should render all the expired work in a
13999 // single batch.
14000 var currentTime = requestCurrentTime$2();
14001 if (currentTime < expirationTime) {
14002 // Restart at the current time.
14003 workPhase = prevWorkPhase;
14004 ReactCurrentDispatcher$2.current = prevDispatcher;
14005 return renderRoot$1.bind(null, root, currentTime);
14006 }
14007 }
14008 workLoopSync();
14009 } else {
14010 // Since we know we're in a React event, we can clear the current
14011 // event time. The next update will compute a new event time.
14012 currentEventTime = NoWork;
14013 workLoop$1();
14014 }
14015 break;
14016 } catch (thrownValue) {
14017 // Reset module-level state that was set during the render phase.
14018 resetContextDependences();
14019 resetHooks();
14020
14021 var sourceFiber = workInProgress;
14022 if (sourceFiber === null || sourceFiber.return === null) {
14023 // Expected to be working on a non-root fiber. This is a fatal error
14024 // because there's no ancestor that can handle it; the root is
14025 // supposed to capture all errors that weren't caught by an error
14026 // boundary.
14027 prepareFreshStack(root, expirationTime);
14028 workPhase = prevWorkPhase;
14029 throw thrownValue;
14030 }
14031
14032 if (enableProfilerTimer && sourceFiber.mode & ProfileMode) {
14033 // Record the time spent rendering before an error was thrown. This
14034 // avoids inaccurate Profiler durations in the case of a
14035 // suspended render.
14036 stopProfilerTimerIfRunningAndRecordDelta(sourceFiber, true);
14037 }
14038
14039 var returnFiber = sourceFiber.return;
14040 throwException(root, returnFiber, sourceFiber, thrownValue, renderExpirationTime$1);
14041 workInProgress = completeUnitOfWork$1(sourceFiber);
14042 }
14043 } while (true);
14044
14045 workPhase = prevWorkPhase;
14046 resetContextDependences();
14047 ReactCurrentDispatcher$2.current = prevDispatcher;
14048 if (enableSchedulerTracing) {
14049 tracing.__interactionsRef.current = prevInteractions;
14050 }
14051
14052 if (workInProgress !== null) {
14053 // There's still work left over. Return a continuation.
14054 stopInterruptedWorkLoopTimer();
14055 if (expirationTime !== Sync) {
14056 startRequestCallbackTimer();
14057 }
14058 return renderRoot$1.bind(null, root, expirationTime);
14059 }
14060 }
14061
14062 // We now have a consistent tree. The next step is either to commit it, or, if
14063 // something suspended, wait to commit it after a timeout.
14064 stopFinishedWorkLoopTimer();
14065
14066 var isLocked = resolveLocksOnRoot(root, expirationTime);
14067 if (isLocked) {
14068 // This root has a lock that prevents it from committing. Exit. If we begin
14069 // work on the root again, without any intervening updates, it will finish
14070 // without doing additional work.
14071 return null;
14072 }
14073
14074 // Set this to null to indicate there's no in-progress render.
14075 workInProgressRoot = null;
14076
14077 switch (workInProgressRootExitStatus) {
14078 case RootIncomplete:
14079 {
14080 (function () {
14081 {
14082 {
14083 throw ReactError('Should have a work-in-progress.');
14084 }
14085 }
14086 })();
14087 }
14088 // Flow knows about invariant, so it compains if I add a break statement,
14089 // but eslint doesn't know about invariant, so it complains if I do.
14090 // eslint-disable-next-line no-fallthrough
14091 case RootErrored:
14092 {
14093 // An error was thrown. First check if there is lower priority work
14094 // scheduled on this root.
14095 var lastPendingTime = root.lastPendingTime;
14096 if (root.lastPendingTime < expirationTime) {
14097 // There's lower priority work. Before raising the error, try rendering
14098 // at the lower priority to see if it fixes it. Use a continuation to
14099 // maintain the existing priority and position in the queue.
14100 return renderRoot$1.bind(null, root, lastPendingTime);
14101 }
14102 if (!isSync) {
14103 // If we're rendering asynchronously, it's possible the error was
14104 // caused by tearing due to a mutation during an event. Try rendering
14105 // one more time without yiedling to events.
14106 prepareFreshStack(root, expirationTime);
14107 scheduleCallback(ImmediatePriority, renderRoot$1.bind(null, root, expirationTime));
14108 return null;
14109 }
14110 // If we're already rendering synchronously, commit the root in its
14111 // errored state.
14112 return commitRoot$1.bind(null, root, expirationTime);
14113 }
14114 case RootSuspended:
14115 {
14116 var _lastPendingTime = root.lastPendingTime;
14117 if (root.lastPendingTime < expirationTime) {
14118 // There's lower priority work. It might be unsuspended. Try rendering
14119 // at that level.
14120 return renderRoot$1.bind(null, root, _lastPendingTime);
14121 }
14122 if (!isSync) {
14123 var msUntilTimeout = computeMsUntilTimeout(root, workInProgressRootAbsoluteTimeoutMs);
14124 if (msUntilTimeout > 0) {
14125 // The render is suspended, it hasn't timed out, and there's no lower
14126 // priority work to do. Instead of committing the fallback
14127 // immediately, wait for more data to arrive.
14128 root.timeoutHandle = scheduleTimeout(commitRoot$1.bind(null, root, expirationTime), msUntilTimeout);
14129 return null;
14130 }
14131 }
14132 // The work expired. Commit immediately.
14133 return commitRoot$1.bind(null, root, expirationTime);
14134 }
14135 case RootCompleted:
14136 {
14137 // The work completed. Ready to commit.
14138 return commitRoot$1.bind(null, root, expirationTime);
14139 }
14140 default:
14141 {
14142 (function () {
14143 {
14144 {
14145 throw ReactError('Unknown root exit status.');
14146 }
14147 }
14148 })();
14149 }
14150 }
14151}
14152
14153function renderDidSuspend$2(root, absoluteTimeoutMs,
14154// TODO: Don't need this argument anymore
14155suspendedTime) {
14156 if (absoluteTimeoutMs >= 0 && workInProgressRootAbsoluteTimeoutMs < absoluteTimeoutMs) {
14157 workInProgressRootAbsoluteTimeoutMs = absoluteTimeoutMs;
14158 if (workInProgressRootExitStatus === RootIncomplete) {
14159 workInProgressRootExitStatus = RootSuspended;
14160 }
14161 }
14162}
14163
14164function renderDidError$2() {
14165 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
14166 workInProgressRootExitStatus = RootErrored;
14167 }
14168}
14169
14170function workLoopSync() {
14171 // Already timed out, so perform work without checking if we need to yield.
14172 while (workInProgress !== null) {
14173 workInProgress = performUnitOfWork$1(workInProgress);
14174 }
14175}
14176
14177function workLoop$1() {
14178 // Perform work until Scheduler asks us to yield
14179 while (workInProgress !== null && !shouldYield$1()) {
14180 workInProgress = performUnitOfWork$1(workInProgress);
14181 }
14182}
14183
14184function performUnitOfWork$1(unitOfWork) {
14185 // The current, flushed, state of this fiber is the alternate. Ideally
14186 // nothing should rely on this, but relying on it here means that we don't
14187 // need an additional field on the work in progress.
14188 var current$$1 = unitOfWork.alternate;
14189
14190 startWorkTimer(unitOfWork);
14191 setCurrentFiber(unitOfWork);
14192
14193 var next = void 0;
14194 if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoContext) {
14195 startProfilerTimer(unitOfWork);
14196 next = beginWork$1(current$$1, unitOfWork, renderExpirationTime$1);
14197 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
14198 } else {
14199 next = beginWork$1(current$$1, unitOfWork, renderExpirationTime$1);
14200 }
14201
14202 resetCurrentFiber();
14203 unitOfWork.memoizedProps = unitOfWork.pendingProps;
14204 if (next === null) {
14205 // If this doesn't spawn new work, complete the current work.
14206 next = completeUnitOfWork$1(unitOfWork);
14207 }
14208
14209 ReactCurrentOwner$3.current = null;
14210 return next;
14211}
14212
14213function completeUnitOfWork$1(unitOfWork) {
14214 // Attempt to complete the current unit of work, then move to the next
14215 // sibling. If there are no more siblings, return to the parent fiber.
14216 workInProgress = unitOfWork;
14217 do {
14218 // The current, flushed, state of this fiber is the alternate. Ideally
14219 // nothing should rely on this, but relying on it here means that we don't
14220 // need an additional field on the work in progress.
14221 var current$$1 = workInProgress.alternate;
14222 var returnFiber = workInProgress.return;
14223
14224 // Check if the work completed or if something threw.
14225 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
14226 setCurrentFiber(workInProgress);
14227 var next = void 0;
14228 if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoContext) {
14229 next = completeWork(current$$1, workInProgress, renderExpirationTime$1);
14230 } else {
14231 startProfilerTimer(workInProgress);
14232 next = completeWork(current$$1, workInProgress, renderExpirationTime$1);
14233 // Update render duration assuming we didn't error.
14234 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
14235 }
14236 stopWorkTimer(workInProgress);
14237 resetCurrentFiber();
14238 resetChildExpirationTime$1(workInProgress);
14239
14240 if (next !== null) {
14241 // Completing this fiber spawned new work. Work on that next.
14242 return next;
14243 }
14244
14245 if (returnFiber !== null &&
14246 // Do not append effects to parents if a sibling failed to complete
14247 (returnFiber.effectTag & Incomplete) === NoEffect) {
14248 // Append all the effects of the subtree and this fiber onto the effect
14249 // list of the parent. The completion order of the children affects the
14250 // side-effect order.
14251 if (returnFiber.firstEffect === null) {
14252 returnFiber.firstEffect = workInProgress.firstEffect;
14253 }
14254 if (workInProgress.lastEffect !== null) {
14255 if (returnFiber.lastEffect !== null) {
14256 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
14257 }
14258 returnFiber.lastEffect = workInProgress.lastEffect;
14259 }
14260
14261 // If this fiber had side-effects, we append it AFTER the children's
14262 // side-effects. We can perform certain side-effects earlier if needed,
14263 // by doing multiple passes over the effect list. We don't want to
14264 // schedule our own side-effect on our own list because if end up
14265 // reusing children we'll schedule this effect onto itself since we're
14266 // at the end.
14267 var effectTag = workInProgress.effectTag;
14268
14269 // Skip both NoWork and PerformedWork tags when creating the effect
14270 // list. PerformedWork effect is read by React DevTools but shouldn't be
14271 // committed.
14272 if (effectTag > PerformedWork) {
14273 if (returnFiber.lastEffect !== null) {
14274 returnFiber.lastEffect.nextEffect = workInProgress;
14275 } else {
14276 returnFiber.firstEffect = workInProgress;
14277 }
14278 returnFiber.lastEffect = workInProgress;
14279 }
14280 }
14281 } else {
14282 // This fiber did not complete because something threw. Pop values off
14283 // the stack without entering the complete phase. If this is a boundary,
14284 // capture values if possible.
14285 var _next = unwindWork(workInProgress, renderExpirationTime$1);
14286
14287 // Because this fiber did not complete, don't reset its expiration time.
14288
14289 if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoContext) {
14290 // Record the render duration for the fiber that errored.
14291 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
14292
14293 // Include the time spent working on failed children before continuing.
14294 var actualDuration = workInProgress.actualDuration;
14295 var child = workInProgress.child;
14296 while (child !== null) {
14297 actualDuration += child.actualDuration;
14298 child = child.sibling;
14299 }
14300 workInProgress.actualDuration = actualDuration;
14301 }
14302
14303 if (_next !== null) {
14304 // If completing this work spawned new work, do that next. We'll come
14305 // back here again.
14306 // Since we're restarting, remove anything that is not a host effect
14307 // from the effect tag.
14308 // TODO: The name stopFailedWorkTimer is misleading because Suspense
14309 // also captures and restarts.
14310 stopFailedWorkTimer(workInProgress);
14311 _next.effectTag &= HostEffectMask;
14312 return _next;
14313 }
14314 stopWorkTimer(workInProgress);
14315
14316 if (returnFiber !== null) {
14317 // Mark the parent fiber as incomplete and clear its effect list.
14318 returnFiber.firstEffect = returnFiber.lastEffect = null;
14319 returnFiber.effectTag |= Incomplete;
14320 }
14321 }
14322
14323 var siblingFiber = workInProgress.sibling;
14324 if (siblingFiber !== null) {
14325 // If there is more work to do in this returnFiber, do that next.
14326 return siblingFiber;
14327 }
14328 // Otherwise, return to the parent
14329 workInProgress = returnFiber;
14330 } while (workInProgress !== null);
14331
14332 // We've reached the root.
14333 if (workInProgressRootExitStatus === RootIncomplete) {
14334 workInProgressRootExitStatus = RootCompleted;
14335 }
14336 return null;
14337}
14338
14339function resetChildExpirationTime$1(completedWork) {
14340 if (renderExpirationTime$1 !== Never && completedWork.childExpirationTime === Never) {
14341 // The children of this component are hidden. Don't bubble their
14342 // expiration times.
14343 return;
14344 }
14345
14346 var newChildExpirationTime = NoWork;
14347
14348 // Bubble up the earliest expiration time.
14349 if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoContext) {
14350 // In profiling mode, resetChildExpirationTime is also used to reset
14351 // profiler durations.
14352 var actualDuration = completedWork.actualDuration;
14353 var treeBaseDuration = completedWork.selfBaseDuration;
14354
14355 // When a fiber is cloned, its actualDuration is reset to 0. This value will
14356 // only be updated if work is done on the fiber (i.e. it doesn't bailout).
14357 // When work is done, it should bubble to the parent's actualDuration. If
14358 // the fiber has not been cloned though, (meaning no work was done), then
14359 // this value will reflect the amount of time spent working on a previous
14360 // render. In that case it should not bubble. We determine whether it was
14361 // cloned by comparing the child pointer.
14362 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
14363
14364 var child = completedWork.child;
14365 while (child !== null) {
14366 var childUpdateExpirationTime = child.expirationTime;
14367 var childChildExpirationTime = child.childExpirationTime;
14368 if (childUpdateExpirationTime > newChildExpirationTime) {
14369 newChildExpirationTime = childUpdateExpirationTime;
14370 }
14371 if (childChildExpirationTime > newChildExpirationTime) {
14372 newChildExpirationTime = childChildExpirationTime;
14373 }
14374 if (shouldBubbleActualDurations) {
14375 actualDuration += child.actualDuration;
14376 }
14377 treeBaseDuration += child.treeBaseDuration;
14378 child = child.sibling;
14379 }
14380 completedWork.actualDuration = actualDuration;
14381 completedWork.treeBaseDuration = treeBaseDuration;
14382 } else {
14383 var _child = completedWork.child;
14384 while (_child !== null) {
14385 var _childUpdateExpirationTime = _child.expirationTime;
14386 var _childChildExpirationTime = _child.childExpirationTime;
14387 if (_childUpdateExpirationTime > newChildExpirationTime) {
14388 newChildExpirationTime = _childUpdateExpirationTime;
14389 }
14390 if (_childChildExpirationTime > newChildExpirationTime) {
14391 newChildExpirationTime = _childChildExpirationTime;
14392 }
14393 _child = _child.sibling;
14394 }
14395 }
14396
14397 completedWork.childExpirationTime = newChildExpirationTime;
14398}
14399
14400function commitRoot$1(root, expirationTime) {
14401 runWithPriority(ImmediatePriority, commitRootImpl.bind(null, root, expirationTime));
14402 // If there are passive effects, schedule a callback to flush them. This goes
14403 // outside commitRootImpl so that it inherits the priority of the render.
14404 if (rootWithPendingPassiveEffects$1 !== null) {
14405 var priorityLevel = getCurrentPriorityLevel();
14406 scheduleCallback(priorityLevel, function () {
14407 flushPassiveEffects$2();
14408 return null;
14409 });
14410 }
14411 return null;
14412}
14413
14414function commitRootImpl(root, expirationTime) {
14415 flushPassiveEffects$2();
14416 flushRenderPhaseStrictModeWarningsInDEV();
14417
14418 (function () {
14419 if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) {
14420 {
14421 throw ReactError('Should not already be working.');
14422 }
14423 }
14424 })();
14425 var finishedWork = root.current.alternate;
14426 (function () {
14427 if (!(finishedWork !== null)) {
14428 {
14429 throw ReactError('Should have a work-in-progress root.');
14430 }
14431 }
14432 })();
14433
14434 // commitRoot never returns a continuation; it always finishes synchronously.
14435 // So we can clear these now to allow a new callback to be scheduled.
14436 root.callbackNode = null;
14437 root.callbackExpirationTime = NoWork;
14438
14439 startCommitTimer();
14440
14441 // Update the first and last pending times on this root. The new first
14442 // pending time is whatever is left on the root fiber.
14443 var updateExpirationTimeBeforeCommit = finishedWork.expirationTime;
14444 var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime;
14445 var firstPendingTimeBeforeCommit = childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit;
14446 root.firstPendingTime = firstPendingTimeBeforeCommit;
14447 if (firstPendingTimeBeforeCommit < root.lastPendingTime) {
14448 // This usually means we've finished all the work, but it can also happen
14449 // when something gets downprioritized during render, like a hidden tree.
14450 root.lastPendingTime = firstPendingTimeBeforeCommit;
14451 }
14452
14453 if (root === workInProgressRoot) {
14454 // We can reset these now that they are finished.
14455 workInProgressRoot = null;
14456 workInProgress = null;
14457 renderExpirationTime$1 = NoWork;
14458 } else {}
14459 // This indicates that the last root we worked on is not the same one that
14460 // we're committing now. This most commonly happens when a suspended root
14461 // times out.
14462
14463
14464 // Get the list of effects.
14465 var firstEffect = void 0;
14466 if (finishedWork.effectTag > PerformedWork) {
14467 // A fiber's effect list consists only of its children, not itself. So if
14468 // the root has an effect, we need to add it to the end of the list. The
14469 // resulting list is the set that would belong to the root's parent, if it
14470 // had one; that is, all the effects in the tree including the root.
14471 if (finishedWork.lastEffect !== null) {
14472 finishedWork.lastEffect.nextEffect = finishedWork;
14473 firstEffect = finishedWork.firstEffect;
14474 } else {
14475 firstEffect = finishedWork;
14476 }
14477 } else {
14478 // There is no effect on the root.
14479 firstEffect = finishedWork.firstEffect;
14480 }
14481
14482 if (firstEffect !== null) {
14483 var prevWorkPhase = workPhase;
14484 workPhase = CommitPhase;
14485 var prevInteractions = null;
14486 if (enableSchedulerTracing) {
14487 prevInteractions = tracing.__interactionsRef.current;
14488 tracing.__interactionsRef.current = root.memoizedInteractions;
14489 }
14490
14491 // Reset this to null before calling lifecycles
14492 ReactCurrentOwner$3.current = null;
14493
14494 // The commit phase is broken into several sub-phases. We do a separate pass
14495 // of the effect list for each phase: all mutation effects come before all
14496 // layout effects, and so on.
14497
14498 // The first phase a "before mutation" phase. We use this phase to read the
14499 // state of the host tree right before we mutate it. This is where
14500 // getSnapshotBeforeUpdate is called.
14501 startCommitSnapshotEffectsTimer();
14502 prepareForCommit(root.containerInfo);
14503 nextEffect$1 = firstEffect;
14504 do {
14505 {
14506 invokeGuardedCallback(null, commitBeforeMutationEffects, null);
14507 if (hasCaughtError()) {
14508 (function () {
14509 if (!(nextEffect$1 !== null)) {
14510 {
14511 throw ReactError('Should be working on an effect.');
14512 }
14513 }
14514 })();
14515 var error = clearCaughtError();
14516 captureCommitPhaseError$2(nextEffect$1, error);
14517 nextEffect$1 = nextEffect$1.nextEffect;
14518 }
14519 }
14520 } while (nextEffect$1 !== null);
14521 stopCommitSnapshotEffectsTimer();
14522
14523 if (enableProfilerTimer) {
14524 // Mark the current commit time to be shared by all Profilers in this
14525 // batch. This enables them to be grouped later.
14526 recordCommitTime();
14527 }
14528
14529 // The next phase is the mutation phase, where we mutate the host tree.
14530 startCommitHostEffectsTimer();
14531 nextEffect$1 = firstEffect;
14532 do {
14533 {
14534 invokeGuardedCallback(null, commitMutationEffects, null);
14535 if (hasCaughtError()) {
14536 (function () {
14537 if (!(nextEffect$1 !== null)) {
14538 {
14539 throw ReactError('Should be working on an effect.');
14540 }
14541 }
14542 })();
14543 var _error = clearCaughtError();
14544 captureCommitPhaseError$2(nextEffect$1, _error);
14545 nextEffect$1 = nextEffect$1.nextEffect;
14546 }
14547 }
14548 } while (nextEffect$1 !== null);
14549 stopCommitHostEffectsTimer();
14550 resetAfterCommit(root.containerInfo);
14551
14552 // The work-in-progress tree is now the current tree. This must come after
14553 // the mutation phase, so that the previous tree is still current during
14554 // componentWillUnmount, but before the layout phase, so that the finished
14555 // work is current during componentDidMount/Update.
14556 root.current = finishedWork;
14557
14558 // The next phase is the layout phase, where we call effects that read
14559 // the host tree after it's been mutated. The idiomatic use case for this is
14560 // layout, but class component lifecycles also fire here for legacy reasons.
14561 startCommitLifeCyclesTimer();
14562 nextEffect$1 = firstEffect;
14563 do {
14564 {
14565 invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
14566 if (hasCaughtError()) {
14567 (function () {
14568 if (!(nextEffect$1 !== null)) {
14569 {
14570 throw ReactError('Should be working on an effect.');
14571 }
14572 }
14573 })();
14574 var _error2 = clearCaughtError();
14575 captureCommitPhaseError$2(nextEffect$1, _error2);
14576 nextEffect$1 = nextEffect$1.nextEffect;
14577 }
14578 }
14579 } while (nextEffect$1 !== null);
14580 stopCommitLifeCyclesTimer();
14581
14582 nextEffect$1 = null;
14583
14584 if (enableSchedulerTracing) {
14585 tracing.__interactionsRef.current = prevInteractions;
14586 }
14587 workPhase = prevWorkPhase;
14588 } else {
14589 // No effects.
14590 root.current = finishedWork;
14591 // Measure these anyway so the flamegraph explicitly shows that there were
14592 // no effects.
14593 // TODO: Maybe there's a better way to report this.
14594 startCommitSnapshotEffectsTimer();
14595 stopCommitSnapshotEffectsTimer();
14596 if (enableProfilerTimer) {
14597 recordCommitTime();
14598 }
14599 startCommitHostEffectsTimer();
14600 stopCommitHostEffectsTimer();
14601 startCommitLifeCyclesTimer();
14602 stopCommitLifeCyclesTimer();
14603 }
14604
14605 stopCommitTimer();
14606
14607 if (rootDoesHavePassiveEffects) {
14608 // This commit has passive effects. Stash a reference to them. But don't
14609 // schedule a callback until after flushing layout work.
14610 rootDoesHavePassiveEffects = false;
14611 rootWithPendingPassiveEffects$1 = root;
14612 pendingPassiveEffectsExpirationTime = expirationTime;
14613 } else {
14614 if (enableSchedulerTracing) {
14615 // If there are no passive effects, then we can complete the pending
14616 // interactions. Otherwise, we'll wait until after the passive effects
14617 // are flushed.
14618 finishPendingInteractions(root, expirationTime);
14619 }
14620 }
14621
14622 // Check if there's remaining work on this root
14623 var remainingExpirationTime = root.firstPendingTime;
14624 if (remainingExpirationTime !== NoWork) {
14625 var currentTime = requestCurrentTime$2();
14626 var priorityLevel = inferPriorityFromExpirationTime(currentTime, remainingExpirationTime);
14627 scheduleCallbackForRoot(root, priorityLevel, remainingExpirationTime);
14628 } else {
14629 // If there's no remaining work, we can clear the set of already failed
14630 // error boundaries.
14631 legacyErrorBoundariesThatAlreadyFailed$1 = null;
14632 }
14633
14634 onCommitRoot(finishedWork.stateNode);
14635
14636 if (remainingExpirationTime === Sync) {
14637 // Count the number of times the root synchronously re-renders without
14638 // finishing. If there are too many, it indicates an infinite update loop.
14639 if (root === rootWithNestedUpdates) {
14640 nestedUpdateCount$1++;
14641 } else {
14642 nestedUpdateCount$1 = 0;
14643 rootWithNestedUpdates = root;
14644 }
14645 } else {
14646 nestedUpdateCount$1 = 0;
14647 }
14648
14649 if (hasUncaughtError) {
14650 hasUncaughtError = false;
14651 var _error3 = firstUncaughtError;
14652 firstUncaughtError = null;
14653 throw _error3;
14654 }
14655
14656 if (workPhase === LegacyUnbatchedPhase) {
14657 // This is a legacy edge case. We just committed the initial mount of
14658 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
14659 // synchronously, but layout updates should be deferred until the end
14660 // of the batch.
14661 return null;
14662 }
14663
14664 // If layout work was scheduled, flush it now.
14665 flushImmediateQueue();
14666 return null;
14667}
14668
14669function commitBeforeMutationEffects() {
14670 while (nextEffect$1 !== null) {
14671 if ((nextEffect$1.effectTag & Snapshot) !== NoEffect) {
14672 setCurrentFiber(nextEffect$1);
14673 recordEffect();
14674
14675 var current$$1 = nextEffect$1.alternate;
14676 commitBeforeMutationLifeCycles(current$$1, nextEffect$1);
14677
14678 resetCurrentFiber();
14679 }
14680 nextEffect$1 = nextEffect$1.nextEffect;
14681 }
14682}
14683
14684function commitMutationEffects() {
14685 // TODO: Should probably move the bulk of this function to commitWork.
14686 while (nextEffect$1 !== null) {
14687 setCurrentFiber(nextEffect$1);
14688
14689 var effectTag = nextEffect$1.effectTag;
14690
14691 if (effectTag & ContentReset) {
14692 commitResetTextContent(nextEffect$1);
14693 }
14694
14695 if (effectTag & Ref) {
14696 var current$$1 = nextEffect$1.alternate;
14697 if (current$$1 !== null) {
14698 commitDetachRef(current$$1);
14699 }
14700 }
14701
14702 // The following switch statement is only concerned about placement,
14703 // updates, and deletions. To avoid needing to add a case for every possible
14704 // bitmap value, we remove the secondary effects from the effect tag and
14705 // switch on that value.
14706 var primaryEffectTag = effectTag & (Placement | Update | Deletion);
14707 switch (primaryEffectTag) {
14708 case Placement:
14709 {
14710 commitPlacement(nextEffect$1);
14711 // Clear the "placement" from effect tag so that we know that this is
14712 // inserted, before any life-cycles like componentDidMount gets called.
14713 // TODO: findDOMNode doesn't rely on this any more but isMounted does
14714 // and isMounted is deprecated anyway so we should be able to kill this.
14715 nextEffect$1.effectTag &= ~Placement;
14716 break;
14717 }
14718 case PlacementAndUpdate:
14719 {
14720 // Placement
14721 commitPlacement(nextEffect$1);
14722 // Clear the "placement" from effect tag so that we know that this is
14723 // inserted, before any life-cycles like componentDidMount gets called.
14724 nextEffect$1.effectTag &= ~Placement;
14725
14726 // Update
14727 var _current = nextEffect$1.alternate;
14728 commitWork(_current, nextEffect$1);
14729 break;
14730 }
14731 case Update:
14732 {
14733 var _current2 = nextEffect$1.alternate;
14734 commitWork(_current2, nextEffect$1);
14735 break;
14736 }
14737 case Deletion:
14738 {
14739 commitDeletion(nextEffect$1);
14740 break;
14741 }
14742 }
14743
14744 // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
14745 recordEffect();
14746
14747 resetCurrentFiber();
14748 nextEffect$1 = nextEffect$1.nextEffect;
14749 }
14750}
14751
14752function commitLayoutEffects(root, committedExpirationTime) {
14753 // TODO: Should probably move the bulk of this function to commitWork.
14754 while (nextEffect$1 !== null) {
14755 setCurrentFiber(nextEffect$1);
14756
14757 var effectTag = nextEffect$1.effectTag;
14758
14759 if (effectTag & (Update | Callback)) {
14760 recordEffect();
14761 var current$$1 = nextEffect$1.alternate;
14762 commitLifeCycles(root, current$$1, nextEffect$1, committedExpirationTime);
14763 }
14764
14765 if (effectTag & Ref) {
14766 recordEffect();
14767 commitAttachRef(nextEffect$1);
14768 }
14769
14770 if (effectTag & Passive) {
14771 rootDoesHavePassiveEffects = true;
14772 }
14773
14774 resetCurrentFiber();
14775 nextEffect$1 = nextEffect$1.nextEffect;
14776 }
14777}
14778
14779function flushPassiveEffects$2() {
14780 if (rootWithPendingPassiveEffects$1 === null) {
14781 return false;
14782 }
14783 var root = rootWithPendingPassiveEffects$1;
14784 var expirationTime = pendingPassiveEffectsExpirationTime;
14785 rootWithPendingPassiveEffects$1 = null;
14786 pendingPassiveEffectsExpirationTime = NoWork;
14787
14788 var prevInteractions = null;
14789 if (enableSchedulerTracing) {
14790 prevInteractions = tracing.__interactionsRef.current;
14791 tracing.__interactionsRef.current = root.memoizedInteractions;
14792 }
14793
14794 (function () {
14795 if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) {
14796 {
14797 throw ReactError('Cannot flush passive effects while already rendering.');
14798 }
14799 }
14800 })();
14801 var prevWorkPhase = workPhase;
14802 workPhase = CommitPhase;
14803
14804 // Note: This currently assumes there are no passive effects on the root
14805 // fiber, because the root is not part of its own effect list. This could
14806 // change in the future.
14807 var effect = root.current.firstEffect;
14808 while (effect !== null) {
14809 {
14810 setCurrentFiber(effect);
14811 invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
14812 if (hasCaughtError()) {
14813 (function () {
14814 if (!(effect !== null)) {
14815 {
14816 throw ReactError('Should be working on an effect.');
14817 }
14818 }
14819 })();
14820 var error = clearCaughtError();
14821 captureCommitPhaseError$2(effect, error);
14822 }
14823 resetCurrentFiber();
14824 }
14825 effect = effect.nextEffect;
14826 }
14827
14828 if (enableSchedulerTracing) {
14829 tracing.__interactionsRef.current = prevInteractions;
14830 finishPendingInteractions(root, expirationTime);
14831 }
14832
14833 workPhase = prevWorkPhase;
14834 flushImmediateQueue();
14835
14836 // If additional passive effects were scheduled, increment a counter. If this
14837 // exceeds the limit, we'll fire a warning.
14838 nestedPassiveUpdateCount = rootWithPendingPassiveEffects$1 === null ? 0 : nestedPassiveUpdateCount + 1;
14839
14840 return true;
14841}
14842
14843function isAlreadyFailedLegacyErrorBoundary$2(instance) {
14844 return legacyErrorBoundariesThatAlreadyFailed$1 !== null && legacyErrorBoundariesThatAlreadyFailed$1.has(instance);
14845}
14846
14847function markLegacyErrorBoundaryAsFailed$2(instance) {
14848 if (legacyErrorBoundariesThatAlreadyFailed$1 === null) {
14849 legacyErrorBoundariesThatAlreadyFailed$1 = new Set([instance]);
14850 } else {
14851 legacyErrorBoundariesThatAlreadyFailed$1.add(instance);
14852 }
14853}
14854
14855function prepareToThrowUncaughtError(error) {
14856 if (!hasUncaughtError) {
14857 hasUncaughtError = true;
14858 firstUncaughtError = error;
14859 }
14860}
14861var onUncaughtError$2 = prepareToThrowUncaughtError;
14862
14863function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
14864 var errorInfo = createCapturedValue(error, sourceFiber);
14865 var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
14866 enqueueUpdate(rootFiber, update);
14867 var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
14868 if (root !== null) {
14869 scheduleCallbackForRoot(root, ImmediatePriority, Sync);
14870 }
14871}
14872
14873function captureCommitPhaseError$2(sourceFiber, error) {
14874 if (sourceFiber.tag === HostRoot) {
14875 // Error was thrown at the root. There is no parent, so the root
14876 // itself should capture it.
14877 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
14878 return;
14879 }
14880
14881 var fiber = sourceFiber.return;
14882 while (fiber !== null) {
14883 if (fiber.tag === HostRoot) {
14884 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
14885 return;
14886 } else if (fiber.tag === ClassComponent) {
14887 var ctor = fiber.type;
14888 var instance = fiber.stateNode;
14889 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary$2(instance)) {
14890 var errorInfo = createCapturedValue(error, sourceFiber);
14891 var update = createClassErrorUpdate(fiber, errorInfo,
14892 // TODO: This is always sync
14893 Sync);
14894 enqueueUpdate(fiber, update);
14895 var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
14896 if (root !== null) {
14897 scheduleCallbackForRoot(root, ImmediatePriority, Sync);
14898 }
14899 return;
14900 }
14901 }
14902 fiber = fiber.return;
14903 }
14904}
14905
14906function pingSuspendedRoot$2(root, thenable, suspendedTime) {
14907 var pingCache = root.pingCache;
14908 if (pingCache !== null) {
14909 // The thenable resolved, so we no longer need to memoize, because it will
14910 // never be thrown again.
14911 pingCache.delete(thenable);
14912 }
14913
14914 if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) {
14915 // Received a ping at the same priority level at which we're currently
14916 // rendering. Restart from the root. Don't need to schedule a ping because
14917 // we're already working on this tree.
14918 prepareFreshStack(root, renderExpirationTime$1);
14919 return;
14920 }
14921
14922 var lastPendingTime = root.lastPendingTime;
14923 if (lastPendingTime < suspendedTime) {
14924 // The root is no longer suspended at this time.
14925 return;
14926 }
14927
14928 var pingTime = root.pingTime;
14929 if (pingTime !== NoWork && pingTime < suspendedTime) {
14930 // There's already a lower priority ping scheduled.
14931 return;
14932 }
14933
14934 // Mark the time at which this ping was scheduled.
14935 root.pingTime = suspendedTime;
14936
14937 var currentTime = requestCurrentTime$2();
14938 var priorityLevel = inferPriorityFromExpirationTime(currentTime, suspendedTime);
14939 scheduleCallbackForRoot(root, priorityLevel, suspendedTime);
14940}
14941
14942function retryTimedOutBoundary$2(boundaryFiber) {
14943 // The boundary fiber (a Suspense component) previously timed out and was
14944 // rendered in its fallback state. One of the promises that suspended it has
14945 // resolved, which means at least part of the tree was likely unblocked. Try
14946 // rendering again, at a new expiration time.
14947 var currentTime = requestCurrentTime$2();
14948 var retryTime = computeExpirationForFiber$2(currentTime, boundaryFiber);
14949 // TODO: Special case idle priority?
14950 var priorityLevel = inferPriorityFromExpirationTime(currentTime, retryTime);
14951 var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
14952 if (root !== null) {
14953 scheduleCallbackForRoot(root, priorityLevel, retryTime);
14954 }
14955}
14956
14957function resolveRetryThenable$2(boundaryFiber, thenable) {
14958 var retryCache = void 0;
14959 if (enableSuspenseServerRenderer) {
14960 switch (boundaryFiber.tag) {
14961 case SuspenseComponent:
14962 retryCache = boundaryFiber.stateNode;
14963 break;
14964 case DehydratedSuspenseComponent:
14965 retryCache = boundaryFiber.memoizedState;
14966 break;
14967 default:
14968 (function () {
14969 {
14970 {
14971 throw ReactError('Pinged unknown suspense boundary type. This is probably a bug in React.');
14972 }
14973 }
14974 })();
14975 }
14976 } else {
14977 retryCache = boundaryFiber.stateNode;
14978 }
14979
14980 if (retryCache !== null) {
14981 // The thenable resolved, so we no longer need to memoize, because it will
14982 // never be thrown again.
14983 retryCache.delete(thenable);
14984 }
14985
14986 retryTimedOutBoundary$2(boundaryFiber);
14987}
14988
14989function inferStartTimeFromExpirationTime$2(root, expirationTime) {
14990 // We don't know exactly when the update was scheduled, but we can infer an
14991 // approximate start time from the expiration time.
14992 var earliestExpirationTimeMs = expirationTimeToMs(root.firstPendingTime);
14993 // TODO: Track this on the root instead. It's more accurate, doesn't rely on
14994 // assumptions about priority, and isn't coupled to Scheduler details.
14995 return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
14996}
14997
14998function computeMsUntilTimeout(root, absoluteTimeoutMs) {
14999 if (disableYielding) {
15000 // Timeout immediately when yielding is disabled.
15001 return 0;
15002 }
15003
15004 // Find the earliest uncommitted expiration time in the tree, including
15005 // work that is suspended. The timeout threshold cannot be longer than
15006 // the overall expiration.
15007 var earliestExpirationTimeMs = expirationTimeToMs(root.firstPendingTime);
15008 if (earliestExpirationTimeMs < absoluteTimeoutMs) {
15009 absoluteTimeoutMs = earliestExpirationTimeMs;
15010 }
15011
15012 // Subtract the current time from the absolute timeout to get the number
15013 // of milliseconds until the timeout. In other words, convert an absolute
15014 // timestamp to a relative time. This is the value that is passed
15015 // to `setTimeout`.
15016 var msUntilTimeout = absoluteTimeoutMs - now$1();
15017 return msUntilTimeout < 0 ? 0 : msUntilTimeout;
15018}
15019
15020function checkForNestedUpdates() {
15021 if (nestedUpdateCount$1 > NESTED_UPDATE_LIMIT$1) {
15022 nestedUpdateCount$1 = 0;
15023 rootWithNestedUpdates = null;
15024 (function () {
15025 {
15026 {
15027 throw ReactError('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.');
15028 }
15029 }
15030 })();
15031 }
15032
15033 {
15034 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT$1) {
15035 nestedPassiveUpdateCount = 0;
15036 warning$1(false, 'Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.');
15037 }
15038 }
15039}
15040
15041function flushRenderPhaseStrictModeWarningsInDEV() {
15042 {
15043 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
15044 ReactStrictModeWarnings.flushLegacyContextWarning();
15045
15046 if (warnAboutDeprecatedLifecycles) {
15047 ReactStrictModeWarnings.flushPendingDeprecationWarnings();
15048 }
15049 }
15050}
15051
15052function stopFinishedWorkLoopTimer() {
15053 var didCompleteRoot = true;
15054 stopWorkLoopTimer(interruptedBy$1, didCompleteRoot);
15055 interruptedBy$1 = null;
15056}
15057
15058function stopInterruptedWorkLoopTimer() {
15059 // TODO: Track which fiber caused the interruption.
15060 var didCompleteRoot = false;
15061 stopWorkLoopTimer(interruptedBy$1, didCompleteRoot);
15062 interruptedBy$1 = null;
15063}
15064
15065function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
15066 if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime$1) {
15067 interruptedBy$1 = fiberThatReceivedUpdate;
15068 }
15069}
15070
15071var didWarnStateUpdateForUnmountedComponent$1 = null;
15072function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
15073 {
15074 var tag = fiber.tag;
15075 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
15076 // Only warn for user-defined components, not internal ones like Suspense.
15077 return;
15078 }
15079 // We show the whole stack but dedupe on the top component's name because
15080 // the problematic code almost always lies inside that component.
15081 var componentName = getComponentName(fiber.type) || 'ReactComponent';
15082 if (didWarnStateUpdateForUnmountedComponent$1 !== null) {
15083 if (didWarnStateUpdateForUnmountedComponent$1.has(componentName)) {
15084 return;
15085 }
15086 didWarnStateUpdateForUnmountedComponent$1.add(componentName);
15087 } else {
15088 didWarnStateUpdateForUnmountedComponent$1 = new Set([componentName]);
15089 }
15090 warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
15091 }
15092}
15093
15094var beginWork$1 = void 0;
15095if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
15096 var dummyFiber = null;
15097 beginWork$1 = function (current$$1, unitOfWork, expirationTime) {
15098 // If a component throws an error, we replay it again in a synchronously
15099 // dispatched event, so that the debugger will treat it as an uncaught
15100 // error See ReactErrorUtils for more information.
15101
15102 // Before entering the begin phase, copy the work-in-progress onto a dummy
15103 // fiber. If beginWork throws, we'll use this to reset the state.
15104 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
15105 try {
15106 return beginWork(current$$1, unitOfWork, expirationTime);
15107 } catch (originalError) {
15108 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
15109 // Don't replay promises. Treat everything else like an error.
15110 throw originalError;
15111 }
15112
15113 // Keep this code in sync with renderRoot; any changes here must have
15114 // corresponding changes there.
15115 resetContextDependences();
15116 resetHooks();
15117
15118 // Unwind the failed stack frame
15119 unwindInterruptedWork(unitOfWork);
15120
15121 // Restore the original properties of the fiber.
15122 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
15123
15124 if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
15125 // Reset the profiler timer.
15126 startProfilerTimer(unitOfWork);
15127 }
15128
15129 // Run beginWork again.
15130 invokeGuardedCallback(null, beginWork, null, current$$1, unitOfWork, expirationTime);
15131
15132 if (hasCaughtError()) {
15133 var replayError = clearCaughtError();
15134 // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
15135 // Rethrow this error instead of the original one.
15136 throw replayError;
15137 } else {
15138 // This branch is reachable if the render phase is impure.
15139 throw originalError;
15140 }
15141 }
15142 };
15143} else {
15144 beginWork$1 = beginWork;
15145}
15146
15147var didWarnAboutUpdateInRender = false;
15148var didWarnAboutUpdateInGetChildContext = false;
15149function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
15150 {
15151 if (fiber.tag === ClassComponent) {
15152 switch (phase) {
15153 case 'getChildContext':
15154 if (didWarnAboutUpdateInGetChildContext) {
15155 return;
15156 }
15157 warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
15158 didWarnAboutUpdateInGetChildContext = true;
15159 break;
15160 case 'render':
15161 if (didWarnAboutUpdateInRender) {
15162 return;
15163 }
15164 warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure function of ' + 'props and state.');
15165 didWarnAboutUpdateInRender = true;
15166 break;
15167 }
15168 }
15169 }
15170}
15171
15172function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
15173 {
15174 if (workPhase === NotWorking && ReactShouldWarnActingUpdates$1.current === false) {
15175 warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
15176 }
15177 }
15178}
15179
15180var warnIfNotCurrentlyActingUpdatesInDev$2 = warnIfNotCurrentlyActingUpdatesInDEV;
15181
15182function computeThreadID$1(root, expirationTime) {
15183 // Interaction threads are unique per root and expiration time.
15184 return expirationTime * 1000 + root.interactionThreadID;
15185}
15186
15187function schedulePendingInteraction(root, expirationTime) {
15188 // This is called when work is scheduled on a root. It sets up a pending
15189 // interaction, which is completed once the work commits.
15190 if (!enableSchedulerTracing) {
15191 return;
15192 }
15193
15194 var interactions = tracing.__interactionsRef.current;
15195 if (interactions.size > 0) {
15196 var pendingInteractionMap = root.pendingInteractionMap;
15197 var pendingInteractions = pendingInteractionMap.get(expirationTime);
15198 if (pendingInteractions != null) {
15199 interactions.forEach(function (interaction) {
15200 if (!pendingInteractions.has(interaction)) {
15201 // Update the pending async work count for previously unscheduled interaction.
15202 interaction.__count++;
15203 }
15204
15205 pendingInteractions.add(interaction);
15206 });
15207 } else {
15208 pendingInteractionMap.set(expirationTime, new Set(interactions));
15209
15210 // Update the pending async work count for the current interactions.
15211 interactions.forEach(function (interaction) {
15212 interaction.__count++;
15213 });
15214 }
15215
15216 var subscriber = tracing.__subscriberRef.current;
15217 if (subscriber !== null) {
15218 var threadID = computeThreadID$1(root, expirationTime);
15219 subscriber.onWorkScheduled(interactions, threadID);
15220 }
15221 }
15222}
15223
15224function startWorkOnPendingInteraction(root, expirationTime) {
15225 // This is called when new work is started on a root.
15226 if (!enableSchedulerTracing) {
15227 return;
15228 }
15229
15230 // Determine which interactions this batch of work currently includes, So that
15231 // we can accurately attribute time spent working on it, And so that cascading
15232 // work triggered during the render phase will be associated with it.
15233 var interactions = new Set();
15234 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
15235 if (scheduledExpirationTime >= expirationTime) {
15236 scheduledInteractions.forEach(function (interaction) {
15237 return interactions.add(interaction);
15238 });
15239 }
15240 });
15241
15242 // Store the current set of interactions on the FiberRoot for a few reasons:
15243 // We can re-use it in hot functions like renderRoot() without having to
15244 // recalculate it. We will also use it in commitWork() to pass to any Profiler
15245 // onRender() hooks. This also provides DevTools with a way to access it when
15246 // the onCommitRoot() hook is called.
15247 root.memoizedInteractions = interactions;
15248
15249 if (interactions.size > 0) {
15250 var subscriber = tracing.__subscriberRef.current;
15251 if (subscriber !== null) {
15252 var threadID = computeThreadID$1(root, expirationTime);
15253 try {
15254 subscriber.onWorkStarted(interactions, threadID);
15255 } catch (error) {
15256 // If the subscriber throws, rethrow it in a separate task
15257 scheduleCallback(ImmediatePriority, function () {
15258 throw error;
15259 });
15260 }
15261 }
15262 }
15263}
15264
15265function finishPendingInteractions(root, committedExpirationTime) {
15266 if (!enableSchedulerTracing) {
15267 return;
15268 }
15269
15270 var earliestRemainingTimeAfterCommit = root.firstPendingTime;
15271
15272 var subscriber = void 0;
15273
15274 try {
15275 subscriber = tracing.__subscriberRef.current;
15276 if (subscriber !== null && root.memoizedInteractions.size > 0) {
15277 var threadID = computeThreadID$1(root, committedExpirationTime);
15278 subscriber.onWorkStopped(root.memoizedInteractions, threadID);
15279 }
15280 } catch (error) {
15281 // If the subscriber throws, rethrow it in a separate task
15282 scheduleCallback(ImmediatePriority, function () {
15283 throw error;
15284 });
15285 } finally {
15286 // Clear completed interactions from the pending Map.
15287 // Unless the render was suspended or cascading work was scheduled,
15288 // In which case– leave pending interactions until the subsequent render.
15289 var pendingInteractionMap = root.pendingInteractionMap;
15290 pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
15291 // Only decrement the pending interaction count if we're done.
15292 // If there's still work at the current priority,
15293 // That indicates that we are waiting for suspense data.
15294 if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
15295 pendingInteractionMap.delete(scheduledExpirationTime);
15296
15297 scheduledInteractions.forEach(function (interaction) {
15298 interaction.__count--;
15299
15300 if (subscriber !== null && interaction.__count === 0) {
15301 try {
15302 subscriber.onInteractionScheduledWorkCompleted(interaction);
15303 } catch (error) {
15304 // If the subscriber throws, rethrow it in a separate task
15305 scheduleCallback(ImmediatePriority, function () {
15306 throw error;
15307 });
15308 }
15309 }
15310 });
15311 }
15312 });
15313 }
15314}
15315
15316var requestCurrentTime$$1 = enableNewScheduler ? requestCurrentTime$2 : requestCurrentTime$1;
15317var computeExpirationForFiber$$1 = enableNewScheduler ? computeExpirationForFiber$2 : computeExpirationForFiber$1;
15318var captureCommitPhaseError$$1 = enableNewScheduler ? captureCommitPhaseError$2 : captureCommitPhaseError$1;
15319var onUncaughtError$$1 = enableNewScheduler ? onUncaughtError$2 : onUncaughtError$1;
15320var renderDidSuspend$$1 = enableNewScheduler ? renderDidSuspend$2 : renderDidSuspend$1;
15321var renderDidError$$1 = enableNewScheduler ? renderDidError$2 : renderDidError$1;
15322var pingSuspendedRoot$$1 = enableNewScheduler ? pingSuspendedRoot$2 : pingSuspendedRoot$1;
15323var retryTimedOutBoundary$$1 = enableNewScheduler ? retryTimedOutBoundary$2 : retryTimedOutBoundary$1;
15324var resolveRetryThenable$$1 = enableNewScheduler ? resolveRetryThenable$2 : resolveRetryThenable$1;
15325var markLegacyErrorBoundaryAsFailed$$1 = enableNewScheduler ? markLegacyErrorBoundaryAsFailed$2 : markLegacyErrorBoundaryAsFailed$1;
15326var isAlreadyFailedLegacyErrorBoundary$$1 = enableNewScheduler ? isAlreadyFailedLegacyErrorBoundary$2 : isAlreadyFailedLegacyErrorBoundary$1;
15327var scheduleWork$$1 = enableNewScheduler ? scheduleWork$2 : scheduleWork$1;
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338var flushPassiveEffects$$1 = enableNewScheduler ? flushPassiveEffects$2 : flushPassiveEffects$1;
15339var warnIfNotCurrentlyActingUpdatesInDev$$1 = enableNewScheduler ? warnIfNotCurrentlyActingUpdatesInDev$2 : warnIfNotCurrentlyActingUpdatesInDev$1;
15340var inferStartTimeFromExpirationTime$$1 = enableNewScheduler ? inferStartTimeFromExpirationTime$2 : inferStartTimeFromExpirationTime$1;
15341
15342// 0 is PROD, 1 is DEV.
15343// Might add PROFILE later.
15344
15345
15346var didWarnAboutNestedUpdates = void 0;
15347{
15348 didWarnAboutNestedUpdates = false;
15349
15350}
15351
15352function getContextForSubtree(parentComponent) {
15353 if (!parentComponent) {
15354 return emptyContextObject;
15355 }
15356
15357 var fiber = get(parentComponent);
15358 var parentContext = findCurrentUnmaskedContext(fiber);
15359
15360 if (fiber.tag === ClassComponent) {
15361 var Component = fiber.type;
15362 if (isContextProvider(Component)) {
15363 return processChildContext(fiber, Component, parentContext);
15364 }
15365 }
15366
15367 return parentContext;
15368}
15369
15370function scheduleRootUpdate(current$$1, element, expirationTime, callback) {
15371 {
15372 if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
15373 didWarnAboutNestedUpdates = true;
15374 warningWithoutStack$1(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current.type) || 'Unknown');
15375 }
15376 }
15377
15378 var update = createUpdate(expirationTime);
15379 // Caution: React DevTools currently depends on this property
15380 // being called "element".
15381 update.payload = { element: element };
15382
15383 callback = callback === undefined ? null : callback;
15384 if (callback !== null) {
15385 !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
15386 update.callback = callback;
15387 }
15388
15389 flushPassiveEffects$$1();
15390 enqueueUpdate(current$$1, update);
15391 scheduleWork$$1(current$$1, expirationTime);
15392
15393 return expirationTime;
15394}
15395
15396function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback) {
15397 // TODO: If this is a nested container, this won't be the root.
15398 var current$$1 = container.current;
15399
15400 {
15401 if (ReactFiberInstrumentation_1.debugTool) {
15402 if (current$$1.alternate === null) {
15403 ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
15404 } else if (element === null) {
15405 ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
15406 } else {
15407 ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
15408 }
15409 }
15410 }
15411
15412 var context = getContextForSubtree(parentComponent);
15413 if (container.context === null) {
15414 container.context = context;
15415 } else {
15416 container.pendingContext = context;
15417 }
15418
15419 return scheduleRootUpdate(current$$1, element, expirationTime, callback);
15420}
15421
15422function createContainer(containerInfo, isConcurrent, hydrate) {
15423 return createFiberRoot(containerInfo, isConcurrent, hydrate);
15424}
15425
15426function updateContainer(element, container, parentComponent, callback) {
15427 var current$$1 = container.current;
15428 var currentTime = requestCurrentTime$$1();
15429 var expirationTime = computeExpirationForFiber$$1(currentTime, current$$1);
15430 return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback);
15431}
15432
15433
15434
15435
15436
15437var overrideHookState = null;
15438var overrideProps = null;
15439
15440{
15441 var copyWithSetImpl = function (obj, path, idx, value) {
15442 if (idx >= path.length) {
15443 return value;
15444 }
15445 var key = path[idx];
15446 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
15447 // $FlowFixMe number or string is fine here
15448 updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
15449 return updated;
15450 };
15451
15452 var copyWithSet = function (obj, path, value) {
15453 return copyWithSetImpl(obj, path, 0, value);
15454 };
15455
15456 // Support DevTools editable values for useState and useReducer.
15457 overrideHookState = function (fiber, id, path, value) {
15458 // For now, the "id" of stateful hooks is just the stateful hook index.
15459 // This may change in the future with e.g. nested hooks.
15460 var currentHook = fiber.memoizedState;
15461 while (currentHook !== null && id > 0) {
15462 currentHook = currentHook.next;
15463 id--;
15464 }
15465 if (currentHook !== null) {
15466 flushPassiveEffects$$1();
15467
15468 var newState = copyWithSet(currentHook.memoizedState, path, value);
15469 currentHook.memoizedState = newState;
15470 currentHook.baseState = newState;
15471
15472 // We aren't actually adding an update to the queue,
15473 // because there is no update we can add for useReducer hooks that won't trigger an error.
15474 // (There's no appropriate action type for DevTools overrides.)
15475 // As a result though, React will see the scheduled update as a noop and bailout.
15476 // Shallow cloning props works as a workaround for now to bypass the bailout check.
15477 fiber.memoizedProps = _assign({}, fiber.memoizedProps);
15478
15479 scheduleWork$$1(fiber, Sync);
15480 }
15481 };
15482
15483 // Support DevTools props for function components, forwardRef, memo, host components, etc.
15484 overrideProps = function (fiber, path, value) {
15485 flushPassiveEffects$$1();
15486 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
15487 if (fiber.alternate) {
15488 fiber.alternate.pendingProps = fiber.pendingProps;
15489 }
15490 scheduleWork$$1(fiber, Sync);
15491 };
15492}
15493
15494function injectIntoDevTools(devToolsConfig) {
15495 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
15496 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
15497
15498
15499 return injectInternals(_assign({}, devToolsConfig, {
15500 overrideHookState: overrideHookState,
15501 overrideProps: overrideProps,
15502 currentDispatcherRef: ReactCurrentDispatcher,
15503 findHostInstanceByFiber: function (fiber) {
15504 var hostFiber = findCurrentHostFiber(fiber);
15505 if (hostFiber === null) {
15506 return null;
15507 }
15508 return hostFiber.stateNode;
15509 },
15510 findFiberByHostInstance: function (instance) {
15511 if (!findFiberByHostInstance) {
15512 // Might not be implemented by the renderer.
15513 return null;
15514 }
15515 return findFiberByHostInstance(instance);
15516 }
15517 }));
15518}
15519
15520// This file intentionally does *not* have the Flow annotation.
15521// Don't add it. See `./inline-typed.js` for an explanation.
15522
15523var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
15524
15525function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
15526
15527function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
15528
15529function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15530
15531Mode.setCurrent(
15532// Change to 'art/modes/dom' for easier debugging via SVG
15533FastNoSideEffects);
15534
15535/** Declarative fill-type objects; API design not finalized */
15536
15537var slice = Array.prototype.slice;
15538
15539var LinearGradient = function () {
15540 function LinearGradient(stops, x1, y1, x2, y2) {
15541 _classCallCheck(this, LinearGradient);
15542
15543 this._args = slice.call(arguments);
15544 }
15545
15546 LinearGradient.prototype.applyFill = function applyFill(node) {
15547 node.fillLinear.apply(node, this._args);
15548 };
15549
15550 return LinearGradient;
15551}();
15552
15553var RadialGradient = function () {
15554 function RadialGradient(stops, fx, fy, rx, ry, cx, cy) {
15555 _classCallCheck(this, RadialGradient);
15556
15557 this._args = slice.call(arguments);
15558 }
15559
15560 RadialGradient.prototype.applyFill = function applyFill(node) {
15561 node.fillRadial.apply(node, this._args);
15562 };
15563
15564 return RadialGradient;
15565}();
15566
15567var Pattern = function () {
15568 function Pattern(url, width, height, left, top) {
15569 _classCallCheck(this, Pattern);
15570
15571 this._args = slice.call(arguments);
15572 }
15573
15574 Pattern.prototype.applyFill = function applyFill(node) {
15575 node.fillImage.apply(node, this._args);
15576 };
15577
15578 return Pattern;
15579}();
15580
15581/** React Components */
15582
15583var Surface = function (_React$Component) {
15584 _inherits(Surface, _React$Component);
15585
15586 function Surface() {
15587 _classCallCheck(this, Surface);
15588
15589 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
15590 }
15591
15592 Surface.prototype.componentDidMount = function componentDidMount() {
15593 var _props = this.props,
15594 height = _props.height,
15595 width = _props.width;
15596
15597
15598 this._surface = Mode.Surface(+width, +height, this._tagRef);
15599
15600 this._mountNode = createContainer(this._surface);
15601 updateContainer(this.props.children, this._mountNode, this);
15602 };
15603
15604 Surface.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
15605 var props = this.props;
15606
15607 if (props.height !== prevProps.height || props.width !== prevProps.width) {
15608 this._surface.resize(+props.width, +props.height);
15609 }
15610
15611 updateContainer(this.props.children, this._mountNode, this);
15612
15613 if (this._surface.render) {
15614 this._surface.render();
15615 }
15616 };
15617
15618 Surface.prototype.componentWillUnmount = function componentWillUnmount() {
15619 updateContainer(null, this._mountNode, this);
15620 };
15621
15622 Surface.prototype.render = function render() {
15623 var _this2 = this;
15624
15625 // This is going to be a placeholder because we don't know what it will
15626 // actually resolve to because ART may render canvas, vml or svg tags here.
15627 // We only allow a subset of properties since others might conflict with
15628 // ART's properties.
15629 var props = this.props;
15630
15631 // TODO: ART's Canvas Mode overrides surface title and cursor
15632 var Tag = Mode.Surface.tagName;
15633
15634 return React.createElement(Tag, {
15635 ref: function (ref) {
15636 return _this2._tagRef = ref;
15637 },
15638 accessKey: props.accessKey,
15639 className: props.className,
15640 draggable: props.draggable,
15641 role: props.role,
15642 style: props.style,
15643 tabIndex: props.tabIndex,
15644 title: props.title
15645 });
15646 };
15647
15648 return Surface;
15649}(React.Component);
15650
15651var Text = function (_React$Component2) {
15652 _inherits(Text, _React$Component2);
15653
15654 function Text(props) {
15655 _classCallCheck(this, Text);
15656
15657 // We allow reading these props. Ideally we could expose the Text node as
15658 // ref directly.
15659 var _this3 = _possibleConstructorReturn(this, _React$Component2.call(this, props));
15660
15661 ['height', 'width', 'x', 'y'].forEach(function (key) {
15662 Object.defineProperty(_this3, key, {
15663 get: function () {
15664 return this._text ? this._text[key] : undefined;
15665 }
15666 });
15667 });
15668 return _this3;
15669 }
15670
15671 Text.prototype.render = function render() {
15672 var _this4 = this;
15673
15674 // This means you can't have children that render into strings...
15675 var T = TYPES.TEXT;
15676 return React.createElement(
15677 T,
15678 _extends({}, this.props, { ref: function (t) {
15679 return _this4._text = t;
15680 } }),
15681 childrenAsString(this.props.children)
15682 );
15683 };
15684
15685 return Text;
15686}(React.Component);
15687
15688injectIntoDevTools({
15689 findFiberByHostInstance: function () {
15690 return null;
15691 },
15692 bundleType: 1,
15693 version: ReactVersion,
15694 rendererPackageName: 'react-art'
15695});
15696
15697/** API */
15698
15699var ClippingRectangle = TYPES.CLIPPING_RECTANGLE;
15700var Group = TYPES.GROUP;
15701var Shape = TYPES.SHAPE;
15702var Path = Mode.Path;
15703
15704
15705var ReactART = Object.freeze({
15706 ClippingRectangle: ClippingRectangle,
15707 Group: Group,
15708 Shape: Shape,
15709 Path: Path,
15710 LinearGradient: LinearGradient,
15711 Pattern: Pattern,
15712 RadialGradient: RadialGradient,
15713 Surface: Surface,
15714 Text: Text,
15715 Transform: Transform
15716});
15717
15718var reactArt = ReactART;
15719
15720module.exports = reactArt;
15721 })();
15722}