diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index b9cc9777d2b91f..25abc612cfd324 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -e67a6b16030ebc30257a69a7fb36a9ed67f29b39 \ No newline at end of file +4e5d7faf54b38ebfc7a2dcadbd09a25d6f330ac0 \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 292bfa73b098a9..bf59a6a287948b 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -139,7 +139,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { // If document doesn't exist we know for sure we will crash in this method // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebookincubator/create-react-app/issues/3482 + // errors: https://github.com/facebook/create-react-app/issues/3482 // So we preemptively throw with a better message instead. if (!(typeof document !== "undefined")) { throw Error( @@ -263,7 +263,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; 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." + "See https://reactjs.org/link/crossorigin-error for more information." ); } @@ -806,13 +806,6 @@ addEventPoolingTo(SyntheticEvent); */ function getPooledWarningPropertyDefinition(propName, getVal) { - var isFunction = typeof getVal === "function"; - return { - configurable: true, - set: set, - get: get - }; - function set(val) { var action = isFunction ? "setting the method" : "setting the property"; warn(action, "This is effectively a no-op"); @@ -834,13 +827,20 @@ function getPooledWarningPropertyDefinition(propName, getVal) { "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", + "See https://reactjs.org/link/event-pooling for more information.", action, propName, result ); } } + + var isFunction = typeof getVal === "function"; + return { + configurable: true, + set: set, + get: get + }; } function createOrGetPooledEvent( @@ -2690,9 +2690,14 @@ function getComponentName(type) { return null; } +// The rest of the flags are static for better dead code elimination. +var enableProfilerTimer = true; +var warnAboutStringRefs = false; +var enableNewReconciler = false; + // Don't change these two values. They're used by React Dev Tools. -var NoEffect = - /* */ +var NoFlags = + /* */ 0; var PerformedWork = /* */ @@ -2727,40 +2732,32 @@ var Snapshot = 256; var Passive = /* */ - 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old. - -var PassiveUnmountPendingDev = - /* */ - 8192; + 512; var Hydrating = /* */ 1024; var HydratingAndUpdate = /* */ - 1028; // Passive & Update & Callback & Ref & Snapshot - -var LifecycleEffectMask = - /* */ - 932; // Union of all host effects + 1028; +var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = /* */ - 2047; // These are not really side effects, but we still reuse this field. + 4095; // These are not really side effects, but we still reuse this field. var Incomplete = /* */ - 2048; + 4096; var ShouldCapture = /* */ - 4096; + 8192; // TODO (effects) Remove this bit once the new reconciler is synced to the old. + +var PassiveUnmountPendingDev = + /* */ + 16384; var ForceUpdateForLegacySuspense = /* */ - 16384; // Static tags describe aspects of a fiber that are not specific to a render, - -// The rest of the flags are static for better dead code elimination. -var enableProfilerTimer = true; -var warnAboutStringRefs = false; -var enableNewReconciler = false; + 32768; // Static tags describe aspects of a fiber that are not specific to a render, var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -2775,7 +2772,7 @@ function getNearestMountedFiber(fiber) { do { node = nextNode; - if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((node.flags & (Placement | Hydrating)) !== NoFlags) { // This is an insertion or in-progress hydration. The nearest possible // mounted fiber is the parent but we need to continue to figure out // if that one is still mounted. @@ -3761,82 +3758,80 @@ if (registerEventHandler) { * This is used for refs on host components. */ -var ReactFabricHostComponent = - /*#__PURE__*/ - (function() { - function ReactFabricHostComponent( - tag, - viewConfig, - props, - internalInstanceHandle - ) { - this._nativeTag = tag; - this.viewConfig = viewConfig; - this.currentProps = props; - this._internalInstanceHandle = internalInstanceHandle; - } - - var _proto = ReactFabricHostComponent.prototype; - - _proto.blur = function blur() { - ReactNativePrivateInterface.TextInputState.blurTextInput(this); - }; - - _proto.focus = function focus() { - ReactNativePrivateInterface.TextInputState.focusTextInput(this); - }; +var ReactFabricHostComponent = /*#__PURE__*/ (function() { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { + this._nativeTag = tag; + this.viewConfig = viewConfig; + this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; + } - _proto.measure = function measure(callback) { - fabricMeasure( - this._internalInstanceHandle.stateNode.node, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + var _proto = ReactFabricHostComponent.prototype; - _proto.measureInWindow = function measureInWindow(callback) { - fabricMeasureInWindow( - this._internalInstanceHandle.stateNode.node, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + _proto.blur = function blur() { + ReactNativePrivateInterface.TextInputState.blurTextInput(this); + }; - _proto.measureLayout = function measureLayout( - relativeToNativeNode, - onSuccess, - onFail - ) /* currently unused */ - { - if ( - typeof relativeToNativeNode === "number" || - !(relativeToNativeNode instanceof ReactFabricHostComponent) - ) { - { - error( - "Warning: ref.measureLayout must be called with a ref to a native component." - ); - } + _proto.focus = function focus() { + ReactNativePrivateInterface.TextInputState.focusTextInput(this); + }; - return; - } + _proto.measure = function measure(callback) { + fabricMeasure( + this._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - fabricMeasureLayout( - this._internalInstanceHandle.stateNode.node, - relativeToNativeNode._internalInstanceHandle.stateNode.node, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; + _proto.measureInWindow = function measureInWindow(callback) { + fabricMeasureInWindow( + this._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - _proto.setNativeProps = function setNativeProps(nativeProps) { + _proto.measureLayout = function measureLayout( + relativeToNativeNode, + onSuccess, + onFail + ) /* currently unused */ + { + if ( + typeof relativeToNativeNode === "number" || + !(relativeToNativeNode instanceof ReactFabricHostComponent) + ) { { - error("Warning: setNativeProps is not currently supported in Fabric"); + error( + "Warning: ref.measureLayout must be called with a ref to a native component." + ); } return; - }; + } + + fabricMeasureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + }; + + _proto.setNativeProps = function setNativeProps(nativeProps) { + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } + + return; + }; - return ReactFabricHostComponent; - })(); // eslint-disable-next-line no-unused-expressions + return ReactFabricHostComponent; +})(); // eslint-disable-next-line no-unused-expressions function appendInitialChild(parentInstance, child) { appendChildNode(parentInstance.node, child.node); } @@ -4575,7 +4570,7 @@ function processChildContext(fiber, type, parentContext) { checkPropTypes(childContextTypes, childContext, "child context", name); } - return Object.assign({}, parentContext, {}, childContext); + return Object.assign({}, parentContext, childContext); } } @@ -4702,7 +4697,7 @@ function injectInternals(internals) { error( "The installed version of React DevTools is too old and will not work " + "with the current version of React. Please update React DevTools. " + - "https://fb.me/react-devtools" + "https://reactjs.org/link/react-devtools" ); } // DevTools exists, even though it doesn't support Fiber. @@ -4743,7 +4738,7 @@ function onScheduleRoot(root, children) { function onCommitRoot(root, priorityLevel) { if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") { try { - var didError = (root.current.effectTag & DidCapture) === DidCapture; + var didError = (root.current.flags & DidCapture) === DidCapture; if (enableProfilerTimer) { injectedHook.onCommitFiberRoot( @@ -4796,7 +4791,7 @@ var Scheduler_now = Scheduler.unstable_now; ) ) { throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); } } @@ -4812,18 +4807,16 @@ var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only var NoPriority = 90; var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. -var SyncLanePriority = 17; -var SyncBatchedLanePriority = 16; -var InputDiscreteHydrationLanePriority = 15; -var InputDiscreteLanePriority = 14; -var InputContinuousHydrationLanePriority = 13; -var InputContinuousLanePriority = 12; -var DefaultHydrationLanePriority = 11; -var DefaultLanePriority = 10; -var TransitionShortHydrationLanePriority = 9; -var TransitionShortLanePriority = 8; -var TransitionLongHydrationLanePriority = 7; -var TransitionLongLanePriority = 6; +var SyncLanePriority = 15; +var SyncBatchedLanePriority = 14; +var InputDiscreteHydrationLanePriority = 13; +var InputDiscreteLanePriority = 12; +var InputContinuousHydrationLanePriority = 11; +var InputContinuousLanePriority = 10; +var DefaultHydrationLanePriority = 9; +var DefaultLanePriority = 8; +var TransitionHydrationPriority = 7; +var TransitionPriority = 6; var RetryLanePriority = 5; var SelectiveHydrationLanePriority = 4; var IdleHydrationLanePriority = 3; @@ -4861,21 +4854,18 @@ var DefaultHydrationLane = var DefaultLanes = /* */ 3584; -var TransitionShortHydrationLane = - /* */ +var TransitionHydrationLane = + /* */ 4096; -var TransitionShortLanes = - /* */ - 122880; -var TransitionLongHydrationLane = - /* */ - 131072; -var TransitionLongLanes = - /* */ - 3932160; +var TransitionLanes = + /* */ + 4186112; var RetryLanes = /* */ 62914560; +var SomeRetryLane = + /* */ + 33554432; var SelectiveHydrationLane = /* */ 67108864; @@ -4892,7 +4882,6 @@ var OffscreenLane = /* */ 1073741824; var NoTimestamp = -1; -function setCurrentUpdateLanePriority(newLanePriority) {} // "Registers" used to "return" multiple values // Used by getHighestPriorityLanes and getNextLanes: var return_highestLanePriority = DefaultLanePriority; @@ -4944,28 +4933,16 @@ function getHighestPriorityLanes(lanes) { return defaultLanes; } - if ((lanes & TransitionShortHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionShortHydrationLanePriority; - return TransitionShortHydrationLane; + if ((lanes & TransitionHydrationLane) !== NoLanes) { + return_highestLanePriority = TransitionHydrationPriority; + return TransitionHydrationLane; } - var transitionShortLanes = TransitionShortLanes & lanes; + var transitionLanes = TransitionLanes & lanes; - if (transitionShortLanes !== NoLanes) { - return_highestLanePriority = TransitionShortLanePriority; - return transitionShortLanes; - } - - if ((lanes & TransitionLongHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionLongHydrationLanePriority; - return TransitionLongHydrationLane; - } - - var transitionLongLanes = TransitionLongLanes & lanes; - - if (transitionLongLanes !== NoLanes) { - return_highestLanePriority = TransitionLongLanePriority; - return transitionLongLanes; + if (transitionLanes !== NoLanes) { + return_highestLanePriority = TransitionPriority; + return transitionLanes; } var retryLanes = RetryLanes & lanes; @@ -5039,10 +5016,8 @@ function lanePriorityToSchedulerPriority(lanePriority) { case DefaultHydrationLanePriority: case DefaultLanePriority: - case TransitionShortHydrationLanePriority: - case TransitionShortLanePriority: - case TransitionLongHydrationLanePriority: - case TransitionLongLanePriority: + case TransitionHydrationPriority: + case TransitionPriority: case SelectiveHydrationLanePriority: case RetryLanePriority: return NormalPriority; @@ -5200,8 +5175,22 @@ function computeExpirationTime(lane, currentTime) { if (priority >= InputContinuousLanePriority) { // User interactions should expire slightly more quickly. - return currentTime + 1000; - } else if (priority >= TransitionLongLanePriority) { + // + // NOTE: This is set to the corresponding constant as in Scheduler.js. When + // we made it larger, a product metric in www regressed, suggesting there's + // a user interaction that's being starved by a series of synchronous + // updates. If that theory is correct, the proper solution is to fix the + // starvation. However, this scenario supports the idea that expiration + // times are an important safeguard when starvation does happen. + // + // Also note that, in the case of user input specifically, this will soon no + // longer be an issue because we plan to make user input synchronous by + // default (until you enter `startTransition`, of course.) + // + // If weren't planning to make these updates synchronous soon anyway, I + // would probably make this number a configurable parameter. + return currentTime + 250; + } else if (priority >= TransitionPriority) { return currentTime + 5000; } else { // Anything idle priority or lower should never expire. @@ -5267,6 +5256,9 @@ function includesNonIdleWork(lanes) { } function includesOnlyRetries(lanes) { return (lanes & RetryLanes) === lanes; +} +function includesOnlyTransitions(lanes) { + return (lanes & TransitionLanes) === lanes; } // To ensure consistency across multiple updates in the same event, this should // be a pure function, so that it always returns the same lane for given inputs. @@ -5309,9 +5301,7 @@ function findUpdateLane(lanePriority, wipLanes) { if (_lane3 === NoLane) { // If all the default lanes are already being worked on, look for a // lane in the transition range. - _lane3 = pickArbitraryLane( - (TransitionShortLanes | TransitionLongLanes) & ~wipLanes - ); + _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes); if (_lane3 === NoLane) { // All the transition lanes are taken, too. This should be very @@ -5324,9 +5314,8 @@ function findUpdateLane(lanePriority, wipLanes) { return _lane3; } - case TransitionShortLanePriority: // Should be handled by findTransitionLane instead + case TransitionPriority: // Should be handled by findTransitionLane instead - case TransitionLongLanePriority: case RetryLanePriority: // Should be handled by findRetryLane instead break; @@ -5349,54 +5338,24 @@ function findUpdateLane(lanePriority, wipLanes) { } // To ensure consistency across multiple updates in the same event, this should // be pure function, so that it always returns the same lane for given inputs. -function findTransitionLane(lanePriority, wipLanes, pendingLanes) { - if (lanePriority === TransitionShortLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var lane = pickArbitraryLane(TransitionShortLanes & ~pendingLanes); - - if (lane === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - lane = pickArbitraryLane(TransitionShortLanes & ~wipLanes); - - if (lane === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - lane = pickArbitraryLane(TransitionShortLanes); - } - } +function findTransitionLane(wipLanes, pendingLanes) { + // First look for lanes that are completely unclaimed, i.e. have no + // pending work. + var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); - return lane; - } - - if (lanePriority === TransitionLongLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var _lane4 = pickArbitraryLane(TransitionLongLanes & ~pendingLanes); - - if (_lane4 === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - _lane4 = pickArbitraryLane(TransitionLongLanes & ~wipLanes); + if (lane === NoLane) { + // If all lanes have pending work, look for a lane that isn't currently + // being worked on. + lane = pickArbitraryLane(TransitionLanes & ~wipLanes); - if (_lane4 === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - _lane4 = pickArbitraryLane(TransitionLongLanes); - } + if (lane === NoLane) { + // If everything is being worked on, pick any lane. This has the + // effect of interrupting the current work-in-progress. + lane = pickArbitraryLane(TransitionLanes); } - - return _lane4; } - { - throw Error( - "Invalid transition priority: " + - lanePriority + - ". This is a bug in React." - ); - } + return lane; } // To ensure consistency across multiple updates in the same event, this should // be pure function, so that it always returns the same lane for given inputs. @@ -5461,7 +5420,15 @@ function laneToLanes(lane) { return lane; } function createLaneMap(initial) { - return new Array(TotalLanes).fill(initial); + // Intentionally pushing one by one. + // https://v8.dev/blog/elements-kinds#avoid-creating-holes + var laneMap = []; + + for (var i = 0; i < TotalLanes; i++) { + laneMap.push(initial); + } + + return laneMap; } function markRootUpdated(root, updateLane, eventTime) { root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But @@ -5502,9 +5469,6 @@ function markRootSuspended(root, suspendedLanes) { function markRootPinged(root, pingedLanes, eventTime) { root.pingedLanes |= root.suspendedLanes & pingedLanes; } -function markRootExpired(root, expiredLanes) { - root.expiredLanes |= expiredLanes & root.pendingLanes; -} function hasDiscreteLanes(lanes) { return (lanes & InputDiscreteLanes) !== NoLanes; } @@ -5588,7 +5552,7 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, ) ) { throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); } } @@ -5717,88 +5681,40 @@ function flushSyncCallbackQueueImpl() { isFlushingSyncQueue = true; var i = 0; - try { - var _isSync = true; - var queue = syncQueue; - setCurrentUpdateLanePriority(SyncLanePriority); - runWithPriority(ImmediatePriority$1, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; - - do { - callback = callback(_isSync); - } while (callback !== null); - } - }); - syncQueue = null; - } catch (error) { - // If something throws, leave the remaining callbacks on the queue. - if (syncQueue !== null) { - syncQueue = syncQueue.slice(i + 1); - } // Resume flushing in the next tick - - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ); - throw error; - } finally { - isFlushingSyncQueue = false; + { + try { + var _isSync2 = true; + var _queue = syncQueue; + runWithPriority(ImmediatePriority$1, function() { + for (; i < _queue.length; i++) { + var callback = _queue[i]; + + do { + callback = callback(_isSync2); + } while (callback !== null); + } + }); + syncQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (syncQueue !== null) { + syncQueue = syncQueue.slice(i + 1); + } // Resume flushing in the next tick + + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ); + throw error; + } finally { + isFlushingSyncQueue = false; + } } } } -function describeFiber(fiber) { - var owner = fiber._debugOwner ? fiber._debugOwner.type : null; - var source = fiber._debugSource; - - switch (fiber.tag) { - case HostComponent: - return describeBuiltInComponentFrame(fiber.type, source, owner); - - case LazyComponent: - return describeBuiltInComponentFrame("Lazy", source, owner); - - case SuspenseComponent: - return describeBuiltInComponentFrame("Suspense", source, owner); - - case SuspenseListComponent: - return describeBuiltInComponentFrame("SuspenseList", source, owner); - - case FunctionComponent: - case IndeterminateComponent: - case SimpleMemoComponent: - return describeFunctionComponentFrame(fiber.type, source, owner); - - case ForwardRef: - return describeFunctionComponentFrame(fiber.type.render, source, owner); - - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - - case ClassComponent: - return describeClassComponentFrame(fiber.type, source, owner); - - default: - return ""; - } -} - -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - var node = workInProgress; - - do { - info += describeFiber(node); - node = node.return; - } while (node); - - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} +// TODO: this is special because it gets imported during build. +var ReactVersion = "17.0.1-4e5d7faf5"; var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root @@ -5809,6 +5725,12 @@ var ConcurrentMode = 4; var ProfileMode = 8; var DebugTracingMode = 16; +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; +var NoTransition = 0; +function requestCurrentTransition() { + return ReactCurrentBatchConfig.transition; +} + /** * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is @@ -5861,6 +5783,58 @@ function shallowEqual(objA, objB) { return true; } +function describeFiber(fiber) { + var owner = fiber._debugOwner ? fiber._debugOwner.type : null; + var source = fiber._debugSource; + + switch (fiber.tag) { + case HostComponent: + return describeBuiltInComponentFrame(fiber.type, source, owner); + + case LazyComponent: + return describeBuiltInComponentFrame("Lazy", source, owner); + + case SuspenseComponent: + return describeBuiltInComponentFrame("Suspense", source, owner); + + case SuspenseListComponent: + return describeBuiltInComponentFrame("SuspenseList", source, owner); + + case FunctionComponent: + case IndeterminateComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type, source, owner); + + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render, source, owner); + + case Block: + return describeFunctionComponentFrame(fiber.type._render, source, owner); + + case ClassComponent: + return describeClassComponentFrame(fiber.type, source, owner); + + default: + return ""; + } +} + +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + var node = workInProgress; + + do { + info += describeFiber(node); + node = node.return; + } while (node); + + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} + var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; var current = null; var isRendering = false; @@ -6089,7 +6063,7 @@ var ReactStrictModeWarnings = { error( "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + "\nPlease update the following components: %s", sortedNames @@ -6104,11 +6078,11 @@ var ReactStrictModeWarnings = { error( "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* If you're updating state whenever props change, " + "refactor your code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + "\nPlease update the following components: %s", _sortedNames ); @@ -6122,7 +6096,7 @@ var ReactStrictModeWarnings = { error( "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "\nPlease update the following components: %s", _sortedNames2 @@ -6134,7 +6108,7 @@ var ReactStrictModeWarnings = { warn( "componentWillMount has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + @@ -6152,11 +6126,11 @@ var ReactStrictModeWarnings = { warn( "componentWillReceiveProps has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* If you're updating state whenever props change, refactor your " + "code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + @@ -6171,7 +6145,7 @@ var ReactStrictModeWarnings = { warn( "componentWillUpdate has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + @@ -6244,7 +6218,7 @@ var ReactStrictModeWarnings = { "\n\nThe old API will be supported in all 16.x releases, but applications " + "using it should migrate to the new version." + "\n\nPlease update the following components: %s" + - "\n\nLearn more about this warning here: https://fb.me/react-legacy-context", + "\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context", sortedNames ); } finally { @@ -6435,8 +6409,7 @@ function propagateContextChange( // Schedule a force update on the work-in-progress. var update = createUpdate( NoTimestamp, - pickArbitraryLane(renderLanes), - null + pickArbitraryLane(renderLanes) ); update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the // update to the current fiber, too, which means it will persist even if @@ -6622,11 +6595,10 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue = clone; } } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(eventTime, lane) { var update = { eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, tag: UpdateState, payload: null, callback: null, @@ -6701,7 +6673,6 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { var clone = { eventTime: update.eventTime, lane: update.lane, - suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, @@ -6793,8 +6764,8 @@ function getStateFromUpdate( } case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = + (workInProgress.flags & ~ShouldCapture) | DidCapture; } // Intentional fallthrough @@ -6920,7 +6891,6 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { var clone = { eventTime: updateEventTime, lane: updateLane, - suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, @@ -6944,21 +6914,13 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { // it. Using NoLane works because 0 is a subset of all bitmasks, so // this will never be skipped by the check above. lane: NoLane, - suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, next: null }; newLastBaseUpdate = newLastBaseUpdate.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig); // Process this update. + } // Process this update. newState = getStateFromUpdate( workInProgress, @@ -6971,7 +6933,7 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { var callback = update.callback; if (callback !== null) { - workInProgress.effectTag |= Callback; + workInProgress.flags |= Callback; var effects = queue.effects; if (effects === null) { @@ -7063,11 +7025,6 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; -function requestCurrentSuspenseConfig() { - return ReactCurrentBatchConfig.suspense; -} - var fakeInternalInstance = {}; var isArray = Array.isArray; // React.Component uses a shared frozen object by default. // We'll use it to determine whether we need to initialize legacy refs. @@ -7192,9 +7149,8 @@ var classComponentUpdater = { enqueueSetState: function(inst, payload, callback) { var fiber = get(inst); var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.payload = payload; if (callback !== undefined && callback !== null) { @@ -7211,9 +7167,8 @@ var classComponentUpdater = { enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ReplaceState; update.payload = payload; @@ -7231,9 +7186,8 @@ var classComponentUpdater = { enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ForceUpdate; if (callback !== undefined && callback !== null) { @@ -7693,7 +7647,7 @@ function constructClassInstance(workInProgress, ctor, props) { "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + - "https://fb.me/react-unsafe-component-lifecycles", + "https://reactjs.org/link/unsafe-component-lifecycles", _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : "", @@ -7855,7 +7809,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -7917,7 +7871,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return false; @@ -7963,13 +7917,13 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the // memoized state to indicate that this work can be reused. @@ -8057,7 +8011,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -8066,7 +8020,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } @@ -8113,11 +8067,11 @@ function updateClassInstance( } if (typeof instance.componentDidUpdate === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } if (typeof instance.getSnapshotBeforeUpdate === "function") { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } else { // If an update was already in progress, we should schedule an Update @@ -8127,7 +8081,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -8136,7 +8090,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } // If shouldComponentUpdate returned false, we should still update the // memoized props/state to indicate that this work can be reused. @@ -8199,7 +8153,7 @@ var warnForMissingKey = function(child, returnFiber) {}; error( "Each child in a list should have a unique " + - '"key" prop. See https://fb.me/react-warning-keys for ' + + '"key" prop. See https://reactjs.org/link/warning-keys for ' + "more information." ); }; @@ -8237,7 +8191,7 @@ function coerceRef(returnFiber, current, element) { "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-string-ref", + "https://reactjs.org/link/strict-mode-string-ref", mixedRef ); } @@ -8256,7 +8210,7 @@ function coerceRef(returnFiber, current, element) { if (!(ownerFiber.tag === ClassComponent)) { throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); } @@ -8310,7 +8264,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + mixedRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } } @@ -8375,7 +8329,7 @@ function ChildReconciler(shouldTrackSideEffects) { } childToDelete.nextEffect = null; - childToDelete.effectTag = Deletion; + childToDelete.flags = Deletion; } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -8439,7 +8393,7 @@ function ChildReconciler(shouldTrackSideEffects) { if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -8447,7 +8401,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -8456,7 +8410,7 @@ function ChildReconciler(shouldTrackSideEffects) { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { - newFiber.effectTag = Placement; + newFiber.flags = Placement; } return newFiber; @@ -9410,12 +9364,13 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case FunctionComponent: { - var Component = returnFiber.type; - + case Block: + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { { throw Error( - (Component.displayName || Component.name || "Component") + + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); } @@ -9579,13 +9534,6 @@ function popSuspenseContext(fiber) { pop(suspenseStackCursor, fiber); } -// A non-null SuspenseState means that it is blocked for one reason or another. -// - A non-null dehydrated field means it's blocked pending hydration. -// - A non-null dehydrated field can use isSuspenseInstancePending or -// isSuspenseInstanceFallback to query the reason for being dehydrated. -// - A null dehydrated field means it's blocked by something suspending and -// we're currently showing a fallback instead. - function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { // If it was the primary children that just suspended, capture and render the // fallback. Otherwise, don't capture and bubble to the next boundary. @@ -9640,7 +9588,7 @@ function findFirstSuspended(row) { // keep track of whether it suspended or not. node.memoizedProps.revealOrder !== undefined ) { - var didSuspend = (node.effectTag & DidCapture) !== NoEffect; + var didSuspend = (node.flags & DidCapture) !== NoFlags; if (didSuspend) { return node; @@ -9670,7 +9618,7 @@ function findFirstSuspended(row) { return null; } -var NoEffect$1 = +var NoFlags$1 = /* */ 0; // Represents whether effect should fire. @@ -9894,7 +9842,7 @@ function warnOnHookMismatchInDev(currentHookName) { error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + - "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + + "For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n" + " Previous render Next render\n" + " ------------------------------------------------------\n" + "%s" + @@ -9910,7 +9858,7 @@ function warnOnHookMismatchInDev(currentHookName) { function throwInvalidHookError() { { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } } @@ -10080,7 +10028,7 @@ function renderWithHooks( } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; - workInProgress.effectTag &= ~(Passive | Update); + workInProgress.flags &= ~(Passive | Update); current.lanes = removeLanes(current.lanes, lanes); } function resetHooksAfterThrow() { @@ -10296,18 +10244,14 @@ function updateReducer(reducer, initialArg, init) { var update = first; do { - var suspenseConfig = update.suspenseConfig; var updateLane = update.lane; - var updateEventTime = update.eventTime; if (!isSubsetOfLanes(renderLanes, updateLane)) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. var clone = { - eventTime: updateEventTime, lane: updateLane, - suspenseConfig: suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, @@ -10332,26 +10276,17 @@ function updateReducer(reducer, initialArg, init) { // This update does have sufficient priority. if (newBaseQueueLast !== null) { var _clone = { - eventTime: updateEventTime, // This update is going to be committed so we never want uncommit // it. Using NoLane works because 0 is a subset of all bitmasks, so // this will never be skipped by the check above. lane: NoLane, - suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }; newBaseQueueLast = newBaseQueueLast.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); // Process this update. + } // Process this update. if (update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -10578,8 +10513,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { if (!objectIs(snapshot, maybeNewSnapshot)) { setSnapshot(maybeNewSnapshot); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var lane = requestUpdateLane(fiber); markRootMutableRead(root, lane); } // If the source mutated between render and now, // there may be state updates already scheduled from the old source. @@ -10600,8 +10534,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { try { latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var lane = requestUpdateLane(fiber); markRootMutableRead(root, lane); } catch (error) { // A selector might throw after a source mutation. @@ -10750,16 +10683,14 @@ function pushEffect(tag, create, destroy, deps) { function mountRef(initialValue) { var hook = mountWorkInProgressHook(); - var ref = { - current: initialValue - }; { - Object.seal(ref); + var _ref2 = { + current: initialValue + }; + hook.memoizedState = _ref2; + return _ref2; } - - hook.memoizedState = ref; - return ref; } function updateRef(initialValue) { @@ -10767,19 +10698,19 @@ function updateRef(initialValue) { return hook.memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, undefined, nextDeps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var destroy = undefined; @@ -10792,15 +10723,15 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - pushEffect(hookEffectTag, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, destroy, nextDeps @@ -10960,128 +10891,124 @@ function updateMemo(nextCreate, deps) { return nextValue; } -function mountDeferredValue(value, config) { +function mountDeferredValue(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function updateDeferredValue(value, config) { +function updateDeferredValue(value) { var _updateState = updateState(), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function rerenderDeferredValue(value, config) { +function rerenderDeferredValue(value) { var _rerenderState = rerenderState(), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); - runWithPriority( - priorityLevel < UserBlockingPriority$1 - ? UserBlockingPriority$1 - : priorityLevel, - function() { - setPending(true); - } - ); // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition. - runWithPriority( - priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, - function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + { + runWithPriority( + priorityLevel < UserBlockingPriority$1 + ? UserBlockingPriority$1 + : priorityLevel, + function() { + setPending(true); } - } - ); + ); + runWithPriority( + priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, + function() { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } + } + ); + } } -function mountTransition(config) { +function mountTransition() { var _mountState2 = mountState(false), isPending = _mountState2[0], - setPending = _mountState2[1]; + setPending = _mountState2[1]; // The `start` method never changes. - var start = mountCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var start = startTransition.bind(null, setPending); + var hook = mountWorkInProgressHook(); + hook.memoizedState = start; return [start, isPending]; } -function updateTransition(config) { +function updateTransition() { var _updateState2 = updateState(), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } -function rerenderTransition(config) { +function rerenderTransition() { var _rerenderState2 = rerenderState(), - isPending = _rerenderState2[0], - setPending = _rerenderState2[1]; + isPending = _rerenderState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } @@ -11145,12 +11072,9 @@ function dispatchAction(fiber, queue, action) { } var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var lane = requestUpdateLane(fiber); var update = { - eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, action: action, eagerReducer: null, eagerState: null, @@ -11268,7 +11192,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; "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" + "https://reactjs.org/link/rules-of-hooks" ); }; @@ -11352,15 +11276,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11449,15 +11373,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11546,15 +11470,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11643,15 +11567,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11751,17 +11675,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11863,17 +11787,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11975,17 +11899,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -12203,7 +12127,7 @@ function updateForwardRef( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12268,7 +12192,7 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, renderLanes ); @@ -12309,7 +12233,7 @@ function updateMemoComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; var newChild = createWorkInProgress(currentChild, nextProps); newChild.ref = workInProgress.ref; newChild.return = workInProgress; @@ -12392,10 +12316,7 @@ function updateSimpleMemoComponent( workInProgress, renderLanes ); - } else if ( - (current.effectTag & ForceUpdateForLegacySuspense) !== - NoEffect - ) { + } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; @@ -12504,7 +12425,7 @@ function updateMode(current, workInProgress, renderLanes) { function updateProfiler(current, workInProgress, renderLanes) { { - workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase. + workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, var stateNode = workInProgress.stateNode; @@ -12526,7 +12447,7 @@ function markRef(current, workInProgress) { (current !== null && current.ref !== ref) ) { // Schedule a Ref effect - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } } @@ -12601,7 +12522,7 @@ function updateFunctionComponent( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12654,7 +12575,7 @@ function updateClassComponent( current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); @@ -12716,7 +12637,7 @@ function finishClassComponent( ) { // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); - var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; + var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags; if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering @@ -12765,7 +12686,7 @@ function finishClassComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (current !== null && didCaptureError) { // If we're recovering from an error, reconcile without reusing any of @@ -12852,7 +12773,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - node.effectTag = (node.effectTag & ~Placement) | Hydrating; + node.flags = (node.flags & ~Placement) | Hydrating; node = node.sibling; } } else { @@ -12875,7 +12796,7 @@ function updateHostComponent(current, workInProgress, renderLanes) { if (prevProps !== null && shouldSetTextContent()) { // If we're switching from a direct text child to a normal child, or to // empty, we need to schedule the text content to be reset. - workInProgress.effectTag |= ContentReset; + workInProgress.flags |= ContentReset; } markRef(current, workInProgress); @@ -12904,7 +12825,7 @@ function mountLazyComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } var props = workInProgress.pendingProps; @@ -13038,7 +12959,7 @@ function mountIncompleteClassComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // Promote the fiber to a class and try rendering again. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` @@ -13082,7 +13003,7 @@ function mountIndeterminateComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } var props = workInProgress.pendingProps; @@ -13132,7 +13053,7 @@ function mountIndeterminateComponent( setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; { // Support for module components is deprecated and is removed behind a flag. @@ -13346,7 +13267,7 @@ function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { return { baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) }; -} +} // TODO: Probably should inline this back function shouldRemainOnFallback( suspenseContext, @@ -13382,19 +13303,19 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { { if (shouldSuspend(workInProgress)) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } } var suspenseContext = suspenseStackCursor.current; var showFallback = false; - var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; + var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags; if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. showFallback = true; - workInProgress.effectTag &= ~DidCapture; + workInProgress.flags &= ~DidCapture; } else { // Attempting the main content if (current === null || current.memoizedState !== null) { @@ -13445,9 +13366,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // But only if this has a fallback. if (nextProps.fallback !== undefined); + var nextPrimaryChildren = nextProps.children; + var nextFallbackChildren = nextProps.fallback; + if (showFallback) { - var nextPrimaryChildren = nextProps.children; - var nextFallbackChildren = nextProps.fallback; var fallbackFragment = mountSuspenseFallbackChildren( workInProgress, nextPrimaryChildren, @@ -13460,11 +13382,41 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ); workInProgress.memoizedState = SUSPENDED_MARKER; return fallbackFragment; + } else if (typeof nextProps.unstable_expectedLoadTime === "number") { + // This is a CPU-bound tree. Skip this tree and show a placeholder to + // unblock the surrounding content. Then immediately retry after the + // initial commit. + var _fallbackFragment = mountSuspenseFallbackChildren( + workInProgress, + nextPrimaryChildren, + nextFallbackChildren, + renderLanes + ); + + var _primaryChildFragment = workInProgress.child; + _primaryChildFragment.memoizedState = mountSuspenseOffscreenState( + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to + // get it started back up to attempt the next item. While in terms of + // priority this work has the same priority as this current render, it's + // not part of the same transition once the transition has committed. If + // it's sync, we still want to yield so that it can be painted. + // Conceptually, this is really the same as pinging. We can use any + // RetryLane even if it's the one currently rendering since we're leaving + // it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + + return _fallbackFragment; } else { - var _nextPrimaryChildren = nextProps.children; return mountSuspensePrimaryChildren( workInProgress, - _nextPrimaryChildren, + nextPrimaryChildren, renderLanes ); } @@ -13477,63 +13429,63 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { if (prevState !== null) { if (showFallback) { var _nextFallbackChildren2 = nextProps.fallback; - var _nextPrimaryChildren3 = nextProps.children; + var _nextPrimaryChildren2 = nextProps.children; var _fallbackChildFragment = updateSuspenseFallbackChildren( current, workInProgress, - _nextPrimaryChildren3, + _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes ); - var _primaryChildFragment2 = workInProgress.child; + var _primaryChildFragment3 = workInProgress.child; var prevOffscreenState = current.child.memoizedState; - _primaryChildFragment2.memoizedState = + _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); - _primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree( + _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree( current, renderLanes ); workInProgress.memoizedState = SUSPENDED_MARKER; return _fallbackChildFragment; } else { - var _nextPrimaryChildren4 = nextProps.children; + var _nextPrimaryChildren3 = nextProps.children; - var _primaryChildFragment3 = updateSuspensePrimaryChildren( + var _primaryChildFragment4 = updateSuspensePrimaryChildren( current, workInProgress, - _nextPrimaryChildren4, + _nextPrimaryChildren3, renderLanes ); workInProgress.memoizedState = null; - return _primaryChildFragment3; + return _primaryChildFragment4; } } else { // The current tree is not already showing a fallback. if (showFallback) { // Timed out. var _nextFallbackChildren3 = nextProps.fallback; - var _nextPrimaryChildren5 = nextProps.children; + var _nextPrimaryChildren4 = nextProps.children; var _fallbackChildFragment2 = updateSuspenseFallbackChildren( current, workInProgress, - _nextPrimaryChildren5, + _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes ); - var _primaryChildFragment4 = workInProgress.child; + var _primaryChildFragment5 = workInProgress.child; var _prevOffscreenState = current.child.memoizedState; - _primaryChildFragment4.memoizedState = + _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); - _primaryChildFragment4.childLanes = getRemainingWorkInPrimaryTree( + _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree( current, renderLanes ); // Skip the primary children, and continue working on the @@ -13544,17 +13496,17 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } else { // Still haven't timed out. Continue rendering the children, like we // normally do. - var _nextPrimaryChildren6 = nextProps.children; + var _nextPrimaryChildren5 = nextProps.children; - var _primaryChildFragment5 = updateSuspensePrimaryChildren( + var _primaryChildFragment6 = updateSuspensePrimaryChildren( current, workInProgress, - _nextPrimaryChildren6, + _nextPrimaryChildren5, renderLanes ); workInProgress.memoizedState = null; - return _primaryChildFragment5; + return _primaryChildFragment6; } } } @@ -13674,7 +13626,7 @@ function updateSuspensePrimaryChildren( if (currentFallbackChildFragment !== null) { // Delete the fallback child fragment currentFallbackChildFragment.nextEffect = null; - currentFallbackChildFragment.effectTag = Deletion; + currentFallbackChildFragment.flags = Deletion; workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; } @@ -13765,7 +13717,7 @@ function updateSuspenseFallbackChildren( ); // Needs a placement effect because the parent (the Suspense boundary) already // mounted but this is a new fiber. - fallbackChildFragment.effectTag |= Placement; + fallbackChildFragment.flags |= Placement; } fallbackChildFragment.return = workInProgress; @@ -14028,7 +13980,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }; @@ -14039,7 +13990,6 @@ function initSuspenseListRenderState( renderState.renderingStartTime = 0; renderState.last = lastContentRow; renderState.tail = tail; - renderState.tailExpiration = 0; renderState.tailMode = tailMode; renderState.lastEffect = lastEffectBeforeRendering; } @@ -14071,10 +14021,10 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { suspenseContext, ForceSuspenseFallback ); - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } else { var didSuspendBefore = - current !== null && (current.effectTag & DidCapture) !== NoEffect; + current !== null && (current.flags & DidCapture) !== NoFlags; if (didSuspendBefore) { // If we previously forced a fallback, we need to schedule work @@ -14316,7 +14266,7 @@ function updateContextConsumer(current, workInProgress, renderLanes) { setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } @@ -14399,8 +14349,8 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } current.nextEffect = null; - current.effectTag = Deletion; - newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber. + current.flags = Deletion; + newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; } @@ -14485,7 +14435,7 @@ function beginWork(current, workInProgress, renderLanes) { ); if (hasChildWork) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -14549,7 +14499,7 @@ function beginWork(current, workInProgress, renderLanes) { } case SuspenseListComponent: { - var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; + var didSuspendBefore = (current.flags & DidCapture) !== NoFlags; var _hasChildWork = includesSomeLane( renderLanes, @@ -14572,7 +14522,7 @@ function beginWork(current, workInProgress, renderLanes) { // them got retried so they'll still be blocked in the same way // as before. We can fast bail out. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } // If nothing suspended before and we're rendering the same children, // then the tail doesn't matter. Anything new that suspends will work // in the "together" mode, so we can continue from the state we had. @@ -14616,7 +14566,7 @@ function beginWork(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else { - if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) { + if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; @@ -14839,11 +14789,11 @@ function beginWork(current, workInProgress, renderLanes) { function markUpdate(workInProgress) { // Tag the fiber with an update effect. This turns a Placement into // a PlacementAndUpdate. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } function markRef$1(workInProgress) { - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } var appendAllChildren; @@ -14888,7 +14838,7 @@ var updateHostText$1; appendInitialChild(parent, _instance); } else if (node.tag === HostPortal); else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoFlags) { // Need to toggle the visibility of the primary children. var newIsHidden = node.memoizedState !== null; @@ -14983,7 +14933,7 @@ var updateHostText$1; appendChildToContainerChildSet(containerChildSet, _instance3); } else if (node.tag === HostPortal); else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoFlags) { // Need to toggle the visibility of the primary children. var newIsHidden = node.memoizedState !== null; @@ -15264,7 +15214,7 @@ function completeWork(current, workInProgress, renderLanes) { // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null // if the previous render was null (so the the container would already be empty). - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } @@ -15380,7 +15330,7 @@ function completeWork(current, workInProgress, renderLanes) { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; - if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + if ((workInProgress.flags & DidCapture) !== NoFlags) { // Something suspended. Re-render with the fallback children. workInProgress.lanes = renderLanes; // Do not reset the effect list. @@ -15443,7 +15393,7 @@ function completeWork(current, workInProgress, renderLanes) { // If this boundary just timed out, schedule an effect to attach a // retry listener to the promise. This flag is also used to hide the // primary children. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -15487,8 +15437,7 @@ function completeWork(current, workInProgress, renderLanes) { return null; } - var didSuspendAlready = - (workInProgress.effectTag & DidCapture) !== NoEffect; + var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags; var renderedTail = renderState.rendering; if (renderedTail === null) { @@ -15505,7 +15454,7 @@ function completeWork(current, workInProgress, renderLanes) { // findFirstSuspended. var cannotBeSuspended = renderHasNotSuspendedYet() && - (current === null || (current.effectTag & DidCapture) === NoEffect); + (current === null || (current.flags & DidCapture) === NoFlags); if (!cannotBeSuspended) { var row = workInProgress.child; @@ -15515,7 +15464,7 @@ function completeWork(current, workInProgress, renderLanes) { if (suspended !== null) { didSuspendAlready = true; - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as // part of the second pass. In that case nothing will subscribe to // its thennables. Instead, we'll transfer its thennables to the @@ -15533,7 +15482,7 @@ function completeWork(current, workInProgress, renderLanes) { if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks // to stay in place. // Reset the effect list before doing the second pass since that's now invalid. @@ -15560,6 +15509,28 @@ function completeWork(current, workInProgress, renderLanes) { row = row.sibling; } } + + if (renderState.tail !== null && now() > getRenderTargetTime()) { + // We have already passed our CPU deadline but we still have rows + // left in the tail. We'll just give up further attempts to render + // the main content and only render fallbacks. + workInProgress.flags |= DidCapture; + didSuspendAlready = true; + cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + } } else { cutOffTailIfNeeded(renderState, false); } // Next we're going to render the tail. @@ -15569,7 +15540,7 @@ function completeWork(current, workInProgress, renderLanes) { var _suspended = findFirstSuspended(renderedTail); if (_suspended !== null) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't // get lost if this row ends up dropped during a second pass. @@ -15577,7 +15548,7 @@ function completeWork(current, workInProgress, renderLanes) { if (_newThennables !== null) { workInProgress.updateQueue = _newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } cutOffTailIfNeeded(renderState, true); // This might have been modified. @@ -15601,27 +15572,31 @@ function completeWork(current, workInProgress, renderLanes) { return null; } } else if ( - // The time it took to render last row is greater than time until - // the expiration. + // The time it took to render last row is greater than the remaining + // time we have to render. So rendering one more row would likely + // exceed it. now() * 2 - renderState.renderingStartTime > - renderState.tailExpiration && + getRenderTargetTime() && renderLanes !== OffscreenLane ) { // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. // The assumption is that this is usually faster. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this - // to get it started back up to attempt the next item. If we can show - // them, then they really have the same priority as this render. - // So we'll pick it back up the very next render pass once we've had - // an opportunity to yield for paint. + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. - workInProgress.lanes = renderLanes; + workInProgress.lanes = SomeRetryLane; { - markSpawnedWork(renderLanes); + markSpawnedWork(SomeRetryLane); } } } @@ -15649,18 +15624,7 @@ function completeWork(current, workInProgress, renderLanes) { if (renderState.tail !== null) { // We still have tail rows to render. - if (renderState.tailExpiration === 0) { - // Heuristic for how long we're willing to spend rendering rows - // until we just give up and show what we have so far. - var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this - // is a per component value. It should really be since the start - // of the total render or last commit. Consider using something like - // globalMostRecentFallbackTime. That doesn't account for being - // suspended for part of the time or when it's a new render. - // It should probably use a global start time value instead. - } // Pop a row. - + // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; @@ -15714,7 +15678,7 @@ function completeWork(current, workInProgress, renderLanes) { prevIsHidden !== nextIsHidden && newProps.mode !== "unstable-defer-without-hiding" ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -15740,10 +15704,10 @@ function unwindWork(workInProgress, renderLanes) { popContext(workInProgress); } - var effectTag = workInProgress.effectTag; + var flags = workInProgress.flags; - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; if ((workInProgress.mode & ProfileMode) !== NoMode) { transferActualDuration(workInProgress); @@ -15759,15 +15723,15 @@ function unwindWork(workInProgress, renderLanes) { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); resetWorkInProgressVersions(); - var _effectTag = workInProgress.effectTag; + var _flags = workInProgress.flags; - if (!((_effectTag & DidCapture) === NoEffect)) { + if (!((_flags & DidCapture) === NoFlags)) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); } - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; return workInProgress; } @@ -15780,10 +15744,10 @@ function unwindWork(workInProgress, renderLanes) { case SuspenseComponent: { popSuspenseContext(workInProgress); - var _effectTag2 = workInProgress.effectTag; + var _flags2 = workInProgress.flags; - if (_effectTag2 & ShouldCapture) { - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. + if (_flags2 & ShouldCapture) { + workInProgress.flags = (_flags2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. if ((workInProgress.mode & ProfileMode) !== NoMode) { transferActualDuration(workInProgress); @@ -15950,7 +15914,7 @@ function logCapturedError(boundary, errorInfo) { } else { 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."; + "Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries."; } var combinedMessage = @@ -15984,7 +15948,7 @@ function logCapturedError(boundary, errorInfo) { var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); // Unmount the root by rendering null. + var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property // being called "element". @@ -16003,7 +15967,7 @@ function createRootErrorUpdate(fiber, errorInfo, lane) { } function createClassErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); + var update = createUpdate(NoTimestamp, lane); update.tag = CaptureUpdate; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; @@ -16101,7 +16065,7 @@ function throwException( rootRenderLanes ) { // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. sourceFiber.firstEffect = sourceFiber.lastEffect = null; @@ -16161,12 +16125,12 @@ function throwException( // should *not* suspend the commit. if ((_workInProgress.mode & BlockingMode) === NoMode) { - _workInProgress.effectTag |= DidCapture; - sourceFiber.effectTag |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. + _workInProgress.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. // But we shouldn't call any lifecycle methods or callbacks. Remove // all lifecycle effect tags. - sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); if (sourceFiber.tag === ClassComponent) { var currentSourceFiber = sourceFiber.alternate; @@ -16180,7 +16144,7 @@ function throwException( // When we try rendering again, we should not reuse the current fiber, // since it's known to be in an inconsistent state. Use a force update to // prevent a bail out. - var update = createUpdate(NoTimestamp, SyncLane, null); + var update = createUpdate(NoTimestamp, SyncLane); update.tag = ForceUpdate; enqueueUpdate(sourceFiber, update); } @@ -16215,8 +16179,8 @@ function throwException( // that we can show the initial loading state as quickly as possible. // // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. // // If we're already showing a fallback and it gets "retried", allowing us to show // another level, but there's still an inner boundary that would show a fallback, @@ -16232,7 +16196,7 @@ function throwException( // ensure that new initial loading states can commit as soon as possible. attachPingListener(root, wakeable, rootRenderLanes); - _workInProgress.effectTag |= ShouldCapture; + _workInProgress.flags |= ShouldCapture; _workInProgress.lanes = rootRenderLanes; return; } // This boundary already captured during this render. Continue to the next @@ -16261,7 +16225,7 @@ function throwException( switch (workInProgress.tag) { case HostRoot: { var _errorInfo = value; - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); @@ -16278,13 +16242,13 @@ function throwException( var instance = workInProgress.stateNode; if ( - (workInProgress.effectTag & DidCapture) === NoEffect && + (workInProgress.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === "function" || (instance !== null && typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance))) ) { - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; var _lane = pickArbitraryLane(rootRenderLanes); @@ -16347,7 +16311,9 @@ function safelyDetachRef(current) { if (ref !== null) { if (typeof ref === "function") { { - invokeGuardedCallback(null, ref, null, null); + { + invokeGuardedCallback(null, ref, null, null); + } if (hasCaughtError()) { var refError = clearCaughtError(); @@ -16381,7 +16347,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } case ClassComponent: { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; @@ -16526,7 +16492,7 @@ function commitHookEffectListMount(tag, finishedWork) { " }\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"; + "Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching"; } else { addendum = " You returned: " + destroy; } @@ -16558,10 +16524,7 @@ function schedulePassiveEffects(finishedWork) { next = _effect.next, tag = _effect.tag; - if ( - (tag & Passive$1) !== NoEffect$1 && - (tag & HasEffect) !== NoEffect$1 - ) { + if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) { enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); enqueuePendingPassiveHookEffectMount(finishedWork, effect); } @@ -16592,7 +16555,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { case ClassComponent: { var instance = finishedWork.stateNode; - if (finishedWork.effectTag & Update) { + if (finishedWork.flags & Update) { if (current === null) { // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -16750,7 +16713,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. - if (current === null && finishedWork.effectTag & Update) { + if (current === null && finishedWork.flags & Update) { var type = finishedWork.type; var props = finishedWork.memoizedProps; commitMount(); @@ -16832,7 +16795,9 @@ function commitAttachRef(finishedWork) { } // Moved outside to ensure DCE works with this flag if (typeof ref === "function") { - ref(instanceToUse); + { + ref(instanceToUse); + } } else { { if (!ref.hasOwnProperty("current")) { @@ -16854,7 +16819,9 @@ function commitDetachRef(current) { if (currentRef !== null) { if (typeof currentRef === "function") { - currentRef(null); + { + currentRef(null); + } } else { currentRef.current = null; } @@ -16887,7 +16854,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { tag = _effect2.tag; if (destroy !== undefined) { - if ((tag & Passive$1) !== NoEffect$1) { + if ((tag & Passive$1) !== NoFlags$1) { enqueuePendingPassiveHookEffectUnmount(current, effect); } else { { @@ -17231,9 +17198,7 @@ var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root complet var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown -var workInProgressRootFatalError = null; -var workInProgressRootLatestSuspenseTimeout = NoTimestamp; -var workInProgressRootCanSuspendUsingConfig = null; // "Included" lanes refer to lanes that were worked on during this render. It's +var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's // slightly different than `renderLanes` because `renderLanes` can change as you // enter and exit an Offscreen tree. This value is the combination of all render // lanes for the entire render phase. @@ -17250,8 +17215,21 @@ var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallb // model where we don't commit new loading states in too quick succession. var globalMostRecentFallbackTime = 0; -var FALLBACK_THROTTLE_MS = 500; -var DEFAULT_TIMEOUT_MS = 5000; +var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering +// more and prefer CPU suspense heuristics instead. + +var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU +// suspense heuristics and opt out of rendering more content. + +var RENDER_TIMEOUT_MS = 500; + +function resetRenderTimer() { + workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS; +} + +function getRenderTargetTime() { + return workInProgressRootRenderTargetTime; +} var nextEffect = null; var hasUncaughtError = false; var firstUncaughtError = null; @@ -17303,7 +17281,7 @@ function requestEventTime() { currentEventTime = now(); return currentEventTime; } -function requestUpdateLane(fiber, suspenseConfig) { +function requestUpdateLane(fiber) { // Special cases var mode = fiber.mode; @@ -17332,16 +17310,9 @@ function requestUpdateLane(fiber, suspenseConfig) { currentEventWipLanes = workInProgressRootIncludedLanes; } - if (suspenseConfig !== null) { - // Use the size of the timeout as a heuristic to prioritize shorter - // transitions over longer ones. - // TODO: This will coerce numbers larger than 31 bits to 0. - var timeoutMs = suspenseConfig.timeoutMs; - var transitionLanePriority = - timeoutMs === undefined || (timeoutMs | 0) < 10000 - ? TransitionShortLanePriority - : TransitionLongLanePriority; + var isTransition = requestCurrentTransition() !== NoTransition; + if (isTransition) { if (currentEventPendingLanes !== NoLanes) { currentEventPendingLanes = mostRecentlyUpdatedRoot !== null @@ -17349,11 +17320,7 @@ function requestUpdateLane(fiber, suspenseConfig) { : NoLanes; } - return findTransitionLane( - transitionLanePriority, - currentEventWipLanes, - currentEventPendingLanes - ); + return findTransitionLane(currentEventWipLanes, currentEventPendingLanes); } // TODO: Remove this dependency on the Scheduler priority. // To do that, we're replacing it with an update lane priority. @@ -17466,6 +17433,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { // scheduleCallbackForFiber to preserve the ability to schedule a callback // without immediately flushing it. We only do this for user-initiated // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); flushSyncCallbackQueue(); } } @@ -17512,7 +17480,7 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { { if ( alternate === null && - (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect + (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags ) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } @@ -17529,7 +17497,7 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { alternate.childLanes = mergeLanes(alternate.childLanes, lane); } else { { - if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((parent.flags & (Placement | Hydrating)) !== NoFlags) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } } @@ -17615,7 +17583,7 @@ function ensureRootIsScheduled(root, currentTime) { } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. -function performConcurrentWorkOnRoot(root, didTimeout) { +function performConcurrentWorkOnRoot(root) { // Since we know we're in a React event, we can clear the current // event time. The next update will compute a new event time. currentEventTime = NoTimestamp; @@ -17650,18 +17618,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (lanes === NoLanes) { // Defensive coding. This is never expected to happen. return null; - } // TODO: We only check `didTimeout` defensively, to account for a Scheduler - // bug where `shouldYield` sometimes returns `true` even if `didTimeout` is - // true, which leads to an infinite loop. Once the bug in Scheduler is - // fixed, we can remove this, since we track expiration ourselves. - - if (didTimeout) { - // Something expired. Flush synchronously until there's no expired - // work left. - markRootExpired(root, lanes); // This will schedule a synchronous callback. - - ensureRootIsScheduled(root, now()); - return null; } var exitStatus = renderRootConcurrent(root, lanes); @@ -17711,7 +17667,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var finishedWork = root.current.alternate; root.finishedWork = finishedWork; root.finishedLanes = lanes; - finishConcurrentRender(root, finishedWork, exitStatus, lanes); + finishConcurrentRender(root, exitStatus, lanes); } ensureRootIsScheduled(root, now()); @@ -17725,7 +17681,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { return null; } -function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { +function finishConcurrentRender(root, exitStatus, lanes) { switch (exitStatus) { case RootIncomplete: case RootFatalErrored: { @@ -17794,64 +17750,36 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { case RootSuspendedWithDelay: { markRootSuspended$1(root, lanes); - if ( - // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() - ) { - // We're suspended in a state that should be avoided. We'll try to - // avoid committing it for as long as the timeouts let us. - var _nextLanes = getNextLanes(root, NoLanes); - - if (_nextLanes !== NoLanes) { - // There's additional work on this root. - break; - } - - var _suspendedLanes = root.suspendedLanes; - - if (!isSubsetOfLanes(_suspendedLanes, lanes)) { - // We should prefer to render the fallback of at the last - // suspended level. Ping the last suspended level to try - // rendering it again. - // FIXME: What if the suspended lanes are Idle? Should not restart. - var _eventTime = requestEventTime(); - - markRootPinged(root, _suspendedLanes); - break; - } + if (includesOnlyTransitions(lanes)) { + // This is a transition, so we should exit without committing a + // placeholder and without scheduling a timeout. Delay indefinitely + // until we receive more data. + break; + } + if (!shouldForceFlushFallbacksInDEV()) { + // This is not a transition, but we did trigger an avoided state. + // Schedule a placeholder to display after a short delay, using the Just + // Noticeable Difference. + // TODO: Is the JND optimization worth the added complexity? If this is + // the only reason we track the event time, then probably not. + // Consider removing. var mostRecentEventTime = getMostRecentEventTime(root, lanes); + var eventTimeMs = mostRecentEventTime; + var timeElapsedMs = now() - eventTimeMs; - var _msUntilTimeout; - - if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) { - // We have processed a suspense config whose expiration time we - // can use as the timeout. - _msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now(); - } else if (mostRecentEventTime === NoTimestamp) { - // This should never normally happen because only new updates - // cause delayed states, so we should have processed something. - // However, this could also happen in an offscreen tree. - _msUntilTimeout = 0; - } else { - // If we didn't process a suspense config, compute a JND based on - // the amount of time elapsed since the most recent event time. - var eventTimeMs = mostRecentEventTime; - var timeElapsedMs = now() - eventTimeMs; - _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; - } // Don't bother with a very short suspense time. + var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time. if (_msUntilTimeout > 10) { - // The render is suspended, it hasn't timed out, and there's no - // lower priority work to do. Instead of committing the fallback - // immediately, wait for more data to arrive. + // Instead of committing the fallback immediately, wait for more data + // to arrive. root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), _msUntilTimeout ); break; } - } // The work expired. Commit immediately. + } // Commit the placeholder. commitRoot(root); break; @@ -17859,33 +17787,6 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { case RootCompleted: { // The work completed. Ready to commit. - var _mostRecentEventTime = getMostRecentEventTime(root, lanes); - - if ( - // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() && - _mostRecentEventTime !== NoTimestamp && - workInProgressRootCanSuspendUsingConfig !== null - ) { - // If we have exceeded the minimum loading delay, which probably - // means we have shown a spinner already, we might have to suspend - // a bit longer to ensure that the spinner is shown for - // enough time. - var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay( - _mostRecentEventTime, - workInProgressRootCanSuspendUsingConfig - ); - - if (_msUntilTimeout2 > 10) { - markRootSuspended$1(root, lanes); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - _msUntilTimeout2 - ); - break; - } - } - commitRoot(root); break; } @@ -17998,6 +17899,7 @@ function batchedUpdates$1(fn, a) { if (executionContext === NoContext) { // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); flushSyncCallbackQueue(); } } @@ -18019,20 +17921,20 @@ function flushSync(fn, a) { executionContext |= BatchedContext; - try { - setCurrentUpdateLanePriority(SyncLanePriority); + { + try { + if (fn) { + return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); + } else { + return undefined; + } + } finally { + executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. + // Note that this will happen even if batchedUpdates is higher up + // the stack. - if (fn) { - return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); - } else { - return undefined; + flushSyncCallbackQueue(); } - } finally { - executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. - // Note that this will happen even if batchedUpdates is higher up - // the stack. - - flushSyncCallbackQueue(); } } function pushRenderLanes(fiber, lanes) { @@ -18075,8 +17977,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = NoTimestamp; - workInProgressRootCanSuspendUsingConfig = null; workInProgressRootSkippedLanes = NoLanes; workInProgressRootUpdatedLanes = NoLanes; workInProgressRootPingedLanes = NoLanes; @@ -18155,7 +18055,7 @@ function handleError(root, thrownValue) { } while (true); } -function pushDispatcher(root) { +function pushDispatcher() { var prevDispatcher = ReactCurrentDispatcher$2.current; ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; @@ -18190,27 +18090,6 @@ function popInteractions(prevInteractions) { function markCommitTimeOfFallback() { globalMostRecentFallbackTime = now(); } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - // Track the largest/latest timeout deadline in this batch. - // TODO: If there are two transitions in the same batch, shouldn't we - // choose the smaller one? Maybe this is because when an intermediate - // transition is superseded, we should ignore its suspense config, but - // we don't currently. - if (suspenseConfig !== null) { - // If `timeoutMs` is not specified, we default to 5 seconds. We have to - // resolve this default here because `suspenseConfig` is owned - // by userspace. - // TODO: Store this on the root instead (transition -> timeoutMs) - // TODO: Should this default to a JND instead? - var timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS; - var timeoutTime = eventTime + timeoutMs; - - if (timeoutTime > workInProgressRootLatestSuspenseTimeout) { - workInProgressRootLatestSuspenseTimeout = timeoutTime; - workInProgressRootCanSuspendUsingConfig = suspenseConfig; - } - } -} function markSkippedUpdateLanes(lane) { workInProgressRootSkippedLanes = mergeLanes( lane, @@ -18320,6 +18199,7 @@ function renderRootConcurrent(root, lanes) { // and prepare a fresh one. Otherwise we'll continue where we left off. if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + resetRenderTimer(); prepareFreshStack(root, lanes); startWorkOnPendingInteractions(root, lanes); } @@ -18403,7 +18283,7 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; // Check if the work completed or if something threw. - if ((completedWork.effectTag & Incomplete) === NoEffect) { + if ((completedWork.flags & Incomplete) === NoFlags) { setCurrentFiber(completedWork); var next = void 0; @@ -18428,7 +18308,7 @@ function completeUnitOfWork(unitOfWork) { if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete - (returnFiber.effectTag & Incomplete) === NoEffect + (returnFiber.flags & Incomplete) === NoFlags ) { // Append all the effects of the subtree and this fiber onto the effect // list of the parent. The completion order of the children affects the @@ -18450,11 +18330,11 @@ function completeUnitOfWork(unitOfWork) { // reusing children we'll schedule this effect onto itself since we're // at the end. - var effectTag = completedWork.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect + var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect // list. PerformedWork effect is read by React DevTools but shouldn't be // committed. - if (effectTag > PerformedWork) { + if (flags > PerformedWork) { if (returnFiber.lastEffect !== null) { returnFiber.lastEffect.nextEffect = completedWork; } else { @@ -18475,7 +18355,7 @@ function completeUnitOfWork(unitOfWork) { // back here again. // Since we're restarting, remove anything that is not a host effect // from the effect tag. - _next.effectTag &= HostEffectMask; + _next.flags &= HostEffectMask; workInProgress = _next; return; } @@ -18498,7 +18378,7 @@ function completeUnitOfWork(unitOfWork) { if (returnFiber !== null) { // Mark the parent fiber as incomplete and clear its effect list. returnFiber.firstEffect = returnFiber.lastEffect = null; - returnFiber.effectTag |= Incomplete; + returnFiber.flags |= Incomplete; } } @@ -18663,14 +18543,11 @@ function commitRootImpl(root, renderPriorityLevel) { workInProgressRoot = null; workInProgress = null; workInProgressRootRenderLanes = NoLanes; - } // This indicates that the last root we worked on is not the same one that - // we're committing now. This most commonly happens when a suspended root - // times out. - // Get the list of effects. + } // Get the list of effects. var firstEffect; - if (finishedWork.effectTag > PerformedWork) { + if (finishedWork.flags > PerformedWork) { // A fiber's effect list consists only of its children, not itself. So if // the root has an effect, we need to add it to the end of the list. The // resulting list is the set that would belong to the root's parent, if it @@ -18788,7 +18665,7 @@ function commitRootImpl(root, renderPriorityLevel) { popInteractions(prevInteractions); } - executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value. + executionContext = prevExecutionContext; } else { // No effects. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were @@ -18819,7 +18696,7 @@ function commitRootImpl(root, renderPriorityLevel) { var nextNextEffect = nextEffect.nextEffect; nextEffect.nextEffect = null; - if (nextEffect.effectTag & Deletion) { + if (nextEffect.flags & Deletion) { detachFiberAfterEffects(nextEffect); } @@ -18905,7 +18782,7 @@ function commitBeforeMutationEffects() { var current = nextEffect.alternate; if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - if ((nextEffect.effectTag & Deletion) !== NoEffect) { + if ((nextEffect.flags & Deletion) !== NoFlags) { if (doesFiberContain(nextEffect, focusedInstanceHandle)) { shouldFireAfterActiveInstanceBlur = true; } @@ -18921,15 +18798,15 @@ function commitBeforeMutationEffects() { } } - var effectTag = nextEffect.effectTag; + var flags = nextEffect.flags; - if ((effectTag & Snapshot) !== NoEffect) { + if ((flags & Snapshot) !== NoFlags) { setCurrentFiber(nextEffect); commitBeforeMutationLifeCycles(current, nextEffect); resetCurrentFiber(); } - if ((effectTag & Passive) !== NoEffect) { + if ((flags & Passive) !== NoFlags) { // If there are passive effects, schedule a callback to flush at // the earliest opportunity. if (!rootDoesHavePassiveEffects) { @@ -18949,9 +18826,9 @@ function commitMutationEffects(root, renderPriorityLevel) { // TODO: Should probably move the bulk of this function to commitWork. while (nextEffect !== null) { setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; + var flags = nextEffect.flags; - if (effectTag & Ref) { + if (flags & Ref) { var current = nextEffect.alternate; if (current !== null) { @@ -18962,23 +18839,22 @@ function commitMutationEffects(root, renderPriorityLevel) { // bitmap value, we remove the secondary effects from the effect tag and // switch on that value. - var primaryEffectTag = - effectTag & (Placement | Update | Deletion | Hydrating); + var primaryFlags = flags & (Placement | Update | Deletion | Hydrating); - switch (primaryEffectTag) { + switch (primaryFlags) { case Placement: { // inserted, before any life-cycles like componentDidMount gets called. // TODO: findDOMNode doesn't rely on this any more but isMounted does // and isMounted is deprecated anyway so we should be able to kill this. - nextEffect.effectTag &= ~Placement; + nextEffect.flags &= ~Placement; break; } case PlacementAndUpdate: { // inserted, before any life-cycles like componentDidMount gets called. - nextEffect.effectTag &= ~Placement; // Update + nextEffect.flags &= ~Placement; // Update var _current = nextEffect.alternate; commitWork(_current, nextEffect); @@ -18986,12 +18862,12 @@ function commitMutationEffects(root, renderPriorityLevel) { } case Hydrating: { - nextEffect.effectTag &= ~Hydrating; + nextEffect.flags &= ~Hydrating; break; } case HydratingAndUpdate: { - nextEffect.effectTag &= ~Hydrating; // Update + nextEffect.flags &= ~Hydrating; // Update var _current2 = nextEffect.alternate; commitWork(_current2, nextEffect); @@ -19018,15 +18894,15 @@ function commitMutationEffects(root, renderPriorityLevel) { function commitLayoutEffects(root, committedLanes) { while (nextEffect !== null) { setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; + var flags = nextEffect.flags; - if (effectTag & (Update | Callback)) { + if (flags & (Update | Callback)) { var current = nextEffect.alternate; commitLifeCycles(root, current, nextEffect); } { - if (effectTag & Ref) { + if (flags & Ref) { commitAttachRef(nextEffect); } } @@ -19045,12 +18921,8 @@ function flushPassiveEffects() { : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = NoPriority$1; - try { - setCurrentUpdateLanePriority( - schedulerPriorityToLanePriority(priorityLevel) - ); + { return runWithPriority(priorityLevel, flushPassiveEffectsImpl); - } finally { } } @@ -19071,11 +18943,11 @@ function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { pendingPassiveHookEffectsUnmount.push(effect, fiber); { - fiber.effectTag |= PassiveUnmountPendingDev; + fiber.flags |= PassiveUnmountPendingDev; var alternate = fiber.alternate; if (alternate !== null) { - alternate.effectTag |= PassiveUnmountPendingDev; + alternate.flags |= PassiveUnmountPendingDev; } } @@ -19131,11 +19003,11 @@ function flushPassiveEffectsImpl() { _effect.destroy = undefined; { - fiber.effectTag &= ~PassiveUnmountPendingDev; + fiber.flags &= ~PassiveUnmountPendingDev; var alternate = fiber.alternate; if (alternate !== null) { - alternate.effectTag &= ~PassiveUnmountPendingDev; + alternate.flags &= ~PassiveUnmountPendingDev; } } @@ -19198,7 +19070,7 @@ function flushPassiveEffectsImpl() { effect.nextEffect = null; - if (effect.effectTag & Deletion) { + if (effect.flags & Deletion) { detachFiberAfterEffects(effect); } @@ -19293,6 +19165,24 @@ function captureCommitPhaseError(sourceFiber, error) { markRootUpdated(root, SyncLane, eventTime); ensureRootIsScheduled(root, eventTime); schedulePendingInteractions(root, SyncLane); + } else { + // This component has already been unmounted. + // We can't schedule any follow up work for the root because the fiber is already unmounted, + // but we can still call the log-only boundary so the error isn't swallowed. + // + // TODO This is only a temporary bandaid for the old reconciler fork. + // We can delete this special case once the new fork is merged. + if ( + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance) + ) { + try { + instance.componentDidCatch(error, errorInfo); + } catch (errorToIgnore) { + // TODO Ignore this error? Rethrow it? + // This is kind of an edge case. + } + } } return; @@ -19407,33 +19297,6 @@ function jnd(timeElapsed) { : ceil(timeElapsed / 1960) * 1960; } -function computeMsUntilSuspenseLoadingDelay( - mostRecentEventTime, - suspenseConfig -) { - var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; - - if (busyMinDurationMs <= 0) { - return 0; - } - - var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. - - var currentTimeMs = now(); - var eventTimeMs = mostRecentEventTime; - var timeElapsed = currentTimeMs - eventTimeMs; - - if (timeElapsed <= busyDelayMs) { - // If we haven't yet waited longer than the initial delay, we don't - // have to wait any additional time. - return 0; - } - - var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`. - - return msUntilTimeout; -} - function checkForNestedUpdates() { if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { nestedUpdateCount = 0; @@ -19553,7 +19416,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { } // If there are pending passive effects unmounts for this Fiber, // we can assume that they would have prevented this update. - if ((fiber.effectTag & PassiveUnmountPendingDev) !== NoEffect) { + if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) { return; } // We show the whole stack but dedupe on the top component's name because // the problematic code almost always lies inside that component. @@ -19686,7 +19549,7 @@ function warnAboutRenderPhaseUpdatesInDEV(fiber) { error( "Cannot update a component (`%s`) while rendering a " + "different component (`%s`). To locate the bad setState() call inside `%s`, " + - "follow the stack trace as described in https://fb.me/setstate-in-render", + "follow the stack trace as described in https://reactjs.org/link/setstate-in-render", setStateComponentName, renderingComponentName, renderingComponentName @@ -19734,7 +19597,7 @@ function warnIfUnmockedScheduler(fiber) { "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + - "For more info, visit https://fb.me/react-mock-scheduler" + "For more info, visit https://reactjs.org/link/mock-scheduler" ); } else { didWarnAboutUnmockedScheduler = true; @@ -19745,7 +19608,7 @@ function warnIfUnmockedScheduler(fiber) { "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + - "For more info, visit https://fb.me/react-mock-scheduler" + "For more info, visit https://reactjs.org/link/mock-scheduler" ); } } @@ -19889,16 +19752,14 @@ function finishPendingInteractions(root, committedLanes) { }); } } // `act` testing API -// -// TODO: This is mostly a copy-paste from the legacy `act`, which does not have -// access to the same internals that we do here. Some trade offs in the -// implementation no longer make sense. - -var isFlushingAct = false; function shouldForceFlushFallbacksInDEV() { - return isFlushingAct; + // Never force flush in production. This function should get stripped out. + return actingUpdatesScopeDepth > 0; } +// so we can tell if any async act() calls try to run in parallel. + +var actingUpdatesScopeDepth = 0; function detachFiberAfterEffects(fiber) { fiber.sibling = null; @@ -20380,7 +20241,7 @@ function FiberNode(tag, pendingProps, key, mode) { this.dependencies = null; this.mode = mode; // Effects - this.effectTag = NoEffect; + this.flags = NoFlags; this.nextEffect = null; this.firstEffect = null; this.lastEffect = null; @@ -20510,7 +20371,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.type = current.type; // We already have an alternate. // Reset the effect tag. - workInProgress.effectTag = NoEffect; // The effect list is no longer valid. + workInProgress.flags = NoFlags; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -20584,7 +20445,7 @@ function resetWorkInProgress(workInProgress, renderLanes) { // avoid doing another reconciliation. // Reset the effect tag but keep any Placement tags, since that's something // that child fiber is setting, not the reconciliation. - workInProgress.effectTag &= Placement; // The effect list is no longer valid. + workInProgress.flags &= Placement; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -20793,6 +20654,11 @@ function createFiberFromTypeAndProps( fiber.elementType = type; fiber.type = resolvedType; fiber.lanes = lanes; + + { + fiber._debugOwner = owner; + } + return fiber; } function createFiberFromElement(element, mode, lanes) { @@ -20945,7 +20811,7 @@ function assignFiberPropertiesInDEV(target, source) { target.memoizedState = source.memoizedState; target.dependencies = source.dependencies; target.mode = source.mode; - target.effectTag = source.effectTag; + target.flags = source.flags; target.nextEffect = source.nextEffect; target.firstEffect = source.firstEffect; target.lastEffect = source.lastEffect; @@ -21111,7 +20977,7 @@ function findHostInstanceWithWarning(component, methodName) { "%s was passed an instance of %s which is inside StrictMode. " + "Instead, add a ref directly to the element you want to reference. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", + "https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName @@ -21122,7 +20988,7 @@ function findHostInstanceWithWarning(component, methodName) { "%s was passed an instance of %s which renders StrictMode children. " + "Instead, add a ref directly to the element you want to reference. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", + "https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName @@ -21162,8 +21028,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(current$1, suspenseConfig); + var lane = requestUpdateLane(current$1); var context = getContextForSubtree(parentComponent); @@ -21187,7 +21052,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var update = createUpdate(eventTime, lane, suspenseConfig); // Caution: React DevTools currently depends on this property + var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property // being called "element". update.payload = { @@ -21237,28 +21102,102 @@ function shouldSuspend(fiber) { return shouldSuspendImpl(fiber); } var overrideHookState = null; +var overrideHookStateDeletePath = null; +var overrideHookStateRenamePath = null; var overrideProps = null; +var overridePropsDeletePath = null; +var overridePropsRenamePath = null; var scheduleUpdate = null; var setSuspenseHandler = null; { - var copyWithSetImpl = function(obj, path, idx, value) { - if (idx >= path.length) { + var copyWithDeleteImpl = function(obj, path, index) { + var key = path[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === path.length) { + if (Array.isArray(updated)) { + updated.splice(key, 1); + } else { + delete updated[key]; + } + + return updated; + } // $FlowFixMe number or string is fine here + + updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); + return updated; + }; + + var copyWithDelete = function(obj, path) { + return copyWithDeleteImpl(obj, path, 0); + }; + + var copyWithRenameImpl = function(obj, oldPath, newPath, index) { + var oldKey = oldPath[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === oldPath.length) { + var newKey = newPath[index]; // $FlowFixMe number or string is fine here + + updated[newKey] = updated[oldKey]; + + if (Array.isArray(updated)) { + updated.splice(oldKey, 1); + } else { + delete updated[oldKey]; + } + } else { + // $FlowFixMe number or string is fine here + updated[oldKey] = copyWithRenameImpl( + // $FlowFixMe number or string is fine here + obj[oldKey], + oldPath, + newPath, + index + 1 + ); + } + + return updated; + }; + + var copyWithRename = function(obj, oldPath, newPath) { + if (oldPath.length !== newPath.length) { + warn("copyWithRename() expects paths of the same length"); + + return; + } else { + for (var i = 0; i < newPath.length - 1; i++) { + if (oldPath[i] !== newPath[i]) { + warn( + "copyWithRename() expects paths to be the same except for the deepest key" + ); + + return; + } + } + } + + return copyWithRenameImpl(obj, oldPath, newPath, 0); + }; + + var copyWithSetImpl = function(obj, path, index, value) { + if (index >= path.length) { return value; } - var key = path[idx]; + var key = path[index]; var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); // $FlowFixMe number or string is fine here - updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value); + updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); return updated; }; var copyWithSet = function(obj, path, value) { return copyWithSetImpl(obj, path, 0, value); - }; // Support DevTools editable values for useState and useReducer. + }; - overrideHookState = function(fiber, id, path, value) { + var findHook = function(fiber, id) { // For now, the "id" of stateful hooks is just the stateful hook index. // This may change in the future with e.g. nested hooks. var currentHook = fiber.memoizedState; @@ -21268,10 +21207,50 @@ var setSuspenseHandler = null; id--; } - if (currentHook !== null) { - var newState = copyWithSet(currentHook.memoizedState, path, value); - currentHook.memoizedState = newState; - currentHook.baseState = newState; // We aren't actually adding an update to the queue, + return currentHook; + }; // Support DevTools editable values for useState and useReducer. + + overrideHookState = function(fiber, id, path, value) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithSet(hook.memoizedState, path, value); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateDeletePath = function(fiber, id, path) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithDelete(hook.memoizedState, path); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithRename(hook.memoizedState, oldPath, newPath); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, // because there is no update we can add for useReducer hooks that won't trigger an error. // (There's no appropriate action type for DevTools overrides.) // As a result though, React will see the scheduled update as a noop and bailout. @@ -21292,6 +21271,26 @@ var setSuspenseHandler = null; scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; + overridePropsDeletePath = function(fiber, path) { + fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsRenamePath = function(fiber, oldPath, newPath) { + fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + scheduleUpdate = function(fiber) { scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; @@ -21328,7 +21327,11 @@ function injectIntoDevTools(devToolsConfig) { rendererPackageName: devToolsConfig.rendererPackageName, rendererConfig: devToolsConfig.rendererConfig, overrideHookState: overrideHookState, + overrideHookStateDeletePath: overrideHookStateDeletePath, + overrideHookStateRenamePath: overrideHookStateRenamePath, overrideProps: overrideProps, + overridePropsDeletePath: overridePropsDeletePath, + overridePropsRenamePath: overridePropsRenamePath, setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, @@ -21345,9 +21348,6 @@ function injectIntoDevTools(devToolsConfig) { }); } -// TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.0-alpha.0"; - var instanceCache = new Map(); function getInstanceFromTag(tag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.js b/Libraries/Renderer/implementations/ReactFabric-dev.js index 8e2baedcc4efc4..07748f8a596994 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.js @@ -24,21 +24,7 @@ var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. -// Current owner and dispatcher used to share the same ref, -// but PR #14548 split them out to better support the react-debug-tools package. - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; -} - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; -} + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // by calls to these methods by a Babel plugin. // @@ -80,19 +66,12 @@ function printWarning(level, format, args) { // When changing this logic, you might want to also // update consoleWithStackDev.www.js as well. { - var hasExistingStack = - args.length > 0 && - typeof args[args.length - 1] === "string" && - args[args.length - 1].indexOf("\n in") === 0; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); - if (!hasExistingStack) { - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - - if (stack !== "") { - format += "%s"; - args = args.concat([stack]); - } + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { @@ -104,161 +83,10 @@ function printWarning(level, format, args) { // eslint-disable-next-line react-internal/no-production-logging Function.prototype.apply.call(console[level], console, argsWithFormat); - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - } -} - -var FunctionComponent = 0; -var ClassComponent = 1; -var IndeterminateComponent = 2; // Before we know whether it is function or class - -var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - -var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - -var HostComponent = 5; -var HostText = 6; -var Fragment = 7; -var Mode = 8; -var ContextConsumer = 9; -var ContextProvider = 10; -var ForwardRef = 11; -var Profiler = 12; -var SuspenseComponent = 13; -var MemoComponent = 14; -var SimpleMemoComponent = 15; -var LazyComponent = 16; -var IncompleteClassComponent = 17; -var DehydratedFragment = 18; -var SuspenseListComponent = 19; -var FundamentalComponent = 20; -var ScopeComponent = 21; -var Block = 22; - -function getParent(inst) { - do { - inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. - // That is depending on if we want nested subtrees (layers) to bubble - // events to their parent. We could also go through parentNode on the - // host node but that wouldn't work for React Native and doesn't let us - // do the portal feature. - } while (inst && inst.tag !== HostComponent); - - if (inst) { - return inst; - } - - return null; -} -/** - * Return the lowest common ancestor of A and B, or null if they are in - * different trees. - */ - -function getLowestCommonAncestor(instA, instB) { - var depthA = 0; - - for (var tempA = instA; tempA; tempA = getParent(tempA)) { - depthA++; - } - - var depthB = 0; - - for (var tempB = instB; tempB; tempB = getParent(tempB)) { - depthB++; - } // If A is deeper, crawl up. - - while (depthA - depthB > 0) { - instA = getParent(instA); - depthA--; - } // If B is deeper, crawl up. - - while (depthB - depthA > 0) { - instB = getParent(instB); - depthB--; - } // Walk in lockstep until we find a match. - - var depth = depthA; - - while (depth--) { - if (instA === instB || instA === instB.alternate) { - return instA; - } - - instA = getParent(instA); - instB = getParent(instB); - } - - return null; -} -/** - * Return if A is an ancestor of B. - */ - -function isAncestor(instA, instB) { - while (instB) { - if (instA === instB || instA === instB.alternate) { - return true; - } - - instB = getParent(instB); - } - - return false; -} -/** - * Return the parent instance of the passed-in instance. - */ - -function getParentInstance(inst) { - return getParent(inst); -} -/** - * Simulates the traversal of a two-phase, capture/bubble event dispatch. - */ - -function traverseTwoPhase(inst, fn, arg) { - var path = []; - - while (inst) { - path.push(inst); - inst = getParent(inst); - } - - var i; - - for (i = path.length; i-- > 0; ) { - fn(path[i], "captured", arg); - } - - for (i = 0; i < path.length; i++) { - fn(path[i], "bubbled", arg); } } -var invokeGuardedCallbackImpl = function( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { +function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -266,7 +94,9 @@ var invokeGuardedCallbackImpl = function( } catch (error) { this.onError(error); } -}; +} + +var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; { // In DEV mode, we swap out invokeGuardedCallback for a special version @@ -297,7 +127,7 @@ var invokeGuardedCallbackImpl = function( ) { var fakeNode = document.createElement("react"); - var invokeGuardedCallbackDev = function( + invokeGuardedCallbackImpl = function invokeGuardedCallbackDev( name, func, context, @@ -310,7 +140,7 @@ var invokeGuardedCallbackImpl = function( ) { // If document doesn't exist we know for sure we will crash in this method // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebookincubator/create-react-app/issues/3482 + // errors: https://github.com/facebook/create-react-app/issues/3482 // So we preemptively throw with a better message instead. if (!(typeof document !== "undefined")) { throw Error( @@ -318,7 +148,8 @@ var invokeGuardedCallbackImpl = function( ); } - var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We + var evt = document.createEvent("Event"); + var didCall = false; // Keeps track of whether the user-provided callback threw an error. We // set this to true at the beginning, then set it to false right after // calling the function. If the function errors, `didError` will never be // set to false. This strategy works even if the browser is flaky and @@ -335,13 +166,9 @@ var invokeGuardedCallbackImpl = function( var windowEventDescriptor = Object.getOwnPropertyDescriptor( window, "event" - ); // Create an event handler for our fake event. We will synchronously - // dispatch our fake event using `dispatchEvent`. Inside the handler, we - // call the user-provided callback. - - var funcArgs = Array.prototype.slice.call(arguments, 3); + ); - function callCallback() { + function restoreAfterDispatch() { // We immediately remove the callback from event listeners so that // nested `invokeGuardedCallback` calls do not clash. Otherwise, a // nested call would trigger the fake event handlers of any call higher @@ -357,7 +184,15 @@ var invokeGuardedCallbackImpl = function( ) { window.event = windowEvent; } + } // Create an event handler for our fake event. We will synchronously + // dispatch our fake event using `dispatchEvent`. Inside the handler, we + // call the user-provided callback. + + var funcArgs = Array.prototype.slice.call(arguments, 3); + function callCallback() { + didCall = true; + restoreAfterDispatch(); func.apply(context, funcArgs); didError = false; } // Create a global error event handler. We use this to capture the value @@ -412,7 +247,7 @@ var invokeGuardedCallbackImpl = function( Object.defineProperty(window, "event", windowEventDescriptor); } - if (didError) { + if (didCall && didError) { if (!didSetError) { // The callback errored, but the error event never fired. error = new Error( @@ -429,7 +264,7 @@ var invokeGuardedCallbackImpl = function( 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." + "See https://reactjs.org/link/crossorigin-error for more information." ); } @@ -437,9 +272,16 @@ var invokeGuardedCallbackImpl = function( } // Remove our event listeners window.removeEventListener("error", handleWindowError); - }; - invokeGuardedCallbackImpl = invokeGuardedCallbackDev; + if (!didCall) { + // Something went really wrong, and our event was not dispatched. + // https://github.com/facebook/react/issues/16734 + // https://github.com/facebook/react/issues/16585 + // Fall back to the production implementation. + restoreAfterDispatch(); + return invokeGuardedCallbackProd.apply(this, arguments); + } + }; } } @@ -708,293 +550,53 @@ function hasDispatches(event) { return !!event._dispatchListeners; } -function isInteractive(tag) { - return ( - tag === "button" || - tag === "input" || - tag === "select" || - tag === "textarea" - ); -} - -function shouldPreventMouseEvent(name, type, props) { - switch (name) { - case "onClick": - case "onClickCapture": - case "onDoubleClick": - case "onDoubleClickCapture": - case "onMouseDown": - case "onMouseDownCapture": - case "onMouseMove": - case "onMouseMoveCapture": - case "onMouseUp": - case "onMouseUpCapture": - case "onMouseEnter": - return !!(props.disabled && isInteractive(type)); - - default: - return false; - } -} +var EVENT_POOL_SIZE = 10; /** - * @param {object} inst The instance, which is the source of events. - * @param {string} registrationName Name of listener (e.g. `onClick`). - * @return {?function} The stored callback. + * @interface Event + * @see http://www.w3.org/TR/DOM-Level-3-Events/ */ -function getListener(inst, registrationName) { - var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not - // live here; needs to be moved to a better place soon - - var stateNode = inst.stateNode; - - if (!stateNode) { - // Work in progress (ex: onload events in incremental mode). - return null; - } - - var props = getFiberCurrentPropsFromNode(stateNode); - - if (!props) { - // Work in progress. - return null; - } - - listener = props[registrationName]; - - if (shouldPreventMouseEvent(registrationName, inst.type, props)) { +var EventInterface = { + type: null, + target: null, + // currentTarget is set when dispatching; no use in copying it here + currentTarget: function() { return null; - } - - if (!(!listener || typeof listener === "function")) { - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - } + }, + eventPhase: null, + bubbles: null, + cancelable: null, + timeStamp: function(event) { + return event.timeStamp || Date.now(); + }, + defaultPrevented: null, + isTrusted: null +}; - return listener; +function functionThatReturnsTrue() { + return true; } +function functionThatReturnsFalse() { + return false; +} /** - * Accumulates items that must not be null or undefined into the first one. This - * is used to conserve memory by avoiding array allocations, and thus sacrifices - * API cleanness. Since `current` can be null before being passed in and not - * null after this function, make sure to assign it back to `current`: + * Synthetic events are dispatched by event plugins, typically in response to a + * top-level event delegation handler. * - * `a = accumulateInto(a, b);` + * These systems should generally use pooling to reduce the frequency of garbage + * collection. The system should check `isPersistent` to determine whether the + * event should be released into the pool after being dispatched. Users that + * need a persisted event should invoke `persist`. * - * This API should be sparingly used. Try `accumulate` for something cleaner. + * Synthetic events (and subclasses) implement the DOM Level 3 Events API by + * normalizing browser quirks. Subclasses do not necessarily have to implement a + * DOM interface; custom application-specific events can also subclass this. * - * @return {*|array<*>} An accumulation of items. - */ - -function accumulateInto(current, next) { - if (!(next != null)) { - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - } - - if (current == null) { - return next; - } // Both are not empty. Warning: Never call x.concat(y) when you are not - // certain that x is an Array (x could be a string with concat method). - - if (Array.isArray(current)) { - if (Array.isArray(next)) { - current.push.apply(current, next); - return current; - } - - current.push(next); - return current; - } - - if (Array.isArray(next)) { - // A bit too dangerous to mutate `next`. - return [current].concat(next); - } - - return [current, next]; -} - -/** - * @param {array} arr an "accumulation" of items which is either an Array or - * a single item. Useful when paired with the `accumulate` module. This is a - * simple utility that allows us to reason about a collection of items, but - * handling the case when there is exactly one item (and we do not need to - * allocate an array). - * @param {function} cb Callback invoked with each element or a collection. - * @param {?} [scope] Scope used as `this` in a callback. - */ -function forEachAccumulated(arr, cb, scope) { - if (Array.isArray(arr)) { - arr.forEach(cb, scope); - } else if (arr) { - cb.call(scope, arr); - } -} - -/** - * Some event types have a notion of different registration names for different - * "phases" of propagation. This finds listeners by a given phase. - */ -function listenerAtPhase(inst, event, propagationPhase) { - var registrationName = - event.dispatchConfig.phasedRegistrationNames[propagationPhase]; - return getListener(inst, registrationName); -} -/** - * A small set of propagation patterns, each of which will accept a small amount - * of information, and generate a set of "dispatch ready event objects" - which - * are sets of events that have already been annotated with a set of dispatched - * listener functions/ids. The API is designed this way to discourage these - * propagation strategies from actually executing the dispatches, since we - * always want to collect the entire set of dispatches before executing even a - * single one. - */ - -/** - * Tags a `SyntheticEvent` with dispatched listeners. Creating this function - * here, allows us to not have to bind or create functions for each event. - * Mutating the event's members allows us to not have to create a wrapping - * "dispatch" object that pairs the event with the listener. - */ - -function accumulateDirectionalDispatches(inst, phase, event) { - { - if (!inst) { - error("Dispatching inst must not be null"); - } - } - - var listener = listenerAtPhase(inst, event, phase); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } -} -/** - * Collect dispatches (must be entirely collected before dispatching - see unit - * tests). Lazily allocate the array to conserve memory. We must loop through - * each event and perform the traversal for each one. We cannot perform a - * single traversal for the entire collection of events because each event may - * have a different target. - */ - -function accumulateTwoPhaseDispatchesSingle(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); - } -} -/** - * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. - */ - -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - var parentInst = targetInst ? getParentInstance(targetInst) : null; - traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); - } -} -/** - * Accumulates without regard to direction, does not look for phased - * registration names. Same as `accumulateDirectDispatchesSingle` but without - * requiring that the `dispatchMarker` be the same as the dispatched ID. - */ - -function accumulateDispatches(inst, ignoredDirection, event) { - if (inst && event && event.dispatchConfig.registrationName) { - var registrationName = event.dispatchConfig.registrationName; - var listener = getListener(inst, registrationName); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } - } -} -/** - * Accumulates dispatches on an `SyntheticEvent`, but only for the - * `dispatchMarker`. - * @param {SyntheticEvent} event - */ - -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - accumulateDispatches(event._targetInst, null, event); - } -} - -function accumulateTwoPhaseDispatches(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); -} -function accumulateTwoPhaseDispatchesSkipTarget(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); -} -function accumulateDirectDispatches(events) { - forEachAccumulated(events, accumulateDirectDispatchesSingle); -} - -var EVENT_POOL_SIZE = 10; -/** - * @interface Event - * @see http://www.w3.org/TR/DOM-Level-3-Events/ - */ - -var EventInterface = { - type: null, - target: null, - // currentTarget is set when dispatching; no use in copying it here - currentTarget: function() { - return null; - }, - eventPhase: null, - bubbles: null, - cancelable: null, - timeStamp: function(event) { - return event.timeStamp || Date.now(); - }, - defaultPrevented: null, - isTrusted: null -}; - -function functionThatReturnsTrue() { - return true; -} - -function functionThatReturnsFalse() { - return false; -} -/** - * Synthetic events are dispatched by event plugins, typically in response to a - * top-level event delegation handler. - * - * These systems should generally use pooling to reduce the frequency of garbage - * collection. The system should check `isPersistent` to determine whether the - * event should be released into the pool after being dispatched. Users that - * need a persisted event should invoke `persist`. - * - * Synthetic events (and subclasses) implement the DOM Level 3 Events API by - * normalizing browser quirks. Subclasses do not necessarily have to implement a - * DOM interface; custom application-specific events can also subclass this. - * - * @param {object} dispatchConfig Configuration used to dispatch this event. - * @param {*} targetInst Marker identifying the event target. - * @param {object} nativeEvent Native browser event. - * @param {DOMEventTarget} nativeEventTarget Target node. + * @param {object} dispatchConfig Configuration used to dispatch this event. + * @param {*} targetInst Marker identifying the event target. + * @param {object} nativeEvent Native browser event. + * @param {DOMEventTarget} nativeEventTarget Target node. */ function SyntheticEvent( @@ -1015,6 +617,8 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; + this._dispatchListeners = null; + this._dispatchInstances = null; var Interface = this.constructor.Interface; for (var propName in Interface) { @@ -1203,13 +807,6 @@ addEventPoolingTo(SyntheticEvent); */ function getPooledWarningPropertyDefinition(propName, getVal) { - var isFunction = typeof getVal === "function"; - return { - configurable: true, - set: set, - get: get - }; - function set(val) { var action = isFunction ? "setting the method" : "setting the property"; warn(action, "This is effectively a no-op"); @@ -1231,16 +828,28 @@ function getPooledWarningPropertyDefinition(propName, getVal) { "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", + "See https://reactjs.org/link/event-pooling for more information.", action, propName, result ); } } + + var isFunction = typeof getVal === "function"; + return { + configurable: true, + set: set, + get: get + }; } -function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { +function createOrGetPooledEvent( + dispatchConfig, + targetInst, + nativeEvent, + nativeInst +) { var EventConstructor = this; if (EventConstructor.eventPool.length) { @@ -1280,8 +889,8 @@ function releasePooledEvent(event) { } function addEventPoolingTo(EventConstructor) { + EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; - EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } @@ -1547,50 +1156,139 @@ function accumulate(current, next) { } /** - * Instance of element that should respond to touch/move types of interactions, - * as indicated explicitly by relevant callbacks. + * Accumulates items that must not be null or undefined into the first one. This + * is used to conserve memory by avoiding array allocations, and thus sacrifices + * API cleanness. Since `current` can be null before being passed in and not + * null after this function, make sure to assign it back to `current`: + * + * `a = accumulateInto(a, b);` + * + * This API should be sparingly used. Try `accumulate` for something cleaner. + * + * @return {*|array<*>} An accumulation of items. */ -var responderInst = null; -/** - * Count of current touches. A textInput should become responder iff the - * selection changes while there is a touch on the screen. - */ +function accumulateInto(current, next) { + if (!(next != null)) { + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } -var trackedTouchCount = 0; + if (current == null) { + return next; + } // Both are not empty. Warning: Never call x.concat(y) when you are not + // certain that x is an Array (x could be a string with concat method). -var changeResponder = function(nextResponderInst, blockHostResponder) { - var oldResponderInst = responderInst; - responderInst = nextResponderInst; + if (Array.isArray(current)) { + if (Array.isArray(next)) { + current.push.apply(current, next); + return current; + } - if (ResponderEventPlugin.GlobalResponderHandler !== null) { - ResponderEventPlugin.GlobalResponderHandler.onChange( - oldResponderInst, - nextResponderInst, - blockHostResponder - ); + current.push(next); + return current; } -}; -var eventTypes = { - /** - * On a `touchStart`/`mouseDown`, is it desired that this element become the - * responder? - */ - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" - }, - dependencies: startDependencies - }, + if (Array.isArray(next)) { + // A bit too dangerous to mutate `next`. + return [current].concat(next); + } - /** - * On a `scroll`, is it desired that this element become the responder? This - * is usually not needed, but should be used to retroactively infer that a - * `touchStart` had occurred during momentum scroll. During a momentum scroll, - * a touch start will be immediately followed by a scroll event if the view is - * currently scrolling. + return [current, next]; +} + +/** + * @param {array} arr an "accumulation" of items which is either an Array or + * a single item. Useful when paired with the `accumulate` module. This is a + * simple utility that allows us to reason about a collection of items, but + * handling the case when there is exactly one item (and we do not need to + * allocate an array). + * @param {function} cb Callback invoked with each element or a collection. + * @param {?} [scope] Scope used as `this` in a callback. + */ +function forEachAccumulated(arr, cb, scope) { + if (Array.isArray(arr)) { + arr.forEach(cb, scope); + } else if (arr) { + cb.call(scope, arr); + } +} + +var FunctionComponent = 0; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class + +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; +var DehydratedFragment = 18; +var SuspenseListComponent = 19; +var FundamentalComponent = 20; +var ScopeComponent = 21; +var Block = 22; +var OffscreenComponent = 23; +var LegacyHiddenComponent = 24; + +/** + * Instance of element that should respond to touch/move types of interactions, + * as indicated explicitly by relevant callbacks. + */ + +var responderInst = null; +/** + * Count of current touches. A textInput should become responder iff the + * selection changes while there is a touch on the screen. + */ + +var trackedTouchCount = 0; + +var changeResponder = function(nextResponderInst, blockHostResponder) { + var oldResponderInst = responderInst; + responderInst = nextResponderInst; + + if (ResponderEventPlugin.GlobalResponderHandler !== null) { + ResponderEventPlugin.GlobalResponderHandler.onChange( + oldResponderInst, + nextResponderInst, + blockHostResponder + ); + } +}; + +var eventTypes = { + /** + * On a `touchStart`/`mouseDown`, is it desired that this element become the + * responder? + */ + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" + }, + dependencies: startDependencies + }, + + /** + * On a `scroll`, is it desired that this element become the responder? This + * is usually not needed, but should be used to retroactively infer that a + * `touchStart` had occurred during momentum scroll. During a momentum scroll, + * a touch start will be immediately followed by a scroll event if the view is + * currently scrolling. * * TODO: This shouldn't bubble. */ @@ -1664,154 +1362,362 @@ var eventTypes = { registrationName: "onResponderTerminate", dependencies: [] } -}; +}; // Start of inline: the below functions were inlined from +// EventPropagator.js, as they deviated from ReactDOM's newer +// implementations. + +function getParent(inst) { + do { + inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. + // That is depending on if we want nested subtrees (layers) to bubble + // events to their parent. We could also go through parentNode on the + // host node but that wouldn't work for React Native and doesn't let us + // do the portal feature. + } while (inst && inst.tag !== HostComponent); + + if (inst) { + return inst; + } + + return null; +} /** - * - * Responder System: - * ---------------- - * - * - A global, solitary "interaction lock" on a view. - * - If a node becomes the responder, it should convey visual feedback - * immediately to indicate so, either by highlighting or moving accordingly. - * - To be the responder means, that touches are exclusively important to that - * responder view, and no other view. - * - While touches are still occurring, the responder lock can be transferred to - * a new view, but only to increasingly "higher" views (meaning ancestors of - * the current responder). - * - * Responder being granted: - * ------------------------ - * - * - Touch starts, moves, and scrolls can cause an ID to become the responder. - * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to - * the "appropriate place". - * - If nothing is currently the responder, the "appropriate place" is the - * initiating event's `targetID`. - * - If something *is* already the responder, the "appropriate place" is the - * first common ancestor of the event target and the current `responderInst`. - * - Some negotiation happens: See the timing diagram below. - * - Scrolled views automatically become responder. The reasoning is that a - * platform scroll view that isn't built on top of the responder system has - * began scrolling, and the active responder must now be notified that the - * interaction is no longer locked to it - the system has taken over. - * - * - Responder being released: - * As soon as no more touches that *started* inside of descendants of the - * *current* responderInst, an `onResponderRelease` event is dispatched to the - * current responder, and the responder lock is released. - * - * TODO: - * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that - * determines if the responder lock should remain. - * - If a view shouldn't "remain" the responder, any active touches should by - * default be considered "dead" and do not influence future negotiations or - * bubble paths. It should be as if those touches do not exist. - * -- For multitouch: Usually a translate-z will choose to "remain" responder - * after one out of many touches ended. For translate-y, usually the view - * doesn't wish to "remain" responder after one of many touches end. - * - Consider building this on top of a `stopPropagation` model similar to - * `W3C` events. - * - Ensure that `onResponderTerminate` is called on touch cancels, whether or - * not `onResponderTerminationRequest` returns `true` or `false`. - * + * Return the lowest common ancestor of A and B, or null if they are in + * different trees. */ -/* Negotiation Performed - +-----------------------+ - / \ -Process low level events to + Current Responder + wantsResponderID -determine who to perform negot-| (if any exists at all) | -iation/transition | Otherwise just pass through| --------------------------------+----------------------------+------------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchStart| | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderReject - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderStart| - | | +----------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchMove | | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderRejec| - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderMove | - | | +----------------+ - | | - | | - Some active touch started| | - inside current responder | +------------------------+ | - +------------------------->| onResponderEnd | | - | | +------------------------+ | - +---+---------+ | | - | onTouchEnd | | | - +---+---------+ | | - | | +------------------------+ | - +------------------------->| onResponderEnd | | - No active touches started| +-----------+------------+ | - inside current responder | | | - | v | - | +------------------------+ | - | | onResponderRelease | | - | +------------------------+ | - | | - + + */ +function getLowestCommonAncestor(instA, instB) { + var depthA = 0; -/** - * A note about event ordering in the `EventPluginRegistry`. - * - * Suppose plugins are injected in the following order: - * - * `[R, S, C]` - * - * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for - * `onClick` etc) and `R` is `ResponderEventPlugin`. - * - * "Deferred-Dispatched Events": - * - * - The current event plugin system will traverse the list of injected plugins, - * in order, and extract events by collecting the plugin's return value of - * `extractEvents()`. - * - These events that are returned from `extractEvents` are "deferred - * dispatched events". + for (var tempA = instA; tempA; tempA = getParent(tempA)) { + depthA++; + } + + var depthB = 0; + + for (var tempB = instB; tempB; tempB = getParent(tempB)) { + depthB++; + } // If A is deeper, crawl up. + + while (depthA - depthB > 0) { + instA = getParent(instA); + depthA--; + } // If B is deeper, crawl up. + + while (depthB - depthA > 0) { + instB = getParent(instB); + depthB--; + } // Walk in lockstep until we find a match. + + var depth = depthA; + + while (depth--) { + if (instA === instB || instA === instB.alternate) { + return instA; + } + + instA = getParent(instA); + instB = getParent(instB); + } + + return null; +} +/** + * Return if A is an ancestor of B. + */ + +function isAncestor(instA, instB) { + while (instB) { + if (instA === instB || instA === instB.alternate) { + return true; + } + + instB = getParent(instB); + } + + return false; +} +/** + * Simulates the traversal of a two-phase, capture/bubble event dispatch. + */ + +function traverseTwoPhase(inst, fn, arg) { + var path = []; + + while (inst) { + path.push(inst); + inst = getParent(inst); + } + + var i; + + for (i = path.length; i-- > 0; ) { + fn(path[i], "captured", arg); + } + + for (i = 0; i < path.length; i++) { + fn(path[i], "bubbled", arg); + } +} + +function getListener(inst, registrationName) { + var stateNode = inst.stateNode; + + if (stateNode === null) { + // Work in progress (ex: onload events in incremental mode). + return null; + } + + var props = getFiberCurrentPropsFromNode(stateNode); + + if (props === null) { + // Work in progress. + return null; + } + + var listener = props[registrationName]; + + if (!(!listener || typeof listener === "function")) { + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + + return listener; +} + +function listenerAtPhase(inst, event, propagationPhase) { + var registrationName = + event.dispatchConfig.phasedRegistrationNames[propagationPhase]; + return getListener(inst, registrationName); +} + +function accumulateDirectionalDispatches(inst, phase, event) { + { + if (!inst) { + error("Dispatching inst must not be null"); + } + } + + var listener = listenerAtPhase(inst, event, phase); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } +} +/** + * Accumulates without regard to direction, does not look for phased + * registration names. Same as `accumulateDirectDispatchesSingle` but without + * requiring that the `dispatchMarker` be the same as the dispatched ID. + */ + +function accumulateDispatches(inst, ignoredDirection, event) { + if (inst && event && event.dispatchConfig.registrationName) { + var registrationName = event.dispatchConfig.registrationName; + var listener = getListener(inst, registrationName); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } + } +} +/** + * Accumulates dispatches on an `SyntheticEvent`, but only for the + * `dispatchMarker`. + * @param {SyntheticEvent} event + */ + +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + accumulateDispatches(event._targetInst, null, event); + } +} + +function accumulateDirectDispatches(events) { + forEachAccumulated(events, accumulateDirectDispatchesSingle); +} + +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + var parentInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); + } +} + +function accumulateTwoPhaseDispatchesSkipTarget(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); +} + +function accumulateTwoPhaseDispatchesSingle(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); + } +} + +function accumulateTwoPhaseDispatches(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); +} // End of inline + +/** + * + * Responder System: + * ---------------- + * + * - A global, solitary "interaction lock" on a view. + * - If a node becomes the responder, it should convey visual feedback + * immediately to indicate so, either by highlighting or moving accordingly. + * - To be the responder means, that touches are exclusively important to that + * responder view, and no other view. + * - While touches are still occurring, the responder lock can be transferred to + * a new view, but only to increasingly "higher" views (meaning ancestors of + * the current responder). + * + * Responder being granted: + * ------------------------ + * + * - Touch starts, moves, and scrolls can cause an ID to become the responder. + * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to + * the "appropriate place". + * - If nothing is currently the responder, the "appropriate place" is the + * initiating event's `targetID`. + * - If something *is* already the responder, the "appropriate place" is the + * first common ancestor of the event target and the current `responderInst`. + * - Some negotiation happens: See the timing diagram below. + * - Scrolled views automatically become responder. The reasoning is that a + * platform scroll view that isn't built on top of the responder system has + * began scrolling, and the active responder must now be notified that the + * interaction is no longer locked to it - the system has taken over. + * + * - Responder being released: + * As soon as no more touches that *started* inside of descendants of the + * *current* responderInst, an `onResponderRelease` event is dispatched to the + * current responder, and the responder lock is released. + * + * TODO: + * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that + * determines if the responder lock should remain. + * - If a view shouldn't "remain" the responder, any active touches should by + * default be considered "dead" and do not influence future negotiations or + * bubble paths. It should be as if those touches do not exist. + * -- For multitouch: Usually a translate-z will choose to "remain" responder + * after one out of many touches ended. For translate-y, usually the view + * doesn't wish to "remain" responder after one of many touches end. + * - Consider building this on top of a `stopPropagation` model similar to + * `W3C` events. + * - Ensure that `onResponderTerminate` is called on touch cancels, whether or + * not `onResponderTerminationRequest` returns `true` or `false`. + * + */ + +/* Negotiation Performed + +-----------------------+ + / \ +Process low level events to + Current Responder + wantsResponderID +determine who to perform negot-| (if any exists at all) | +iation/transition | Otherwise just pass through| +-------------------------------+----------------------------+------------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchStart| | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderReject + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderStart| + | | +----------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchMove | | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderRejec| + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderMove | + | | +----------------+ + | | + | | + Some active touch started| | + inside current responder | +------------------------+ | + +------------------------->| onResponderEnd | | + | | +------------------------+ | + +---+---------+ | | + | onTouchEnd | | | + +---+---------+ | | + | | +------------------------+ | + +------------------------->| onResponderEnd | | + No active touches started| +-----------+------------+ | + inside current responder | | | + | v | + | +------------------------+ | + | | onResponderRelease | | + | +------------------------+ | + | | + + + */ + +/** + * A note about event ordering in the `EventPluginRegistry`. + * + * Suppose plugins are injected in the following order: + * + * `[R, S, C]` + * + * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for + * `onClick` etc) and `R` is `ResponderEventPlugin`. + * + * "Deferred-Dispatched Events": + * + * - The current event plugin system will traverse the list of injected plugins, + * in order, and extract events by collecting the plugin's return value of + * `extractEvents()`. + * - These events that are returned from `extractEvents` are "deferred + * dispatched events". * - When returned from `extractEvents`, deferred-dispatched events contain an * "accumulation" of deferred dispatches. * - These deferred dispatches are accumulated/collected before they are @@ -2352,20 +2258,163 @@ function injectEventPluginsByName(injectedNamesToPlugins) { } } +function getListener$1(inst, registrationName) { + var stateNode = inst.stateNode; + + if (stateNode === null) { + // Work in progress (ex: onload events in incremental mode). + return null; + } + + var props = getFiberCurrentPropsFromNode(stateNode); + + if (props === null) { + // Work in progress. + return null; + } + + var listener = props[registrationName]; + + if (!(!listener || typeof listener === "function")) { + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + + return listener; +} + var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry - .customDirectEventTypes; + .customDirectEventTypes; // Start of inline: the below functions were inlined from +// EventPropagator.js, as they deviated from ReactDOM's newer +// implementations. + +function listenerAtPhase$1(inst, event, propagationPhase) { + var registrationName = + event.dispatchConfig.phasedRegistrationNames[propagationPhase]; + return getListener$1(inst, registrationName); +} + +function accumulateDirectionalDispatches$1(inst, phase, event) { + { + if (!inst) { + error("Dispatching inst must not be null"); + } + } + + var listener = listenerAtPhase$1(inst, event, phase); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } +} + +function getParent$1(inst) { + do { + inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. + // That is depending on if we want nested subtrees (layers) to bubble + // events to their parent. We could also go through parentNode on the + // host node but that wouldn't work for React Native and doesn't let us + // do the portal feature. + } while (inst && inst.tag !== HostComponent); + + if (inst) { + return inst; + } + + return null; +} +/** + * Simulates the traversal of a two-phase, capture/bubble event dispatch. + */ + +function traverseTwoPhase$1(inst, fn, arg) { + var path = []; + + while (inst) { + path.push(inst); + inst = getParent$1(inst); + } + + var i; + + for (i = path.length; i-- > 0; ) { + fn(path[i], "captured", arg); + } + + for (i = 0; i < path.length; i++) { + fn(path[i], "bubbled", arg); + } +} + +function accumulateTwoPhaseDispatchesSingle$1(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + traverseTwoPhase$1( + event._targetInst, + accumulateDirectionalDispatches$1, + event + ); + } +} + +function accumulateTwoPhaseDispatches$1(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1); +} +/** + * Accumulates without regard to direction, does not look for phased + * registration names. Same as `accumulateDirectDispatchesSingle` but without + * requiring that the `dispatchMarker` be the same as the dispatched ID. + */ + +function accumulateDispatches$1(inst, ignoredDirection, event) { + if (inst && event && event.dispatchConfig.registrationName) { + var registrationName = event.dispatchConfig.registrationName; + var listener = getListener$1(inst, registrationName); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } + } +} +/** + * Accumulates dispatches on an `SyntheticEvent`, but only for the + * `dispatchMarker`. + * @param {SyntheticEvent} event + */ + +function accumulateDirectDispatchesSingle$1(event) { + if (event && event.dispatchConfig.registrationName) { + accumulateDispatches$1(event._targetInst, null, event); + } +} + +function accumulateDirectDispatches$1(events) { + forEachAccumulated(events, accumulateDirectDispatchesSingle$1); +} // End of inline + var ReactNativeBridgeEventPlugin = { eventTypes: {}, extractEvents: function( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ) { if (targetInst == null) { // Probably a node belonging to another renderer's tree. @@ -2389,9 +2438,9 @@ var ReactNativeBridgeEventPlugin = { ); if (bubbleDispatchConfig) { - accumulateTwoPhaseDispatches(event); + accumulateTwoPhaseDispatches$1(event); } else if (directDispatchConfig) { - accumulateDirectDispatches(event); + accumulateDirectDispatches$1(event); } else { return null; } @@ -2477,37 +2526,62 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler( * If this becomes an actual Map, that will break. */ function get(key) { - return key._reactInternalFiber; + return key._reactInternals; } function set(key, value) { - key._reactInternalFiber = value; + key._reactInternals = value; } +// ATTENTION +// When adding new symbols to this file, +// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. -var hasSymbol = typeof Symbol === "function" && Symbol.for; -var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7; -var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca; -var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb; -var REACT_STRICT_MODE_TYPE = hasSymbol - ? Symbol.for("react.strict_mode") - : 0xeacc; -var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; -var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; -var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary -var REACT_CONCURRENT_MODE_TYPE = hasSymbol - ? Symbol.for("react.concurrent_mode") - : 0xeacf; -var REACT_FORWARD_REF_TYPE = hasSymbol - ? Symbol.for("react.forward_ref") - : 0xead0; -var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_SUSPENSE_LIST_TYPE = hasSymbol - ? Symbol.for("react.suspense_list") - : 0xead8; -var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; -var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; -var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 0xead9; +var REACT_ELEMENT_TYPE = 0xeac7; +var REACT_PORTAL_TYPE = 0xeaca; +var REACT_FRAGMENT_TYPE = 0xeacb; +var REACT_STRICT_MODE_TYPE = 0xeacc; +var REACT_PROFILER_TYPE = 0xead2; +var REACT_PROVIDER_TYPE = 0xeacd; +var REACT_CONTEXT_TYPE = 0xeace; +var REACT_FORWARD_REF_TYPE = 0xead0; +var REACT_SUSPENSE_TYPE = 0xead1; +var REACT_SUSPENSE_LIST_TYPE = 0xead8; +var REACT_MEMO_TYPE = 0xead3; +var REACT_LAZY_TYPE = 0xead4; +var REACT_BLOCK_TYPE = 0xead9; +var REACT_SERVER_BLOCK_TYPE = 0xeada; +var REACT_FUNDAMENTAL_TYPE = 0xead5; +var REACT_SCOPE_TYPE = 0xead7; +var REACT_OPAQUE_ID_TYPE = 0xeae0; +var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; +var REACT_OFFSCREEN_TYPE = 0xeae2; +var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; + +if (typeof Symbol === "function" && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor("react.element"); + REACT_PORTAL_TYPE = symbolFor("react.portal"); + REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); + REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); + REACT_PROFILER_TYPE = symbolFor("react.profiler"); + REACT_PROVIDER_TYPE = symbolFor("react.provider"); + REACT_CONTEXT_TYPE = symbolFor("react.context"); + REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); + REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); + REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); + REACT_MEMO_TYPE = symbolFor("react.memo"); + REACT_LAZY_TYPE = symbolFor("react.lazy"); + REACT_BLOCK_TYPE = symbolFor("react.block"); + REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); + REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); + REACT_SCOPE_TYPE = symbolFor("react.scope"); + REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); + REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); + REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); +} + var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { @@ -2526,63 +2600,6 @@ function getIteratorFn(maybeIterable) { return null; } -// TODO: Move this to "react" once we can import from externals. -var Uninitialized = -1; -var Pending = 0; -var Resolved = 1; -var Rejected = 2; - -function refineResolvedLazyComponent(lazyComponent) { - return lazyComponent._status === Resolved ? lazyComponent._result : null; -} -function initializeLazyComponentType(lazyComponent) { - if (lazyComponent._status === Uninitialized) { - var ctor = lazyComponent._result; - - if (!ctor) { - // TODO: Remove this later. THis only exists in case you use an older "react" package. - ctor = lazyComponent._ctor; - } - - var thenable = ctor(); // Transition to the next state. - - var pending = lazyComponent; - pending._status = Pending; - pending._result = thenable; - thenable.then( - function(moduleObject) { - if (lazyComponent._status === Pending) { - var defaultExport = moduleObject.default; - - { - if (defaultExport === undefined) { - error( - "lazy: Expected the result of a dynamic import() call. " + - "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. - "const MyComponent = lazy(() => imp" + - "ort('./MyComponent'))", - moduleObject - ); - } - } // Transition to the next state. - - var resolved = lazyComponent; - resolved._status = Resolved; - resolved._result = defaultExport; - } - }, - function(error) { - if (lazyComponent._status === Pending) { - // Transition to the next state. - var rejected = lazyComponent; - rejected._status = Rejected; - rejected._result = error; - } - } - ); - } -} - function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ""; return ( @@ -2655,17 +2672,18 @@ function getComponentName(type) { return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type.render); + return getComponentName(type._render); case REACT_LAZY_TYPE: { - var thenable = type; - var resolvedThenable = refineResolvedLazyComponent(thenable); + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; - if (resolvedThenable) { - return getComponentName(resolvedThenable); + try { + return getComponentName(init(payload)); + } catch (x) { + return null; } - - break; } } } @@ -2673,67 +2691,73 @@ function getComponentName(type) { return null; } +var enableProfilerTimer = true; +var warnAboutStringRefs = false; +var enableNewReconciler = false; + // Don't change these two values. They're used by React Dev Tools. -var NoEffect = - /* */ +var NoFlags = + /* */ 0; var PerformedWork = - /* */ + /* */ 1; // You can change the rest (and add more). var Placement = - /* */ + /* */ 2; var Update = - /* */ + /* */ 4; var PlacementAndUpdate = - /* */ + /* */ 6; var Deletion = - /* */ + /* */ 8; var ContentReset = - /* */ + /* */ 16; var Callback = - /* */ + /* */ 32; var DidCapture = - /* */ + /* */ 64; var Ref = - /* */ + /* */ 128; var Snapshot = - /* */ + /* */ 256; var Passive = - /* */ + /* */ 512; var Hydrating = - /* */ + /* */ 1024; var HydratingAndUpdate = - /* */ - 1028; // Passive & Update & Callback & Ref & Snapshot - -var LifecycleEffectMask = - /* */ - 932; // Union of all host effects + /* */ + 1028; +var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = - /* */ - 2047; + /* */ + 4095; // These are not really side effects, but we still reuse this field. + var Incomplete = - /* */ - 2048; -var ShouldCapture = - /* */ + /* */ 4096; +var ShouldCapture = + /* */ + 8192; // TODO (effects) Remove this bit once the new reconciler is synced to the old. -var enableProfilerTimer = true; -var warnAboutStringRefs = false; +var PassiveUnmountPendingDev = + /* */ + 16384; +var ForceUpdateForLegacySuspense = + /* */ + 32768; // Static tags describe aspects of a fiber that are not specific to a render, var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -2748,7 +2772,7 @@ function getNearestMountedFiber(fiber) { do { node = nextNode; - if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((node.flags & (Placement | Hydrating)) !== NoFlags) { // This is an insertion or in-progress hydration. The nearest possible // mounted fiber is the parent but we need to continue to figure out // if that one is still mounted. @@ -3008,6 +3032,20 @@ function findCurrentHostFiber(parent) { return null; } +function doesFiberContain(parentFiber, childFiber) { + var node = childFiber; + var parentFiberAlternate = parentFiber.alternate; + + while (node !== null) { + if (node === parentFiber || node === parentFiberAlternate) { + return true; + } + + node = node.return; + } + + return false; +} /** * In the future, we should cleanup callbacks by cancelling them instead of @@ -3497,19 +3535,16 @@ function diff(prevProps, nextProps, validAttributes) { ); } -var PLUGIN_EVENT_SYSTEM = 1; - +// Used as a way to call batchedUpdates when we don't have a reference to // the renderer. Such as when we're dispatching events or if third party // libraries need to call batchedUpdates. Eventually, this API will go away when // everything is batched by default. We'll then have a similar API to opt-out of // scheduled work and instead do synchronous work. // Defaults - var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; var isInsideEventHandler = false; - function batchedUpdates(fn, bookkeeping) { if (isInsideEventHandler) { // If we are currently inside another batch, we need to wait until it @@ -3597,22 +3632,21 @@ function extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ) { var events = null; + var legacyPlugins = plugins; - for (var i = 0; i < plugins.length; i++) { + for (var i = 0; i < legacyPlugins.length; i++) { // Not every plugin in the ordering may be loaded at runtime. - var possiblePlugin = plugins[i]; + var possiblePlugin = legacyPlugins[i]; if (possiblePlugin) { var extractedEvents = possiblePlugin.extractEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ); if (extractedEvents) { @@ -3628,15 +3662,13 @@ function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ) { var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ); runEventsInBatch(events); } @@ -3659,8 +3691,7 @@ function dispatchEvent(target, topLevelType, nativeEvent) { topLevelType, targetFiber, nativeEvent, - eventTarget, - PLUGIN_EVENT_SYSTEM + eventTarget ); }); // React Native doesn't use ReactControlledComponent but if it did, here's // where it would do it. @@ -3678,6 +3709,7 @@ function shim() { var supportsMutation = false; var commitMount = shim; +var clearContainer = shim; // can re-export everything from this module. @@ -3726,82 +3758,80 @@ if (registerEventHandler) { * This is used for refs on host components. */ -var ReactFabricHostComponent = - /*#__PURE__*/ - (function() { - function ReactFabricHostComponent( - tag, - viewConfig, - props, - internalInstanceHandle - ) { - this._nativeTag = tag; - this.viewConfig = viewConfig; - this.currentProps = props; - this._internalInstanceHandle = internalInstanceHandle; - } - - var _proto = ReactFabricHostComponent.prototype; - - _proto.blur = function blur() { - ReactNativePrivateInterface.TextInputState.blurTextInput(this); - }; - - _proto.focus = function focus() { - ReactNativePrivateInterface.TextInputState.focusTextInput(this); - }; +var ReactFabricHostComponent = /*#__PURE__*/ (function() { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { + this._nativeTag = tag; + this.viewConfig = viewConfig; + this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; + } - _proto.measure = function measure(callback) { - fabricMeasure( - this._internalInstanceHandle.stateNode.node, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + var _proto = ReactFabricHostComponent.prototype; - _proto.measureInWindow = function measureInWindow(callback) { - fabricMeasureInWindow( - this._internalInstanceHandle.stateNode.node, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + _proto.blur = function blur() { + ReactNativePrivateInterface.TextInputState.blurTextInput(this); + }; - _proto.measureLayout = function measureLayout( - relativeToNativeNode, - onSuccess, - onFail - ) /* currently unused */ - { - if ( - typeof relativeToNativeNode === "number" || - !(relativeToNativeNode instanceof ReactFabricHostComponent) - ) { - { - error( - "Warning: ref.measureLayout must be called with a ref to a native component." - ); - } + _proto.focus = function focus() { + ReactNativePrivateInterface.TextInputState.focusTextInput(this); + }; - return; - } + _proto.measure = function measure(callback) { + fabricMeasure( + this._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - fabricMeasureLayout( - this._internalInstanceHandle.stateNode.node, - relativeToNativeNode._internalInstanceHandle.stateNode.node, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; + _proto.measureInWindow = function measureInWindow(callback) { + fabricMeasureInWindow( + this._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - _proto.setNativeProps = function setNativeProps(nativeProps) { + _proto.measureLayout = function measureLayout( + relativeToNativeNode, + onSuccess, + onFail + ) /* currently unused */ + { + if ( + typeof relativeToNativeNode === "number" || + !(relativeToNativeNode instanceof ReactFabricHostComponent) + ) { { - error("Warning: setNativeProps is not currently supported in Fabric"); + error( + "Warning: ref.measureLayout must be called with a ref to a native component." + ); } return; - }; + } + + fabricMeasureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + }; + + _proto.setNativeProps = function setNativeProps(nativeProps) { + { + error("Warning: setNativeProps is not currently supported in Fabric"); + } - return ReactFabricHostComponent; - })(); // eslint-disable-next-line no-unused-expressions + return; + }; + + return ReactFabricHostComponent; +})(); // eslint-disable-next-line no-unused-expressions function appendInitialChild(parentInstance, child) { appendChildNode(parentInstance.node, child.node); } @@ -3897,6 +3927,7 @@ function getPublicInstance(instance) { } function prepareForCommit(containerInfo) { // Noop + return null; } function prepareUpdate( instance, @@ -3917,9 +3948,6 @@ function prepareUpdate( function resetAfterCommit(containerInfo) { // Noop } -function shouldDeprioritizeSubtree(type, props) { - return false; -} function shouldSetTextContent(type, props) { // TODO (bvaughn) Revisit this decision. // Always returning false simplifies the createInstance() implementation, @@ -3992,522 +4020,235 @@ function appendChildToContainerChildSet(childSet, child) { function finalizeContainerChildren(container, newChildren) { completeRoot(container, newChildren); } +function makeClientIdInDEV(warnOnAccessInDEV) { + throw new Error("Not yet implemented"); +} +function preparePortalMount(portalInstance) { + // noop +} -var loggedTypeFailures = {}; -function checkPropTypes(typeSpecs, values, location, componentName) { +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; +function describeBuiltInComponentFrame(name, source, ownerFn) { { - // $FlowFixMe This is okay but Flow doesn't know it. - var has = Function.call.bind(Object.prototype.hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - var err = Error( - (componentName || "React class") + - ": " + - location + - " type `" + - typeSpecName + - "` is invalid; " + - "it must be a function, usually from the `prop-types` package, but received `" + - typeof typeSpecs[typeSpecName] + - "`." + - "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." - ); - err.name = "Invariant Violation"; - throw err; - } - - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } - - if (error$1 && !(error$1 instanceof Error)) { - error( - "%s: type specification of %s" + - " `%s` is invalid; the type checker " + - "function must return `null` or an `Error` but returned a %s. " + - "You may have forgotten to pass an argument to the type checker " + - "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + - "shape all require an argument).", - componentName || "React class", - location, - typeSpecName, - typeof error$1 - ); - } - - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; + var ownerName = null; - error("Failed %s type: %s", location, error$1.message); - } - } + if (ownerFn) { + ownerName = ownerFn.displayName || ownerFn.name || null; } - } -} - -// Prefix measurements so that it's possible to filter them. -// Longer prefixes are hard to read in DevTools. -var reactEmoji = "\u269B"; -var warningEmoji = "\u26D4"; -var supportsUserTiming = - typeof performance !== "undefined" && - typeof performance.mark === "function" && - typeof performance.clearMarks === "function" && - typeof performance.measure === "function" && - typeof performance.clearMeasures === "function"; // Keep track of current fiber so that we know the path to unwind on pause. -// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? - -var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? -// Reusing `currentFiber` would be confusing for this because user code fiber -// can change during commit phase too, but we don't need to unwind it (since -// lifecycles in the commit phase don't resemble a tree). - -var currentPhase = null; -var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, -// so we will keep track of it, and include it in the report. -// Track commits caused by cascading updates. - -var isCommitting = false; -var hasScheduledUpdateInCurrentCommit = false; -var hasScheduledUpdateInCurrentPhase = false; -var commitCountInCurrentWorkLoop = 0; -var effectCountInCurrentCommit = 0; -// to avoid stretch the commit phase with measurement overhead. - -var labelsInCurrentCommit = new Set(); - -var formatMarkName = function(markName) { - return reactEmoji + " " + markName; -}; - -var formatLabel = function(label, warning) { - var prefix = warning ? warningEmoji + " " : reactEmoji + " "; - var suffix = warning ? " Warning: " + warning : ""; - return "" + prefix + label + suffix; -}; - -var beginMark = function(markName) { - performance.mark(formatMarkName(markName)); -}; -var clearMark = function(markName) { - performance.clearMarks(formatMarkName(markName)); -}; - -var endMark = function(label, markName, warning) { - var formattedMarkName = formatMarkName(markName); - var formattedLabel = formatLabel(label, warning); - - try { - performance.measure(formattedLabel, formattedMarkName); - } catch (err) {} // If previous mark was missing for some reason, this will throw. - // This could only happen if React crashed in an unexpected place earlier. - // Don't pile on with more errors. - // Clear marks immediately to avoid growing buffer. - - performance.clearMarks(formattedMarkName); - performance.clearMeasures(formattedLabel); -}; - -var getFiberMarkName = function(label, debugID) { - return label + " (#" + debugID + ")"; -}; - -var getFiberLabel = function(componentName, isMounted, phase) { - if (phase === null) { - // These are composite component total time measurements. - return componentName + " [" + (isMounted ? "update" : "mount") + "]"; - } else { - // Composite component methods. - return componentName + "." + phase; - } -}; - -var beginFiberMark = function(fiber, phase) { - var componentName = getComponentName(fiber.type) || "Unknown"; - var debugID = fiber._debugID; - var isMounted = fiber.alternate !== null; - var label = getFiberLabel(componentName, isMounted, phase); - - if (isCommitting && labelsInCurrentCommit.has(label)) { - // During the commit phase, we don't show duplicate labels because - // there is a fixed overhead for every measurement, and we don't - // want to stretch the commit phase beyond necessary. - return false; + return describeComponentFrame(name, source, ownerName); } +} +var componentFrameCache; - labelsInCurrentCommit.add(label); - var markName = getFiberMarkName(label, debugID); - beginMark(markName); - return true; -}; - -var clearFiberMark = function(fiber, phase) { - var componentName = getComponentName(fiber.type) || "Unknown"; - var debugID = fiber._debugID; - var isMounted = fiber.alternate !== null; - var label = getFiberLabel(componentName, isMounted, phase); - var markName = getFiberMarkName(label, debugID); - clearMark(markName); -}; - -var endFiberMark = function(fiber, phase, warning) { - var componentName = getComponentName(fiber.type) || "Unknown"; - var debugID = fiber._debugID; - var isMounted = fiber.alternate !== null; - var label = getFiberLabel(componentName, isMounted, phase); - var markName = getFiberMarkName(label, debugID); - endMark(label, markName, warning); -}; - -var shouldIgnoreFiber = function(fiber) { - // Host components should be skipped in the timeline. - // We could check typeof fiber.type, but does this work with RN? - switch (fiber.tag) { - case HostRoot: - case HostComponent: - case HostText: - case HostPortal: - case Fragment: - case ContextProvider: - case ContextConsumer: - case Mode: - return true; +{ + var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap(); +} +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; - default: - return false; - } -}; +function describeComponentFrame(name, source, ownerName) { + var sourceInfo = ""; -var clearPendingPhaseMeasurement = function() { - if (currentPhase !== null && currentPhaseFiber !== null) { - clearFiberMark(currentPhaseFiber, currentPhase); - } + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". - currentPhaseFiber = null; - currentPhase = null; - hasScheduledUpdateInCurrentPhase = false; -}; + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); -var pauseTimers = function() { - // Stops all currently active measurements so that they can be resumed - // if we continue in a later deferred loop from the same unit of work. - var fiber = currentFiber; + if (match) { + var pathBeforeSlash = match[1]; - while (fiber) { - if (fiber._debugIsCurrentlyTiming) { - endFiberMark(fiber, null, null); + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); + fileName = folderName + "/" + fileName; + } + } } - fiber = fiber.return; - } -}; - -var resumeTimersRecursively = function(fiber) { - if (fiber.return !== null) { - resumeTimersRecursively(fiber.return); - } - - if (fiber._debugIsCurrentlyTiming) { - beginFiberMark(fiber, null); + sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; + } else if (ownerName) { + sourceInfo = " (created by " + ownerName + ")"; } -}; -var resumeTimers = function() { - // Resumes all measurements that were active during the last deferred loop. - if (currentFiber !== null) { - resumeTimersRecursively(currentFiber); - } -}; + return "\n in " + (name || "Unknown") + sourceInfo; +} -function recordEffect() { +function describeClassComponentFrame(ctor, source, ownerFn) { { - effectCountInCurrentCommit++; + return describeFunctionComponentFrame(ctor, source, ownerFn); } } -function recordScheduleUpdate() { +function describeFunctionComponentFrame(fn, source, ownerFn) { { - if (isCommitting) { - hasScheduledUpdateInCurrentCommit = true; - } - - if ( - currentPhase !== null && - currentPhase !== "componentWillMount" && - currentPhase !== "componentWillReceiveProps" - ) { - hasScheduledUpdateInCurrentPhase = true; + if (!fn) { + return ""; } - } -} -function startWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // If we pause, this is the fiber to unwind from. - currentFiber = fiber; + var name = fn.displayName || fn.name || null; + var ownerName = null; - if (!beginFiberMark(fiber, null)) { - return; + if (ownerFn) { + ownerName = ownerFn.displayName || ownerFn.name || null; } - fiber._debugIsCurrentlyTiming = true; - } -} -function cancelWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // Remember we shouldn't complete measurement for this fiber. - // Otherwise flamechart will be deep even for small updates. - - fiber._debugIsCurrentlyTiming = false; - clearFiberMark(fiber, null); + return describeComponentFrame(name, source, ownerName); } } -function stopWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // If we pause, its parent is the fiber to unwind from. - - currentFiber = fiber.return; - - if (!fiber._debugIsCurrentlyTiming) { - return; - } - fiber._debugIsCurrentlyTiming = false; - endFiberMark(fiber, null, null); +function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { + if (type == null) { + return ""; } -} -function stopFailedWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // If we pause, its parent is the fiber to unwind from. - currentFiber = fiber.return; - - if (!fiber._debugIsCurrentlyTiming) { - return; + if (typeof type === "function") { + { + return describeFunctionComponentFrame(type, source, ownerFn); } - - fiber._debugIsCurrentlyTiming = false; - var warning = - fiber.tag === SuspenseComponent - ? "Rendering was suspended" - : "An error was thrown inside this error boundary"; - endFiberMark(fiber, null, warning); } -} -function startPhaseTimer(fiber, phase) { - { - if (!supportsUserTiming) { - return; - } - - clearPendingPhaseMeasurement(); - if (!beginFiberMark(fiber, phase)) { - return; - } - - currentPhaseFiber = fiber; - currentPhase = phase; + if (typeof type === "string") { + return describeBuiltInComponentFrame(type, source, ownerFn); } -} -function stopPhaseTimer() { - { - if (!supportsUserTiming) { - return; - } - if (currentPhase !== null && currentPhaseFiber !== null) { - var warning = hasScheduledUpdateInCurrentPhase - ? "Scheduled a cascading update" - : null; - endFiberMark(currentPhaseFiber, currentPhase, warning); - } + switch (type) { + case REACT_SUSPENSE_TYPE: + return describeBuiltInComponentFrame("Suspense", source, ownerFn); - currentPhase = null; - currentPhaseFiber = null; + case REACT_SUSPENSE_LIST_TYPE: + return describeBuiltInComponentFrame("SuspenseList", source, ownerFn); } -} -function startWorkLoopTimer(nextUnitOfWork) { - { - currentFiber = nextUnitOfWork; - - if (!supportsUserTiming) { - return; - } - commitCountInCurrentWorkLoop = 0; // This is top level call. - // Any other measurements are performed within. + if (typeof type === "object") { + switch (type.$$typeof) { + case REACT_FORWARD_REF_TYPE: + return describeFunctionComponentFrame(type.render, source, ownerFn); - beginMark("(React Tree Reconciliation)"); // Resume any measurements that were in progress during the last loop. + case REACT_MEMO_TYPE: + // Memo may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); - resumeTimers(); - } -} -function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { - { - if (!supportsUserTiming) { - return; - } + case REACT_BLOCK_TYPE: + return describeFunctionComponentFrame(type._render, source, ownerFn); - var warning = null; + case REACT_LAZY_TYPE: { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; - if (interruptedBy !== null) { - if (interruptedBy.tag === HostRoot) { - warning = "A top-level update interrupted the previous render"; - } else { - var componentName = getComponentName(interruptedBy.type) || "Unknown"; - warning = - "An update to " + componentName + " interrupted the previous render"; + try { + // Lazy may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV( + init(payload), + source, + ownerFn + ); + } catch (x) {} } - } else if (commitCountInCurrentWorkLoop > 1) { - warning = "There were cascading updates"; } - - commitCountInCurrentWorkLoop = 0; - var label = didCompleteRoot - ? "(React Tree Reconciliation: Completed Root)" - : "(React Tree Reconciliation: Yielded)"; // Pause any measurements until the next loop. - - pauseTimers(); - endMark(label, "(React Tree Reconciliation)", warning); } + + return ""; } -function startCommitTimer() { + +var loggedTypeFailures = {}; +var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + +function setCurrentlyValidatingElement(element) { { - if (!supportsUserTiming) { - return; + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + element._source, + owner ? owner.type : null + ); + ReactDebugCurrentFrame.setExtraStackFrame(stack); + } else { + ReactDebugCurrentFrame.setExtraStackFrame(null); } - - isCommitting = true; - hasScheduledUpdateInCurrentCommit = false; - labelsInCurrentCommit.clear(); - beginMark("(Committing Changes)"); } } -function stopCommitTimer() { + +function checkPropTypes(typeSpecs, values, location, componentName, element) { { - if (!supportsUserTiming) { - return; - } + // $FlowFixMe This is okay but Flow doesn't know it. + var has = Function.call.bind(Object.prototype.hasOwnProperty); - var warning = null; + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. - if (hasScheduledUpdateInCurrentCommit) { - warning = "Lifecycle hook scheduled a cascading update"; - } else if (commitCountInCurrentWorkLoop > 0) { - warning = "Caused by a cascading update in earlier commit"; - } + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== "function") { + var err = Error( + (componentName || "React class") + + ": " + + location + + " type `" + + typeSpecName + + "` is invalid; " + + "it must be a function, usually from the `prop-types` package, but received `" + + typeof typeSpecs[typeSpecName] + + "`." + + "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." + ); + err.name = "Invariant Violation"; + throw err; + } - hasScheduledUpdateInCurrentCommit = false; - commitCountInCurrentWorkLoop++; - isCommitting = false; - labelsInCurrentCommit.clear(); - endMark("(Committing Changes)", "(Committing Changes)", warning); - } -} -function startCommitSnapshotEffectsTimer() { - { - if (!supportsUserTiming) { - return; - } + error$1 = typeSpecs[typeSpecName]( + values, + typeSpecName, + componentName, + location, + null, + "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" + ); + } catch (ex) { + error$1 = ex; + } - effectCountInCurrentCommit = 0; - beginMark("(Committing Snapshot Effects)"); - } -} -function stopCommitSnapshotEffectsTimer() { - { - if (!supportsUserTiming) { - return; - } + if (error$1 && !(error$1 instanceof Error)) { + setCurrentlyValidatingElement(element); - var count = effectCountInCurrentCommit; - effectCountInCurrentCommit = 0; - endMark( - "(Committing Snapshot Effects: " + count + " Total)", - "(Committing Snapshot Effects)", - null - ); - } -} -function startCommitHostEffectsTimer() { - { - if (!supportsUserTiming) { - return; - } + error( + "%s: type specification of %s" + + " `%s` is invalid; the type checker " + + "function must return `null` or an `Error` but returned a %s. " + + "You may have forgotten to pass an argument to the type checker " + + "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + + "shape all require an argument).", + componentName || "React class", + location, + typeSpecName, + typeof error$1 + ); - effectCountInCurrentCommit = 0; - beginMark("(Committing Host Effects)"); - } -} -function stopCommitHostEffectsTimer() { - { - if (!supportsUserTiming) { - return; - } + setCurrentlyValidatingElement(null); + } - var count = effectCountInCurrentCommit; - effectCountInCurrentCommit = 0; - endMark( - "(Committing Host Effects: " + count + " Total)", - "(Committing Host Effects)", - null - ); - } -} -function startCommitLifeCyclesTimer() { - { - if (!supportsUserTiming) { - return; - } + if ( + error$1 instanceof Error && + !(error$1.message in loggedTypeFailures) + ) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error$1.message] = true; + setCurrentlyValidatingElement(element); - effectCountInCurrentCommit = 0; - beginMark("(Calling Lifecycle Methods)"); - } -} -function stopCommitLifeCyclesTimer() { - { - if (!supportsUserTiming) { - return; - } + error("Failed %s type: %s", location, error$1.message); - var count = effectCountInCurrentCommit; - effectCountInCurrentCommit = 0; - endMark( - "(Calling Lifecycle Methods: " + count + " Total)", - "(Calling Lifecycle Methods)", - null - ); + setCurrentlyValidatingElement(null); + } + } + } } } @@ -4714,10 +4455,7 @@ function processChildContext(fiber, type, parentContext) { return parentContext; } - var childContext; - startPhaseTimer(fiber, "getChildContext"); - childContext = instance.getChildContext(); - stopPhaseTimer(); + var childContext = instance.getChildContext(); for (var contextKey in childContext) { if (!(contextKey in childContextTypes)) { @@ -4735,7 +4473,7 @@ function processChildContext(fiber, type, parentContext) { checkPropTypes(childContextTypes, childContext, "child context", name); } - return Object.assign({}, parentContext, {}, childContext); + return Object.assign({}, parentContext, childContext); } } @@ -4838,20 +4576,112 @@ var LegacyRoot = 0; var BlockingRoot = 1; var ConcurrentRoot = 2; +var rendererID = null; +var injectedHook = null; +var hasLoggedError = false; +var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; +function injectInternals(internals) { + if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { + // No DevTools + return false; + } + + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + + if (hook.isDisabled) { + // This isn't a real property on the hook, but it can be set to opt out + // of DevTools integration and associated warnings and logs. + // https://github.com/facebook/react/issues/3877 + return true; + } + + if (!hook.supportsFiber) { + { + error( + "The installed version of React DevTools is too old and will not work " + + "with the current version of React. Please update React DevTools. " + + "https://reactjs.org/link/react-devtools" + ); + } // DevTools exists, even though it doesn't support Fiber. + + return true; + } + + try { + rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + + injectedHook = hook; + } catch (err) { + // Catch all errors because it is unsafe to throw during initialization. + { + error("React instrumentation encountered an error: %s.", err); + } + } // DevTools exists + + return true; +} +function onScheduleRoot(root, children) { + { + if ( + injectedHook && + typeof injectedHook.onScheduleFiberRoot === "function" + ) { + try { + injectedHook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } +} +function onCommitRoot(root, priorityLevel) { + if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") { + try { + var didError = (root.current.flags & DidCapture) === DidCapture; + + if (enableProfilerTimer) { + injectedHook.onCommitFiberRoot( + rendererID, + root, + priorityLevel, + didError + ); + } else { + injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError); + } + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } +} +function onCommitUnmount(fiber) { + if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") { + try { + injectedHook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } +} + // Intentionally not named imports because Rollup would use dynamic dispatch for -var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, - Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, - Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, - Scheduler_shouldYield = Scheduler.unstable_shouldYield, - Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now = Scheduler.unstable_now, - Scheduler_getCurrentPriorityLevel = - Scheduler.unstable_getCurrentPriorityLevel, - Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, - Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, - Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, - Scheduler_LowPriority = Scheduler.unstable_LowPriority, - Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; +var Scheduler_now = Scheduler.unstable_now; { // Provide explicit error message when production+profiling bundle of e.g. @@ -4864,12 +4694,10 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, ) ) { throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); } } - -var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use // ascending numbers so we can compare them like numbers. They start at 90 to // avoid clashing with Scheduler's priorities. @@ -4880,1214 +4708,1437 @@ var LowPriority = 96; var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. var NoPriority = 90; -var shouldYield = Scheduler_shouldYield; -var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. - Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {}; -var syncQueue = null; -var immediateQueueCallbackNode = null; -var isFlushingSyncQueue = false; var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. -// This will be the case for modern browsers that support `performance.now`. In -// older browsers, Scheduler falls back to `Date.now`, which returns a Unix -// timestamp. In that case, subtract the module initialization time to simulate -// the behavior of performance.now and keep our times small enough to fit -// within 32 bits. -// TODO: Consider lifting this into Scheduler. - -var now = - initialTimeMs < 10000 - ? Scheduler_now - : function() { - return Scheduler_now() - initialTimeMs; - }; -function getCurrentPriorityLevel() { - switch (Scheduler_getCurrentPriorityLevel()) { - case Scheduler_ImmediatePriority: - return ImmediatePriority; - - case Scheduler_UserBlockingPriority: - return UserBlockingPriority; - - case Scheduler_NormalPriority: - return NormalPriority; - - case Scheduler_LowPriority: - return LowPriority; - - case Scheduler_IdlePriority: - return IdlePriority; - - default: { - throw Error("Unknown priority level."); - } - } -} - -function reactPriorityToSchedulerPriority(reactPriorityLevel) { - switch (reactPriorityLevel) { - case ImmediatePriority: - return Scheduler_ImmediatePriority; - case UserBlockingPriority: - return Scheduler_UserBlockingPriority; +var SyncLanePriority = 15; +var SyncBatchedLanePriority = 14; +var InputDiscreteHydrationLanePriority = 13; +var InputDiscreteLanePriority = 12; +var InputContinuousHydrationLanePriority = 11; +var InputContinuousLanePriority = 10; +var DefaultHydrationLanePriority = 9; +var DefaultLanePriority = 8; +var TransitionHydrationPriority = 7; +var TransitionPriority = 6; +var RetryLanePriority = 5; +var SelectiveHydrationLanePriority = 4; +var IdleHydrationLanePriority = 3; +var IdleLanePriority = 2; +var OffscreenLanePriority = 1; +var NoLanePriority = 0; +var TotalLanes = 31; +var NoLanes = + /* */ + 0; +var NoLane = + /* */ + 0; +var SyncLane = + /* */ + 1; +var SyncBatchedLane = + /* */ + 2; +var InputDiscreteHydrationLane = + /* */ + 4; +var InputDiscreteLanes = + /* */ + 24; +var InputContinuousHydrationLane = + /* */ + 32; +var InputContinuousLanes = + /* */ + 192; +var DefaultHydrationLane = + /* */ + 256; +var DefaultLanes = + /* */ + 3584; +var TransitionHydrationLane = + /* */ + 4096; +var TransitionLanes = + /* */ + 4186112; +var RetryLanes = + /* */ + 62914560; +var SomeRetryLane = + /* */ + 33554432; +var SelectiveHydrationLane = + /* */ + 67108864; +var NonIdleLanes = + /* */ + 134217727; +var IdleHydrationLane = + /* */ + 134217728; +var IdleLanes = + /* */ + 805306368; +var OffscreenLane = + /* */ + 1073741824; +var NoTimestamp = -1; +// Used by getHighestPriorityLanes and getNextLanes: - case NormalPriority: - return Scheduler_NormalPriority; +var return_highestLanePriority = DefaultLanePriority; - case LowPriority: - return Scheduler_LowPriority; +function getHighestPriorityLanes(lanes) { + if ((SyncLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncLanePriority; + return SyncLane; + } - case IdlePriority: - return Scheduler_IdlePriority; + if ((SyncBatchedLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncBatchedLanePriority; + return SyncBatchedLane; + } - default: { - throw Error("Unknown priority level."); - } + if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { + return_highestLanePriority = InputDiscreteHydrationLanePriority; + return InputDiscreteHydrationLane; } -} -function runWithPriority(reactPriorityLevel, fn) { - var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_runWithPriority(priorityLevel, fn); -} -function scheduleCallback(reactPriorityLevel, callback, options) { - var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_scheduleCallback(priorityLevel, callback, options); -} -function scheduleSyncCallback(callback) { - // Push this callback into an internal queue. We'll flush these either in - // the next tick, or earlier if something calls `flushSyncCallbackQueue`. - if (syncQueue === null) { - syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. + var inputDiscreteLanes = InputDiscreteLanes & lanes; - immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ); - } else { - // Push onto existing queue. Don't need to schedule a callback because - // we already scheduled one when we created the queue. - syncQueue.push(callback); + if (inputDiscreteLanes !== NoLanes) { + return_highestLanePriority = InputDiscreteLanePriority; + return inputDiscreteLanes; } - return fakeCallbackNode; -} -function cancelCallback(callbackNode) { - if (callbackNode !== fakeCallbackNode) { - Scheduler_cancelCallback(callbackNode); - } -} -function flushSyncCallbackQueue() { - if (immediateQueueCallbackNode !== null) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); + if ((lanes & InputContinuousHydrationLane) !== NoLanes) { + return_highestLanePriority = InputContinuousHydrationLanePriority; + return InputContinuousHydrationLane; } - flushSyncCallbackQueueImpl(); -} - -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrancy. - isFlushingSyncQueue = true; - var i = 0; - - try { - var _isSync = true; - var queue = syncQueue; - runWithPriority(ImmediatePriority, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; + var inputContinuousLanes = InputContinuousLanes & lanes; - do { - callback = callback(_isSync); - } while (callback !== null); - } - }); - syncQueue = null; - } catch (error) { - // If something throws, leave the remaining callbacks on the queue. - if (syncQueue !== null) { - syncQueue = syncQueue.slice(i + 1); - } // Resume flushing in the next tick - - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ); - throw error; - } finally { - isFlushingSyncQueue = false; - } + if (inputContinuousLanes !== NoLanes) { + return_highestLanePriority = InputContinuousLanePriority; + return inputContinuousLanes; } -} -var NoMode = 0; -var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root -// tag instead + if ((lanes & DefaultHydrationLane) !== NoLanes) { + return_highestLanePriority = DefaultHydrationLanePriority; + return DefaultHydrationLane; + } -var BlockingMode = 2; -var ConcurrentMode = 4; -var ProfileMode = 8; + var defaultLanes = DefaultLanes & lanes; -// Max 31 bit integer. The max integer size in V8 for 32-bit systems. -// Math.pow(2, 30) - 1 -// 0b111111111111111111111111111111 -var MAX_SIGNED_31_BIT_INT = 1073741823; + if (defaultLanes !== NoLanes) { + return_highestLanePriority = DefaultLanePriority; + return defaultLanes; + } -var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that -// Never work can be committed in an inconsistent state without tearing the UI. -// The main example is offscreen content, like a hidden subtree. So one possible -// name is Offscreen. However, it also includes dehydrated Suspense boundaries, -// which are inconsistent in the sense that they haven't finished yet, but -// aren't visibly inconsistent because the server rendered HTML matches what the -// hydrated tree would look like. + if ((lanes & TransitionHydrationLane) !== NoLanes) { + return_highestLanePriority = TransitionHydrationPriority; + return TransitionHydrationLane; + } -var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in -// order to be consistent. + var transitionLanes = TransitionLanes & lanes; -var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase -var Sync = MAX_SIGNED_31_BIT_INT; -var Batched = Sync - 1; -var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms. + if (transitionLanes !== NoLanes) { + return_highestLanePriority = TransitionPriority; + return transitionLanes; + } -function msToExpirationTime(ms) { - // Always subtract from the offset so that we don't clash with the magic number for NoWork. - return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); -} -function expirationTimeToMs(expirationTime) { - return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; -} + var retryLanes = RetryLanes & lanes; -function ceiling(num, precision) { - return (((num / precision) | 0) + 1) * precision; -} + if (retryLanes !== NoLanes) { + return_highestLanePriority = RetryLanePriority; + return retryLanes; + } -function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { - return ( - MAGIC_NUMBER_OFFSET - - ceiling( - MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, - bucketSizeMs / UNIT_SIZE - ) - ); -} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update -// the names to reflect. - -var LOW_PRIORITY_EXPIRATION = 5000; -var LOW_PRIORITY_BATCH_SIZE = 250; -function computeAsyncExpiration(currentTime) { - return computeExpirationBucket( - currentTime, - LOW_PRIORITY_EXPIRATION, - LOW_PRIORITY_BATCH_SIZE - ); -} -function computeSuspenseExpiration(currentTime, timeoutMs) { - // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time? - return computeExpirationBucket( - currentTime, - timeoutMs, - LOW_PRIORITY_BATCH_SIZE - ); -} // We intentionally set a higher expiration time for interactive updates in -// dev than in production. -// -// If the main thread is being blocked so long that you hit the expiration, -// it's a problem that could be solved with better scheduling. -// -// People will be more likely to notice this and fix it with the long -// expiration time in development. -// -// In production we opt for better UX at the risk of masking scheduling -// problems, by expiring fast. - -var HIGH_PRIORITY_EXPIRATION = 500; -var HIGH_PRIORITY_BATCH_SIZE = 100; -function computeInteractiveExpiration(currentTime) { - return computeExpirationBucket( - currentTime, - HIGH_PRIORITY_EXPIRATION, - HIGH_PRIORITY_BATCH_SIZE - ); -} -function inferPriorityFromExpirationTime(currentTime, expirationTime) { - if (expirationTime === Sync) { - return ImmediatePriority; + if (lanes & SelectiveHydrationLane) { + return_highestLanePriority = SelectiveHydrationLanePriority; + return SelectiveHydrationLane; } - if (expirationTime === Never || expirationTime === Idle) { - return IdlePriority; + if ((lanes & IdleHydrationLane) !== NoLanes) { + return_highestLanePriority = IdleHydrationLanePriority; + return IdleHydrationLane; } - var msUntil = - expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); + var idleLanes = IdleLanes & lanes; - if (msUntil <= 0) { - return ImmediatePriority; + if (idleLanes !== NoLanes) { + return_highestLanePriority = IdleLanePriority; + return idleLanes; } - if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { - return UserBlockingPriority; + if ((OffscreenLane & lanes) !== NoLanes) { + return_highestLanePriority = OffscreenLanePriority; + return OffscreenLane; } - if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { - return NormalPriority; - } // TODO: Handle LowPriority - // Assume anything lower has idle priority + { + error("Should have found matching lanes. This is a bug in React."); + } // This shouldn't be reachable, but as a fallback, return the entire bitmask. - return IdlePriority; + return_highestLanePriority = DefaultLanePriority; + return lanes; } -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return ( - (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare - ); -} +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case ImmediatePriority: + return SyncLanePriority; -var objectIs = typeof Object.is === "function" ? Object.is : is; + case UserBlockingPriority: + return InputContinuousLanePriority; -var hasOwnProperty = Object.prototype.hasOwnProperty; -/** - * Performs equality by iterating through keys on an object and returning false - * when any key has values which are not strictly equal between the arguments. - * Returns true when the values of all keys are strictly equal. - */ + case NormalPriority: + case LowPriority: + // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. + return DefaultLanePriority; -function shallowEqual(objA, objB) { - if (objectIs(objA, objB)) { - return true; - } + case IdlePriority: + return IdleLanePriority; - if ( - typeof objA !== "object" || - objA === null || - typeof objB !== "object" || - objB === null - ) { - return false; + default: + return NoLanePriority; } +} +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case SyncLanePriority: + case SyncBatchedLanePriority: + return ImmediatePriority; - var keysA = Object.keys(objA); - var keysB = Object.keys(objB); + case InputDiscreteHydrationLanePriority: + case InputDiscreteLanePriority: + case InputContinuousHydrationLanePriority: + case InputContinuousLanePriority: + return UserBlockingPriority; - if (keysA.length !== keysB.length) { - return false; - } // Test for A's keys different from B. + case DefaultHydrationLanePriority: + case DefaultLanePriority: + case TransitionHydrationPriority: + case TransitionPriority: + case SelectiveHydrationLanePriority: + case RetryLanePriority: + return NormalPriority; - for (var i = 0; i < keysA.length; i++) { - if ( - !hasOwnProperty.call(objB, keysA[i]) || - !objectIs(objA[keysA[i]], objB[keysA[i]]) - ) { - return false; + case IdleHydrationLanePriority: + case IdleLanePriority: + case OffscreenLanePriority: + return IdlePriority; + + case NoLanePriority: + return NoPriority; + + default: { + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); } } - - return true; } +function getNextLanes(root, wipLanes) { + // Early bailout if there's no pending work left. + var pendingLanes = root.pendingLanes; -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; -function describeComponentFrame(name, source, ownerName) { - var sourceInfo = ""; + if (pendingLanes === NoLanes) { + return_highestLanePriority = NoLanePriority; + return NoLanes; + } - if (source) { - var path = source.fileName; - var fileName = path.replace(BEFORE_SLASH_RE, ""); + var nextLanes = NoLanes; + var nextLanePriority = NoLanePriority; + var expiredLanes = root.expiredLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; // Check if any work has expired. - { - // In DEV, include code for a common special case: - // prefer "folder/index.js" instead of just "index.js". - if (/^index\./.test(fileName)) { - var match = path.match(BEFORE_SLASH_RE); + if (expiredLanes !== NoLanes) { + nextLanes = expiredLanes; + nextLanePriority = return_highestLanePriority = SyncLanePriority; + } else { + // Do not work on any idle work until all the non-idle work has finished, + // even if the work is suspended. + var nonIdlePendingLanes = pendingLanes & NonIdleLanes; - if (match) { - var pathBeforeSlash = match[1]; + if (nonIdlePendingLanes !== NoLanes) { + var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; - if (pathBeforeSlash) { - var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); - fileName = folderName + "/" + fileName; - } + if (nonIdleUnblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); + nextLanePriority = return_highestLanePriority; + } else { + var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; + + if (nonIdlePingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); + nextLanePriority = return_highestLanePriority; } } - } + } else { + // The only remaining work is Idle. + var unblockedLanes = pendingLanes & ~suspendedLanes; - sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; - } else if (ownerName) { - sourceInfo = " (created by " + ownerName + ")"; + if (unblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(unblockedLanes); + nextLanePriority = return_highestLanePriority; + } else { + if (pingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(pingedLanes); + nextLanePriority = return_highestLanePriority; + } + } + } } - return "\n in " + (name || "Unknown") + sourceInfo; -} + if (nextLanes === NoLanes) { + // This should only be reachable if we're suspended + // TODO: Consider warning in this path if a fallback timer is not scheduled. + return NoLanes; + } // If there are higher priority lanes, we'll include them even if they + // are suspended. -var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt + // it and we'll lose our progress. We should only do this if the new lanes are + // higher priority. -function describeFiber(fiber) { - switch (fiber.tag) { - case HostRoot: - case HostPortal: - case HostText: - case Fragment: - case ContextProvider: - case ContextConsumer: - return ""; + if ( + wipLanes !== NoLanes && + wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't + // bother waiting until the root is complete. + (wipLanes & suspendedLanes) === NoLanes + ) { + getHighestPriorityLanes(wipLanes); + var wipLanePriority = return_highestLanePriority; - default: - var owner = fiber._debugOwner; - var source = fiber._debugSource; - var name = getComponentName(fiber.type); - var ownerName = null; + if (nextLanePriority <= wipLanePriority) { + return wipLanes; + } else { + return_highestLanePriority = nextLanePriority; + } + } // Check for entangled lanes and add them to the batch. + // + // A lane is said to be entangled with another when it's not allowed to render + // in a batch that does not also include the other lane. Typically we do this + // when multiple updates have the same source, and we only want to respond to + // the most recent event from that source. + // + // Note that we apply entanglements *after* checking for partial work above. + // This means that if a lane is entangled during an interleaved event while + // it's already rendering, we won't interrupt it. This is intentional, since + // entanglement is usually "best effort": we'll try our best to render the + // lanes in the same batch, but it's not worth throwing out partially + // completed work in order to do it. + // + // For those exceptions where entanglement is semantically important, like + // useMutableSource, we should ensure that there is no partial work at the + // time we apply the entanglement. - if (owner) { - ownerName = getComponentName(owner.type); - } + var entangledLanes = root.entangledLanes; - return describeComponentFrame(name, source, ownerName); + if (entangledLanes !== NoLanes) { + var entanglements = root.entanglements; + var lanes = nextLanes & entangledLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + nextLanes |= entanglements[index]; + lanes &= ~lane; + } } + + return nextLanes; } +function getMostRecentEventTime(root, lanes) { + var eventTimes = root.eventTimes; + var mostRecentEventTime = NoTimestamp; -function getStackByFiberInDevAndProd(workInProgress) { - var info = ""; - var node = workInProgress; + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var eventTime = eventTimes[index]; - do { - info += describeFiber(node); - node = node.return; - } while (node); + if (eventTime > mostRecentEventTime) { + mostRecentEventTime = eventTime; + } + + lanes &= ~lane; + } - return info; + return mostRecentEventTime; } -var current = null; -var isRendering = false; -function getCurrentFiberOwnerNameInDevOrNull() { - { - if (current === null) { - return null; - } - var owner = current._debugOwner; +function computeExpirationTime(lane, currentTime) { + // TODO: Expiration heuristic is constant per lane, so could use a map. + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; - if (owner !== null && typeof owner !== "undefined") { - return getComponentName(owner.type); + if (priority >= InputContinuousLanePriority) { + // User interactions should expire slightly more quickly. + // + // NOTE: This is set to the corresponding constant as in Scheduler.js. When + // we made it larger, a product metric in www regressed, suggesting there's + // a user interaction that's being starved by a series of synchronous + // updates. If that theory is correct, the proper solution is to fix the + // starvation. However, this scenario supports the idea that expiration + // times are an important safeguard when starvation does happen. + // + // Also note that, in the case of user input specifically, this will soon no + // longer be an issue because we plan to make user input synchronous by + // default (until you enter `startTransition`, of course.) + // + // If weren't planning to make these updates synchronous soon anyway, I + // would probably make this number a configurable parameter. + return currentTime + 250; + } else if (priority >= TransitionPriority) { + return currentTime + 5000; + } else { + // Anything idle priority or lower should never expire. + return NoTimestamp; + } +} + +function markStarvedLanesAsExpired(root, currentTime) { + // TODO: This gets called every time we yield. We can optimize by storing + // the earliest expiration time on the root. Then use that to quickly bail out + // of this function. + var pendingLanes = root.pendingLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; + var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their + // expiration time. If so, we'll assume the update is being starved and mark + // it as expired to force it to finish. + + var lanes = pendingLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var expirationTime = expirationTimes[index]; + + if (expirationTime === NoTimestamp) { + // Found a pending lane with no expiration time. If it's not suspended, or + // if it's pinged, assume it's CPU-bound. Compute a new expiration time + // using the current time. + if ( + (lane & suspendedLanes) === NoLanes || + (lane & pingedLanes) !== NoLanes + ) { + // Assumes timestamps are monotonically increasing. + expirationTimes[index] = computeExpirationTime(lane, currentTime); + } + } else if (expirationTime <= currentTime) { + // This lane expired + root.expiredLanes |= lane; } + + lanes &= ~lane; } +} // This returns the highest priority pending lanes regardless of whether they +function getLanesToRetrySynchronouslyOnError(root) { + var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; - return null; -} -function getCurrentFiberStackInDev() { - { - if (current === null) { - return ""; - } // Safe because if current fiber exists, we are reconciling, - // and it is guaranteed to be the work-in-progress version. + if (everythingButOffscreen !== NoLanes) { + return everythingButOffscreen; + } - return getStackByFiberInDevAndProd(current); + if (everythingButOffscreen & OffscreenLane) { + return OffscreenLane; } + + return NoLanes; } -function resetCurrentFiber() { - { - ReactDebugCurrentFrame.getCurrentStack = null; - current = null; - isRendering = false; - } +function returnNextLanesPriority() { + return return_highestLanePriority; } -function setCurrentFiber(fiber) { - { - ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; - current = fiber; - isRendering = false; - } +function includesNonIdleWork(lanes) { + return (lanes & NonIdleLanes) !== NoLanes; } -function setIsRendering(rendering) { - { - isRendering = rendering; - } +function includesOnlyRetries(lanes) { + return (lanes & RetryLanes) === lanes; } +function includesOnlyTransitions(lanes) { + return (lanes & TransitionLanes) === lanes; +} // To ensure consistency across multiple updates in the same event, this should +// be a pure function, so that it always returns the same lane for given inputs. + +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case NoLanePriority: + break; -var ReactStrictModeWarnings = { - recordUnsafeLifecycleWarnings: function(fiber, instance) {}, - flushPendingUnsafeLifecycleWarnings: function() {}, - recordLegacyContextWarning: function(fiber, instance) {}, - flushLegacyContextWarning: function() {}, - discardPendingWarnings: function() {} -}; + case SyncLanePriority: + return SyncLane; -{ - var findStrictRoot = function(fiber) { - var maybeStrictRoot = null; - var node = fiber; + case SyncBatchedLanePriority: + return SyncBatchedLane; - while (node !== null) { - if (node.mode & StrictMode) { - maybeStrictRoot = node; + case InputDiscreteLanePriority: { + var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); + + if (_lane === NoLane) { + // Shift to the next priority level + return findUpdateLane(InputContinuousLanePriority, wipLanes); } - node = node.return; + return _lane; } - return maybeStrictRoot; - }; + case InputContinuousLanePriority: { + var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); - var setToSortedString = function(set) { - var array = []; - set.forEach(function(value) { - array.push(value); - }); - return array.sort().join(", "); - }; + if (_lane2 === NoLane) { + // Shift to the next priority level + return findUpdateLane(DefaultLanePriority, wipLanes); + } - var pendingComponentWillMountWarnings = []; - var pendingUNSAFE_ComponentWillMountWarnings = []; - var pendingComponentWillReceivePropsWarnings = []; - var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; - var pendingComponentWillUpdateWarnings = []; - var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. + return _lane2; + } - var didWarnAboutUnsafeLifecycles = new Set(); + case DefaultLanePriority: { + var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); - ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function( - fiber, - instance - ) { - // Dedup strategy: Warn once per component. - if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { - return; - } + if (_lane3 === NoLane) { + // If all the default lanes are already being worked on, look for a + // lane in the transition range. + _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes); - if ( - typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components. - instance.componentWillMount.__suppressDeprecationWarning !== true - ) { - pendingComponentWillMountWarnings.push(fiber); - } + if (_lane3 === NoLane) { + // All the transition lanes are taken, too. This should be very + // rare, but as a last resort, pick a default lane. This will have + // the effect of interrupting the current work-in-progress render. + _lane3 = pickArbitraryLane(DefaultLanes); + } + } - if ( - fiber.mode & StrictMode && - typeof instance.UNSAFE_componentWillMount === "function" - ) { - pendingUNSAFE_ComponentWillMountWarnings.push(fiber); + return _lane3; } - if ( - typeof instance.componentWillReceiveProps === "function" && - instance.componentWillReceiveProps.__suppressDeprecationWarning !== true - ) { - pendingComponentWillReceivePropsWarnings.push(fiber); - } + case TransitionPriority: // Should be handled by findTransitionLane instead - if ( - fiber.mode & StrictMode && - typeof instance.UNSAFE_componentWillReceiveProps === "function" - ) { - pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); - } + case RetryLanePriority: + // Should be handled by findRetryLane instead + break; - if ( - typeof instance.componentWillUpdate === "function" && - instance.componentWillUpdate.__suppressDeprecationWarning !== true - ) { - pendingComponentWillUpdateWarnings.push(fiber); - } + case IdleLanePriority: + var lane = pickArbitraryLane(IdleLanes & ~wipLanes); - if ( - fiber.mode & StrictMode && - typeof instance.UNSAFE_componentWillUpdate === "function" - ) { - pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); - } - }; + if (lane === NoLane) { + lane = pickArbitraryLane(IdleLanes); + } - ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() { - // We do an initial pass to gather component names - var componentWillMountUniqueNames = new Set(); + return lane; + } - if (pendingComponentWillMountWarnings.length > 0) { - pendingComponentWillMountWarnings.forEach(function(fiber) { - componentWillMountUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingComponentWillMountWarnings = []; - } + { + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); + } +} // To ensure consistency across multiple updates in the same event, this should +// be pure function, so that it always returns the same lane for given inputs. - var UNSAFE_componentWillMountUniqueNames = new Set(); +function findTransitionLane(wipLanes, pendingLanes) { + // First look for lanes that are completely unclaimed, i.e. have no + // pending work. + var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); - if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { - pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) { - UNSAFE_componentWillMountUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingUNSAFE_ComponentWillMountWarnings = []; + if (lane === NoLane) { + // If all lanes have pending work, look for a lane that isn't currently + // being worked on. + lane = pickArbitraryLane(TransitionLanes & ~wipLanes); + + if (lane === NoLane) { + // If everything is being worked on, pick any lane. This has the + // effect of interrupting the current work-in-progress. + lane = pickArbitraryLane(TransitionLanes); } + } - var componentWillReceivePropsUniqueNames = new Set(); + return lane; +} // To ensure consistency across multiple updates in the same event, this should +// be pure function, so that it always returns the same lane for given inputs. - if (pendingComponentWillReceivePropsWarnings.length > 0) { - pendingComponentWillReceivePropsWarnings.forEach(function(fiber) { - componentWillReceivePropsUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingComponentWillReceivePropsWarnings = []; - } +function findRetryLane(wipLanes) { + // This is a fork of `findUpdateLane` designed specifically for Suspense + // "retries" — a special update that attempts to flip a Suspense boundary + // from its placeholder state to its primary/resolved state. + var lane = pickArbitraryLane(RetryLanes & ~wipLanes); - var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); + if (lane === NoLane) { + lane = pickArbitraryLane(RetryLanes); + } - if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { - pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) { - UNSAFE_componentWillReceivePropsUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingUNSAFE_ComponentWillReceivePropsWarnings = []; - } + return lane; +} - var componentWillUpdateUniqueNames = new Set(); +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} - if (pendingComponentWillUpdateWarnings.length > 0) { - pendingComponentWillUpdateWarnings.forEach(function(fiber) { - componentWillUpdateUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingComponentWillUpdateWarnings = []; - } +function getLowestPriorityLane(lanes) { + // This finds the most significant non-zero bit. + var index = 31 - clz32(lanes); + return index < 0 ? NoLanes : 1 << index; +} - var UNSAFE_componentWillUpdateUniqueNames = new Set(); +function getEqualOrHigherPriorityLanes(lanes) { + return (getLowestPriorityLane(lanes) << 1) - 1; +} - if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { - pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) { - UNSAFE_componentWillUpdateUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingUNSAFE_ComponentWillUpdateWarnings = []; - } // Finally, we flush all the warnings - // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' +function pickArbitraryLane(lanes) { + // This wrapper function gets inlined. Only exists so to communicate that it + // doesn't matter which bit is selected; you can pick any bit without + // affecting the algorithms where its used. Here I'm using + // getHighestPriorityLane because it requires the fewest operations. + return getHighestPriorityLane(lanes); +} - if (UNSAFE_componentWillMountUniqueNames.size > 0) { - var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); +function pickArbitraryLaneIndex(lanes) { + return 31 - clz32(lanes); +} - error( - "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + - "\nPlease update the following components: %s", - sortedNames - ); - } +function laneToIndex(lane) { + return pickArbitraryLaneIndex(lane); +} - if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { - var _sortedNames = setToSortedString( - UNSAFE_componentWillReceivePropsUniqueNames - ); +function includesSomeLane(a, b) { + return (a & b) !== NoLanes; +} +function isSubsetOfLanes(set, subset) { + return (set & subset) === subset; +} +function mergeLanes(a, b) { + return a | b; +} +function removeLanes(set, subset) { + return set & ~subset; +} // Seems redundant, but it changes the type from a single lane (used for +// updates) to a group of lanes (used for flushing work). - error( - "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + - "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "* If you're updating state whenever props change, " + - "refactor your code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + - "\nPlease update the following components: %s", - _sortedNames - ); - } +function laneToLanes(lane) { + return lane; +} +function createLaneMap(initial) { + // Intentionally pushing one by one. + // https://v8.dev/blog/elements-kinds#avoid-creating-holes + var laneMap = []; - if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { - var _sortedNames2 = setToSortedString( - UNSAFE_componentWillUpdateUniqueNames - ); + for (var i = 0; i < TotalLanes; i++) { + laneMap.push(initial); + } - error( - "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + - "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "\nPlease update the following components: %s", - _sortedNames2 - ); - } + return laneMap; +} +function markRootUpdated(root, updateLane, eventTime) { + root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But + // it's not practical to try every single possible combination. We need a + // heuristic to decide which lanes to attempt to render, and in which batches. + // For now, we use the same heuristic as in the old ExpirationTimes model: + // retry any lane at equal or lower priority, but don't try updates at higher + // priority without also including the lower priority updates. This works well + // when considering updates across different priority levels, but isn't + // sufficient for updates within the same priority, since we want to treat + // those updates as parallel. + // Unsuspend any update at equal or lower priority. - if (componentWillMountUniqueNames.size > 0) { - var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); + var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 - warn( - "componentWillMount has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + - "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + - "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + - "To rename all deprecated lifecycles to their new names, you can run " + - "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + - "\nPlease update the following components: %s", - _sortedNames3 - ); - } + root.suspendedLanes &= higherPriorityLanes; + root.pingedLanes &= higherPriorityLanes; + var eventTimes = root.eventTimes; + var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most + // recent event, and we assume time is monotonically increasing. - if (componentWillReceivePropsUniqueNames.size > 0) { - var _sortedNames4 = setToSortedString( - componentWillReceivePropsUniqueNames - ); + eventTimes[index] = eventTime; +} +function markRootSuspended(root, suspendedLanes) { + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. + + var expirationTimes = root.expirationTimes; + var lanes = suspendedLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + expirationTimes[index] = NoTimestamp; + lanes &= ~lane; + } +} +function markRootPinged(root, pingedLanes, eventTime) { + root.pingedLanes |= root.suspendedLanes & pingedLanes; +} +function hasDiscreteLanes(lanes) { + return (lanes & InputDiscreteLanes) !== NoLanes; +} +function markRootMutableRead(root, updateLane) { + root.mutableReadLanes |= updateLane & root.pendingLanes; +} +function markRootFinished(root, remainingLanes) { + var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; + root.pendingLanes = remainingLanes; // Let's try everything again + + root.suspendedLanes = 0; + root.pingedLanes = 0; + root.expiredLanes &= remainingLanes; + root.mutableReadLanes &= remainingLanes; + root.entangledLanes &= remainingLanes; + var entanglements = root.entanglements; + var eventTimes = root.eventTimes; + var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work + + var lanes = noLongerPendingLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entanglements[index] = NoLanes; + eventTimes[index] = NoTimestamp; + expirationTimes[index] = NoTimestamp; + lanes &= ~lane; + } +} +function markRootEntangled(root, entangledLanes) { + root.entangledLanes |= entangledLanes; + var entanglements = root.entanglements; + var lanes = entangledLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entanglements[index] |= entangledLanes; + lanes &= ~lane; + } +} +var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer. +// Based on: +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 + +var log = Math.log; +var LN2 = Math.LN2; + +function clz32Fallback(lanes) { + if (lanes === 0) { + return 32; + } + + return (31 - ((log(lanes) / LN2) | 0)) | 0; +} + +// Intentionally not named imports because Rollup would use dynamic dispatch for +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, + Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, + Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_shouldYield = Scheduler.unstable_shouldYield, + Scheduler_requestPaint = Scheduler.unstable_requestPaint, + Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel, + Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, + Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, + Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, + Scheduler_LowPriority = Scheduler.unstable_LowPriority, + Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; + +{ + // Provide explicit error message when production+profiling bundle of e.g. + // react-dom is used with production (non-profiling) bundle of + // scheduler/tracing + if ( + !( + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null + ) + ) { + throw Error( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" + ); + } +} - warn( - "componentWillReceiveProps has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "* If you're updating state whenever props change, refactor your " + - "code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + - "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + - "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + - "To rename all deprecated lifecycles to their new names, you can run " + - "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + - "\nPlease update the following components: %s", - _sortedNames4 - ); - } +var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. - if (componentWillUpdateUniqueNames.size > 0) { - var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); +var ImmediatePriority$1 = 99; +var UserBlockingPriority$1 = 98; +var NormalPriority$1 = 97; +var LowPriority$1 = 96; +var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only. - warn( - "componentWillUpdate has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + - "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + - "To rename all deprecated lifecycles to their new names, you can run " + - "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + - "\nPlease update the following components: %s", - _sortedNames5 - ); - } - }; +var NoPriority$1 = 90; +var shouldYield = Scheduler_shouldYield; +var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. + Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {}; +var syncQueue = null; +var immediateQueueCallbackNode = null; +var isFlushingSyncQueue = false; +var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. +// This will be the case for modern browsers that support `performance.now`. In +// older browsers, Scheduler falls back to `Date.now`, which returns a Unix +// timestamp. In that case, subtract the module initialization time to simulate +// the behavior of performance.now and keep our times small enough to fit +// within 32 bits. +// TODO: Consider lifting this into Scheduler. - var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. +var now = + initialTimeMs$1 < 10000 + ? Scheduler_now$1 + : function() { + return Scheduler_now$1() - initialTimeMs$1; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return ImmediatePriority$1; - var didWarnAboutLegacyContext = new Set(); + case Scheduler_UserBlockingPriority: + return UserBlockingPriority$1; - ReactStrictModeWarnings.recordLegacyContextWarning = function( - fiber, - instance - ) { - var strictRoot = findStrictRoot(fiber); + case Scheduler_NormalPriority: + return NormalPriority$1; - if (strictRoot === null) { - error( - "Expected to find a StrictMode component in a strict mode tree. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + case Scheduler_LowPriority: + return LowPriority$1; - return; - } // Dedup strategy: Warn once per component. + case Scheduler_IdlePriority: + return IdlePriority$1; - if (didWarnAboutLegacyContext.has(fiber.type)) { - return; + default: { + throw Error("Unknown priority level."); } + } +} - var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority$1: + return Scheduler_ImmediatePriority; - if ( - fiber.type.contextTypes != null || - fiber.type.childContextTypes != null || - (instance !== null && typeof instance.getChildContext === "function") - ) { - if (warningsForRoot === undefined) { - warningsForRoot = []; - pendingLegacyContextWarning.set(strictRoot, warningsForRoot); - } + case UserBlockingPriority$1: + return Scheduler_UserBlockingPriority; - warningsForRoot.push(fiber); - } - }; + case NormalPriority$1: + return Scheduler_NormalPriority; - ReactStrictModeWarnings.flushLegacyContextWarning = function() { - pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) { - if (fiberArray.length === 0) { - return; - } + case LowPriority$1: + return Scheduler_LowPriority; - var firstFiber = fiberArray[0]; - var uniqueNames = new Set(); - fiberArray.forEach(function(fiber) { - uniqueNames.add(getComponentName(fiber.type) || "Component"); - didWarnAboutLegacyContext.add(fiber.type); - }); - var sortedNames = setToSortedString(uniqueNames); - var firstComponentStack = getStackByFiberInDevAndProd(firstFiber); + case IdlePriority$1: + return Scheduler_IdlePriority; - error( - "Legacy context API has been detected within a strict-mode tree." + - "\n\nThe old API will be supported in all 16.x releases, but applications " + - "using it should migrate to the new version." + - "\n\nPlease update the following components: %s" + - "\n\nLearn more about this warning here: https://fb.me/react-legacy-context" + - "%s", - sortedNames, - firstComponentStack - ); - }); - }; + default: { + throw Error("Unknown priority level."); + } + } +} - ReactStrictModeWarnings.discardPendingWarnings = function() { - pendingComponentWillMountWarnings = []; - pendingUNSAFE_ComponentWillMountWarnings = []; - pendingComponentWillReceivePropsWarnings = []; - pendingUNSAFE_ComponentWillReceivePropsWarnings = []; - pendingComponentWillUpdateWarnings = []; - pendingUNSAFE_ComponentWillUpdateWarnings = []; - pendingLegacyContextWarning = new Map(); - }; +function runWithPriority(reactPriorityLevel, fn) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(priorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(priorityLevel, callback, options); } +function scheduleSyncCallback(callback) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushSyncCallbackQueue`. + if (syncQueue === null) { + syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. -var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. + immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ); + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + syncQueue.push(callback); + } -var failedBoundaries = null; -var setRefreshHandler = function(handler) { - { - resolveFamily = handler; + return fakeCallbackNode; +} +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } +} +function flushSyncCallbackQueue() { + if (immediateQueueCallbackNode !== null) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); } -}; -function resolveFunctionForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; - } - var family = resolveFamily(type); + flushSyncCallbackQueueImpl(); +} - if (family === undefined) { - return type; - } // Use the latest known implementation. +function flushSyncCallbackQueueImpl() { + if (!isFlushingSyncQueue && syncQueue !== null) { + // Prevent re-entrancy. + isFlushingSyncQueue = true; + var i = 0; - return family.current; + { + try { + var _isSync2 = true; + var _queue = syncQueue; + runWithPriority(ImmediatePriority$1, function() { + for (; i < _queue.length; i++) { + var callback = _queue[i]; + + do { + callback = callback(_isSync2); + } while (callback !== null); + } + }); + syncQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (syncQueue !== null) { + syncQueue = syncQueue.slice(i + 1); + } // Resume flushing in the next tick + + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ); + throw error; + } finally { + isFlushingSyncQueue = false; + } + } } } -function resolveClassForHotReloading(type) { - // No implementation differences. - return resolveFunctionForHotReloading(type); -} -function resolveForwardRefForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; - } - var family = resolveFamily(type); +// TODO: this is special because it gets imported during build. +var ReactVersion = "17.0.1-4e5d7faf5"; - if (family === undefined) { - // Check if we're dealing with a real forwardRef. Don't want to crash early. - if ( - type !== null && - type !== undefined && - typeof type.render === "function" - ) { - // ForwardRef is special because its resolved .type is an object, - // but it's possible that we only have its inner render function in the map. - // If that inner render function is different, we'll build a new forwardRef type. - var currentRender = resolveFunctionForHotReloading(type.render); +var NoMode = 0; +var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root +// tag instead - if (type.render !== currentRender) { - var syntheticType = { - $$typeof: REACT_FORWARD_REF_TYPE, - render: currentRender - }; +var BlockingMode = 2; +var ConcurrentMode = 4; +var ProfileMode = 8; +var DebugTracingMode = 16; - if (type.displayName !== undefined) { - syntheticType.displayName = type.displayName; - } +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; +var NoTransition = 0; +function requestCurrentTransition() { + return ReactCurrentBatchConfig.transition; +} - return syntheticType; - } - } +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return ( + (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare + ); +} + +var objectIs = typeof Object.is === "function" ? Object.is : is; + +var hasOwnProperty = Object.prototype.hasOwnProperty; +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ - return type; - } // Use the latest known implementation. +function shallowEqual(objA, objB) { + if (objectIs(objA, objB)) { + return true; + } - return family.current; + if ( + typeof objA !== "object" || + objA === null || + typeof objB !== "object" || + objB === null + ) { + return false; } -} -function isCompatibleFamilyForHotReloading(fiber, element) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } // Test for A's keys different from B. + + for (var i = 0; i < keysA.length; i++) { + if ( + !hasOwnProperty.call(objB, keysA[i]) || + !objectIs(objA[keysA[i]], objB[keysA[i]]) + ) { return false; } + } - var prevType = fiber.elementType; - var nextType = element.type; // If we got here, we know types aren't === equal. + return true; +} - var needsCompareFamilies = false; - var $$typeofNextType = - typeof nextType === "object" && nextType !== null - ? nextType.$$typeof - : null; +function describeFiber(fiber) { + var owner = fiber._debugOwner ? fiber._debugOwner.type : null; + var source = fiber._debugSource; - switch (fiber.tag) { - case ClassComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } + switch (fiber.tag) { + case HostComponent: + return describeBuiltInComponentFrame(fiber.type, source, owner); - break; - } + case LazyComponent: + return describeBuiltInComponentFrame("Lazy", source, owner); - case FunctionComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - // We don't know the inner type yet. - // We're going to assume that the lazy inner type is stable, - // and so it is sufficient to avoid reconciling it away. - // We're not going to unwrap or actually use the new lazy type. - needsCompareFamilies = true; - } + case SuspenseComponent: + return describeBuiltInComponentFrame("Suspense", source, owner); - break; - } + case SuspenseListComponent: + return describeBuiltInComponentFrame("SuspenseList", source, owner); - case ForwardRef: { - if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } + case FunctionComponent: + case IndeterminateComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type, source, owner); - break; - } + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render, source, owner); - case MemoComponent: - case SimpleMemoComponent: { - if ($$typeofNextType === REACT_MEMO_TYPE) { - // TODO: if it was but can no longer be simple, - // we shouldn't set this. - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } + case Block: + return describeFunctionComponentFrame(fiber.type._render, source, owner); - break; - } + case ClassComponent: + return describeClassComponentFrame(fiber.type, source, owner); - default: - return false; - } // Check if both types have a family and it's the same one. + default: + return ""; + } +} - if (needsCompareFamilies) { - // Note: memo() and forwardRef() we'll compare outer rather than inner type. - // This means both of them need to be registered to preserve state. - // If we unwrapped and compared the inner types for wrappers instead, - // then we would risk falsely saying two separate memo(Foo) - // calls are equivalent because they wrap the same Foo function. - var prevFamily = resolveFamily(prevType); +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + var node = workInProgress; - if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { - return true; - } - } + do { + info += describeFiber(node); + node = node.return; + } while (node); - return false; + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; } } -function markFailedErrorBoundaryForHotReloading(fiber) { + +var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; +var current = null; +var isRendering = false; +function getCurrentFiberOwnerNameInDevOrNull() { { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; + if (current === null) { + return null; } - if (typeof WeakSet !== "function") { - return; - } + var owner = current._debugOwner; - if (failedBoundaries === null) { - failedBoundaries = new WeakSet(); + if (owner !== null && typeof owner !== "undefined") { + return getComponentName(owner.type); } + } - failedBoundaries.add(fiber); + return null; +} + +function getCurrentFiberStackInDev() { + { + if (current === null) { + return ""; + } // Safe because if current fiber exists, we are reconciling, + // and it is guaranteed to be the work-in-progress version. + + return getStackByFiberInDevAndProd(current); } } -var scheduleRefresh = function(root, update) { + +function resetCurrentFiber() { { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; + ReactDebugCurrentFrame$1.getCurrentStack = null; + current = null; + isRendering = false; + } +} +function setCurrentFiber(fiber) { + { + ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; + current = fiber; + isRendering = false; + } +} +function setIsRendering(rendering) { + { + isRendering = rendering; + } +} +function getIsRendering() { + { + return isRendering; + } +} + +var ReactStrictModeWarnings = { + recordUnsafeLifecycleWarnings: function(fiber, instance) {}, + flushPendingUnsafeLifecycleWarnings: function() {}, + recordLegacyContextWarning: function(fiber, instance) {}, + flushLegacyContextWarning: function() {}, + discardPendingWarnings: function() {} +}; + +{ + var findStrictRoot = function(fiber) { + var maybeStrictRoot = null; + var node = fiber; + + while (node !== null) { + if (node.mode & StrictMode) { + maybeStrictRoot = node; + } + + node = node.return; } - var staleFamilies = update.staleFamilies, - updatedFamilies = update.updatedFamilies; - flushPassiveEffects(); - flushSync(function() { - scheduleFibersWithFamiliesRecursively( - root.current, - updatedFamilies, - staleFamilies - ); + return maybeStrictRoot; + }; + + var setToSortedString = function(set) { + var array = []; + set.forEach(function(value) { + array.push(value); }); - } -}; -var scheduleRoot = function(root, element) { - { - if (root.context !== emptyContextObject) { - // Super edge case: root has a legacy _renderSubtree context - // but we don't know the parentComponent so we can't pass it. - // Just ignore. We'll delete this with _renderSubtree code path later. + return array.sort().join(", "); + }; + + var pendingComponentWillMountWarnings = []; + var pendingUNSAFE_ComponentWillMountWarnings = []; + var pendingComponentWillReceivePropsWarnings = []; + var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + var pendingComponentWillUpdateWarnings = []; + var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. + + var didWarnAboutUnsafeLifecycles = new Set(); + + ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function( + fiber, + instance + ) { + // Dedup strategy: Warn once per component. + if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { return; } - flushPassiveEffects(); - syncUpdates(function() { - updateContainer(element, root, null, null); - }); - } -}; + if ( + typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components. + instance.componentWillMount.__suppressDeprecationWarning !== true + ) { + pendingComponentWillMountWarnings.push(fiber); + } -function scheduleFibersWithFamiliesRecursively( - fiber, - updatedFamilies, - staleFamilies -) { - { - var alternate = fiber.alternate, - child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; + if ( + fiber.mode & StrictMode && + typeof instance.UNSAFE_componentWillMount === "function" + ) { + pendingUNSAFE_ComponentWillMountWarnings.push(fiber); + } - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; + if ( + typeof instance.componentWillReceiveProps === "function" && + instance.componentWillReceiveProps.__suppressDeprecationWarning !== true + ) { + pendingComponentWillReceivePropsWarnings.push(fiber); + } - case ForwardRef: - candidateType = type.render; - break; + if ( + fiber.mode & StrictMode && + typeof instance.UNSAFE_componentWillReceiveProps === "function" + ) { + pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); } - if (resolveFamily === null) { - throw new Error("Expected resolveFamily to be set during hot reload."); + if ( + typeof instance.componentWillUpdate === "function" && + instance.componentWillUpdate.__suppressDeprecationWarning !== true + ) { + pendingComponentWillUpdateWarnings.push(fiber); } - var needsRender = false; - var needsRemount = false; + if ( + fiber.mode & StrictMode && + typeof instance.UNSAFE_componentWillUpdate === "function" + ) { + pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); + } + }; - if (candidateType !== null) { - var family = resolveFamily(candidateType); + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() { + // We do an initial pass to gather component names + var componentWillMountUniqueNames = new Set(); - if (family !== undefined) { - if (staleFamilies.has(family)) { - needsRemount = true; - } else if (updatedFamilies.has(family)) { - if (tag === ClassComponent) { - needsRemount = true; - } else { - needsRender = true; - } - } - } + if (pendingComponentWillMountWarnings.length > 0) { + pendingComponentWillMountWarnings.forEach(function(fiber) { + componentWillMountUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillMountWarnings = []; } - if (failedBoundaries !== null) { - if ( - failedBoundaries.has(fiber) || - (alternate !== null && failedBoundaries.has(alternate)) - ) { - needsRemount = true; - } + var UNSAFE_componentWillMountUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { + pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) { + UNSAFE_componentWillMountUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillMountWarnings = []; } - if (needsRemount) { - fiber._debugNeedsRemount = true; + var componentWillReceivePropsUniqueNames = new Set(); + + if (pendingComponentWillReceivePropsWarnings.length > 0) { + pendingComponentWillReceivePropsWarnings.forEach(function(fiber) { + componentWillReceivePropsUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillReceivePropsWarnings = []; } - if (needsRemount || needsRender) { - scheduleWork(fiber, Sync); + var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { + pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) { + UNSAFE_componentWillReceivePropsUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; } - if (child !== null && !needsRemount) { - scheduleFibersWithFamiliesRecursively( - child, - updatedFamilies, - staleFamilies - ); + var componentWillUpdateUniqueNames = new Set(); + + if (pendingComponentWillUpdateWarnings.length > 0) { + pendingComponentWillUpdateWarnings.forEach(function(fiber) { + componentWillUpdateUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillUpdateWarnings = []; } - if (sibling !== null) { - scheduleFibersWithFamiliesRecursively( - sibling, - updatedFamilies, - staleFamilies + var UNSAFE_componentWillUpdateUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { + pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) { + UNSAFE_componentWillUpdateUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillUpdateWarnings = []; + } // Finally, we flush all the warnings + // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' + + if (UNSAFE_componentWillMountUniqueNames.size > 0) { + var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); + + error( + "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + + "\nPlease update the following components: %s", + sortedNames ); } - } -} -var findHostInstancesForRefresh = function(root, families) { - { - var hostInstances = new Set(); - var types = new Set( - families.map(function(family) { - return family.current; - }) - ); - findHostInstancesForMatchingFibersRecursively( - root.current, - types, - hostInstances - ); - return hostInstances; - } -}; + if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames = setToSortedString( + UNSAFE_componentWillReceivePropsUniqueNames + ); -function findHostInstancesForMatchingFibersRecursively( - fiber, - types, - hostInstances -) { - { - var child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; + error( + "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + + "and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* If you're updating state whenever props change, " + + "refactor your code to use memoization techniques or move it to " + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + + "\nPlease update the following components: %s", + _sortedNames + ); + } - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; + if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { + var _sortedNames2 = setToSortedString( + UNSAFE_componentWillUpdateUniqueNames + ); - case ForwardRef: - candidateType = type.render; - break; + error( + "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + + "and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "\nPlease update the following components: %s", + _sortedNames2 + ); } - var didMatch = false; + if (componentWillMountUniqueNames.size > 0) { + var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); - if (candidateType !== null) { - if (types.has(candidateType)) { - didMatch = true; - } + warn( + "componentWillMount has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + + "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames3 + ); } - if (didMatch) { - // We have a match. This only drills down to the closest host components. - // There's no need to search deeper because for the purpose of giving - // visual feedback, "flashing" outermost parent rectangles is sufficient. - findHostInstancesForFiberShallowly(fiber, hostInstances); - } else { - // If there's no match, maybe there will be one further down in the child tree. - if (child !== null) { - findHostInstancesForMatchingFibersRecursively( - child, - types, - hostInstances - ); - } - } + if (componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames4 = setToSortedString( + componentWillReceivePropsUniqueNames + ); - if (sibling !== null) { - findHostInstancesForMatchingFibersRecursively( - sibling, - types, - hostInstances + warn( + "componentWillReceiveProps has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* If you're updating state whenever props change, refactor your " + + "code to use memoization techniques or move it to " + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + + "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames4 ); } - } -} -function findHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var foundHostInstances = findChildHostInstancesForFiberShallowly( - fiber, - hostInstances - ); + if (componentWillUpdateUniqueNames.size > 0) { + var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); - if (foundHostInstances) { - return; - } // If we didn't find any host children, fallback to closest host parent. + warn( + "componentWillUpdate has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames5 + ); + } + }; - var node = fiber; + var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. - while (true) { - switch (node.tag) { - case HostComponent: - hostInstances.add(node.stateNode); - return; + var didWarnAboutLegacyContext = new Set(); - case HostPortal: - hostInstances.add(node.stateNode.containerInfo); - return; + ReactStrictModeWarnings.recordLegacyContextWarning = function( + fiber, + instance + ) { + var strictRoot = findStrictRoot(fiber); - case HostRoot: - hostInstances.add(node.stateNode.containerInfo); - return; - } + if (strictRoot === null) { + error( + "Expected to find a StrictMode component in a strict mode tree. " + + "This error is likely caused by a bug in React. Please file an issue." + ); - if (node.return === null) { - throw new Error("Expected to reach root first."); - } + return; + } // Dedup strategy: Warn once per component. - node = node.return; + if (didWarnAboutLegacyContext.has(fiber.type)) { + return; } - } -} -function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var node = fiber; - var foundHostInstances = false; + var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); - while (true) { - if (node.tag === HostComponent) { - // We got a match. - foundHostInstances = true; - hostInstances.add(node.stateNode); // There may still be more, so keep searching. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; + if ( + fiber.type.contextTypes != null || + fiber.type.childContextTypes != null || + (instance !== null && typeof instance.getChildContext === "function") + ) { + if (warningsForRoot === undefined) { + warningsForRoot = []; + pendingLegacyContextWarning.set(strictRoot, warningsForRoot); } - if (node === fiber) { - return foundHostInstances; + warningsForRoot.push(fiber); + } + }; + + ReactStrictModeWarnings.flushLegacyContextWarning = function() { + pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) { + if (fiberArray.length === 0) { + return; } - while (node.sibling === null) { - if (node.return === null || node.return === fiber) { - return foundHostInstances; - } + var firstFiber = fiberArray[0]; + var uniqueNames = new Set(); + fiberArray.forEach(function(fiber) { + uniqueNames.add(getComponentName(fiber.type) || "Component"); + didWarnAboutLegacyContext.add(fiber.type); + }); + var sortedNames = setToSortedString(uniqueNames); - node = node.return; - } + try { + setCurrentFiber(firstFiber); - node.sibling.return = node.return; - node = node.sibling; - } - } + error( + "Legacy context API has been detected within a strict-mode tree." + + "\n\nThe old API will be supported in all 16.x releases, but applications " + + "using it should migrate to the new version." + + "\n\nPlease update the following components: %s" + + "\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context", + sortedNames + ); + } finally { + resetCurrentFiber(); + } + }); + }; - return false; + ReactStrictModeWarnings.discardPendingWarnings = function() { + pendingComponentWillMountWarnings = []; + pendingUNSAFE_ComponentWillMountWarnings = []; + pendingComponentWillReceivePropsWarnings = []; + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + pendingComponentWillUpdateWarnings = []; + pendingUNSAFE_ComponentWillUpdateWarnings = []; + pendingLegacyContextWarning = new Map(); + }; } function resolveDefaultProps(Component, baseProps) { @@ -6107,15 +6158,11 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } -function readLazyComponentType(lazyComponent) { - initializeLazyComponentType(lazyComponent); - - if (lazyComponent._status !== Resolved) { - throw lazyComponent._result; - } - return lazyComponent._result; -} +// Max 31 bit integer. The max integer size in V8 for 32-bit systems. +// Math.pow(2, 30) - 1 +// 0b111111111111111111111111111111 +var MAX_SIGNED_31_BIT_INT = 1073741823; var valueCursor = createCursor(null); var rendererSigil; @@ -6205,28 +6252,24 @@ function calculateChangedBits(context, newValue, oldValue) { return changedBits | 0; } } -function scheduleWorkOnParentPath(parent, renderExpirationTime) { - // Update the child expiration time of all the ancestors, including - // the alternates. +function scheduleWorkOnParentPath(parent, renderLanes) { + // Update the child lanes of all the ancestors, including the alternates. var node = parent; while (node !== null) { var alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { - node.childExpirationTime = renderExpirationTime; + if (!isSubsetOfLanes(node.childLanes, renderLanes)) { + node.childLanes = mergeLanes(node.childLanes, renderLanes); - if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); } } else if ( alternate !== null && - alternate.childExpirationTime < renderExpirationTime + !isSubsetOfLanes(alternate.childLanes, renderLanes) ) { - alternate.childExpirationTime = renderExpirationTime; + alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); } else { // Neither alternate was updated, which means the rest of the // ancestor path already has sufficient priority. @@ -6240,7 +6283,7 @@ function propagateContextChange( workInProgress, context, changedBits, - renderExpirationTime + renderLanes ) { var fiber = workInProgress.child; @@ -6267,7 +6310,10 @@ function propagateContextChange( // Match! Schedule an update on this fiber. if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. - var update = createUpdate(renderExpirationTime, null); + var update = createUpdate( + NoTimestamp, + pickArbitraryLane(renderLanes) + ); update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the // update to the current fiber, too, which means it will persist even if // this render is thrown away. Since it's a race condition, not sure it's @@ -6276,24 +6322,16 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } - + fiber.lanes = mergeLanes(fiber.lanes, renderLanes); var alternate = fiber.alternate; - if ( - alternate !== null && - alternate.expirationTime < renderExpirationTime - ) { - alternate.expirationTime = renderExpirationTime; + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, renderLanes); } - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. + scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too. - if (list.expirationTime < renderExpirationTime) { - list.expirationTime = renderExpirationTime; - } // Since we already found a match, we can stop traversing the + list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the // dependency list. break; @@ -6339,7 +6377,7 @@ function propagateContextChange( fiber = nextFiber; } } -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress, renderLanes) { currentlyRenderingFiber = workInProgress; lastContextDependency = null; lastContextWithAllBitsObserved = null; @@ -6349,7 +6387,7 @@ function prepareToReadContext(workInProgress, renderExpirationTime) { var firstContext = dependencies.firstContext; if (firstContext !== null) { - if (dependencies.expirationTime >= renderExpirationTime) { + if (includesSomeLane(dependencies.lanes, renderLanes)) { // Context list has a pending update. Mark that this fiber performed work. markWorkInProgressReceivedUpdate(); } // Reset the work-in-progress list @@ -6403,7 +6441,7 @@ function readContext(context, observedBits) { lastContextDependency = contextItem; currentlyRenderingFiber.dependencies = { - expirationTime: NoWork, + lanes: NoLanes, firstContext: contextItem, responders: null }; @@ -6435,7 +6473,8 @@ var currentlyProcessingQueue; function initializeUpdateQueue(fiber) { var queue = { baseState: fiber.memoizedState, - baseQueue: null, + firstBaseUpdate: null, + lastBaseUpdate: null, shared: { pending: null }, @@ -6451,28 +6490,23 @@ function cloneUpdateQueue(current, workInProgress) { if (queue === currentQueue) { var clone = { baseState: currentQueue.baseState, - baseQueue: currentQueue.baseQueue, + firstBaseUpdate: currentQueue.firstBaseUpdate, + lastBaseUpdate: currentQueue.lastBaseUpdate, shared: currentQueue.shared, effects: currentQueue.effects }; workInProgress.updateQueue = clone; } } -function createUpdate(expirationTime, suspenseConfig) { +function createUpdate(eventTime, lane) { var update = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, + eventTime: eventTime, + lane: lane, tag: UpdateState, payload: null, callback: null, next: null }; - update.next = update; - - { - update.priority = getCurrentPriorityLevel(); - } - return update; } function enqueueUpdate(fiber, update) { @@ -6512,25 +6546,84 @@ function enqueueUpdate(fiber, update) { } } } -function enqueueCapturedUpdate(workInProgress, update) { +function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + // Captured updates are updates that are thrown by a child during the render + // phase. They should be discarded if the render is aborted. Therefore, + // we should only put them on the work-in-progress queue, not the current one. + var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. + var current = workInProgress.alternate; if (current !== null) { - // Ensure the work-in-progress queue is a clone - cloneUpdateQueue(current, workInProgress); - } // Captured updates go only on the work-in-progress queue. + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + // The work-in-progress queue is the same as current. This happens when + // we bail out on a parent fiber that then captures an error thrown by + // a child. Since we want to append the update only to the work-in + // -progress queue, we need to clone the updates. We usually clone during + // processUpdateQueue, but that didn't happen in this case because we + // skipped over the parent when we bailed out. + var newFirst = null; + var newLast = null; + var firstBaseUpdate = queue.firstBaseUpdate; + + if (firstBaseUpdate !== null) { + // Loop through the updates and clone them. + var update = firstBaseUpdate; + + do { + var clone = { + eventTime: update.eventTime, + lane: update.lane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - var queue = workInProgress.updateQueue; // Append the update to the end of the list. + if (newLast === null) { + newFirst = newLast = clone; + } else { + newLast.next = clone; + newLast = clone; + } - var last = queue.baseQueue; + update = update.next; + } while (update !== null); // Append the captured update the end of the cloned list. - if (last === null) { - queue.baseQueue = update.next = update; - update.next = update; + if (newLast === null) { + newFirst = newLast = capturedUpdate; + } else { + newLast.next = capturedUpdate; + newLast = capturedUpdate; + } + } else { + // There are no base updates. + newFirst = newLast = capturedUpdate; + } + + queue = { + baseState: currentQueue.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = queue; + return; + } + } // Append the update to the end of the list. + + var lastBaseUpdate = queue.lastBaseUpdate; + + if (lastBaseUpdate === null) { + queue.firstBaseUpdate = capturedUpdate; } else { - update.next = last.next; - last.next = update; + lastBaseUpdate.next = capturedUpdate; } + + queue.lastBaseUpdate = capturedUpdate; } function getStateFromUpdate( @@ -6564,8 +6657,8 @@ function getStateFromUpdate( } case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = + (workInProgress.flags & ~ShouldCapture) | DidCapture; } // Intentional fallthrough @@ -6606,161 +6699,163 @@ function getStateFromUpdate( return prevState; } -function processUpdateQueue( - workInProgress, - props, - instance, - renderExpirationTime -) { +function processUpdateQueue(workInProgress, props, instance, renderLanes) { // This is always non-null on a ClassComponent or HostRoot var queue = workInProgress.updateQueue; hasForceUpdate = false; { currentlyProcessingQueue = queue.shared; - } // The last rebase update that is NOT part of the base state. + } - var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. + var firstBaseUpdate = queue.firstBaseUpdate; + var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. var pendingQueue = queue.shared.pending; if (pendingQueue !== null) { - // We have new updates that haven't been processed yet. - // We'll add them to the base queue. - if (baseQueue !== null) { - // Merge the pending queue and the base queue. - var baseFirst = baseQueue.next; - var pendingFirst = pendingQueue.next; - baseQueue.next = pendingFirst; - pendingQueue.next = baseFirst; + queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first + // and last so that it's non-circular. + + var lastPendingUpdate = pendingQueue; + var firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; // Append pending updates to base queue + + if (lastBaseUpdate === null) { + firstBaseUpdate = firstPendingUpdate; + } else { + lastBaseUpdate.next = firstPendingUpdate; } - baseQueue = pendingQueue; - queue.shared.pending = null; // TODO: Pass `current` as argument + lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then + // we need to transfer the updates to that queue, too. Because the base + // queue is a singly-linked list with no cycles, we can append to both + // lists and take advantage of structural sharing. + // TODO: Pass `current` as argument var current = workInProgress.alternate; if (current !== null) { + // This is always non-null on a ClassComponent or HostRoot var currentQueue = current.updateQueue; + var currentLastBaseUpdate = currentQueue.lastBaseUpdate; + + if (currentLastBaseUpdate !== lastBaseUpdate) { + if (currentLastBaseUpdate === null) { + currentQueue.firstBaseUpdate = firstPendingUpdate; + } else { + currentLastBaseUpdate.next = firstPendingUpdate; + } - if (currentQueue !== null) { - currentQueue.baseQueue = pendingQueue; + currentQueue.lastBaseUpdate = lastPendingUpdate; } } } // These values may change as we process the queue. - if (baseQueue !== null) { - var first = baseQueue.next; // Iterate through the list of updates to compute the result. + if (firstBaseUpdate !== null) { + // Iterate through the list of updates to compute the result. + var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes + // from the original lanes. - var newState = queue.baseState; - var newExpirationTime = NoWork; + var newLanes = NoLanes; var newBaseState = null; - var newBaseQueueFirst = null; - var newBaseQueueLast = null; + var newFirstBaseUpdate = null; + var newLastBaseUpdate = null; + var update = firstBaseUpdate; - if (first !== null) { - var update = first; + do { + var updateLane = update.lane; + var updateEventTime = update.eventTime; - do { - var updateExpirationTime = update.expirationTime; + if (!isSubsetOfLanes(renderLanes, updateLane)) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + eventTime: updateEventTime, + lane: updateLane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - if (updateExpirationTime < renderExpirationTime) { - // Priority is insufficient. Skip this update. If this is the first - // skipped update, the previous update/state is the new base - // update/state. - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, + if (newLastBaseUpdate === null) { + newFirstBaseUpdate = newLastBaseUpdate = clone; + newBaseState = newState; + } else { + newLastBaseUpdate = newLastBaseUpdate.next = clone; + } // Update the remaining priority in the queue. + + newLanes = mergeLanes(newLanes, updateLane); + } else { + // This update does have sufficient priority. + if (newLastBaseUpdate !== null) { + var _clone = { + eventTime: updateEventTime, + // This update is going to be committed so we never want uncommit + // it. Using NoLane works because 0 is a subset of all bitmasks, so + // this will never be skipped by the check above. + lane: NoLane, tag: update.tag, payload: update.payload, callback: update.callback, next: null }; + newLastBaseUpdate = newLastBaseUpdate.next = _clone; + } // Process this update. - if (newBaseQueueLast === null) { - newBaseQueueFirst = newBaseQueueLast = clone; - newBaseState = newState; - } else { - newBaseQueueLast = newBaseQueueLast.next = clone; - } // Update the remaining priority in the queue. - - if (updateExpirationTime > newExpirationTime) { - newExpirationTime = updateExpirationTime; - } - } else { - // This update does have sufficient priority. - if (newBaseQueueLast !== null) { - var _clone = { - expirationTime: Sync, - // This update is going to be committed so we never want uncommit it. - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }; - newBaseQueueLast = newBaseQueueLast.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ); // Process this update. - - newState = getStateFromUpdate( - workInProgress, - queue, - update, - newState, - props, - instance - ); - var callback = update.callback; + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; - if (callback !== null) { - workInProgress.effectTag |= Callback; - var effects = queue.effects; + if (callback !== null) { + workInProgress.flags |= Callback; + var effects = queue.effects; - if (effects === null) { - queue.effects = [update]; - } else { - effects.push(update); - } + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); } } + } - update = update.next; + update = update.next; - if (update === null || update === first) { - pendingQueue = queue.shared.pending; + if (update === null) { + pendingQueue = queue.shared.pending; - if (pendingQueue === null) { - break; - } else { - // An update was scheduled from inside a reducer. Add the new - // pending updates to the end of the list and keep processing. - update = baseQueue.next = pendingQueue.next; - pendingQueue.next = first; - queue.baseQueue = baseQueue = pendingQueue; - queue.shared.pending = null; - } + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we + // unravel them when transferring them to the base queue. + + var _firstPendingUpdate = _lastPendingUpdate.next; + _lastPendingUpdate.next = null; + update = _firstPendingUpdate; + queue.lastBaseUpdate = _lastPendingUpdate; + queue.shared.pending = null; } - } while (true); - } + } + } while (true); - if (newBaseQueueLast === null) { + if (newLastBaseUpdate === null) { newBaseState = newState; - } else { - newBaseQueueLast.next = newBaseQueueFirst; } queue.baseState = newBaseState; - queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. + queue.firstBaseUpdate = newFirstBaseUpdate; + queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. // This should be fine because the only two other things that contribute to // expiration time are props and context. We're already in the middle of the // begin phase by the time we start processing the queue, so we've already @@ -6768,8 +6863,8 @@ function processUpdateQueue( // shouldComponentUpdate is tricky; but we'll have to account for // that regardless. - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; + markSkippedUpdateLanes(newLanes); + workInProgress.lanes = newLanes; workInProgress.memoizedState = newState; } @@ -6813,11 +6908,6 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; -function requestCurrentSuspenseConfig() { - return ReactCurrentBatchConfig.suspense; -} - var fakeInternalInstance = {}; var isArray = Array.isArray; // React.Component uses a shared frozen object by default. // We'll use it to determine whether we need to initialize legacy refs. @@ -6918,7 +7008,7 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - if (workInProgress.expirationTime === NoWork) { + if (workInProgress.lanes === NoLanes) { // Queue is always non-null for classes var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; @@ -6928,14 +7018,9 @@ var classComponentUpdater = { isMounted: isMounted, enqueueSetState: function(inst, payload, callback) { var fiber = get(inst); - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); - var update = createUpdate(expirationTime, suspenseConfig); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.payload = payload; if (callback !== undefined && callback !== null) { @@ -6947,18 +7032,13 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); - var update = createUpdate(expirationTime, suspenseConfig); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ReplaceState; update.payload = payload; @@ -6971,18 +7051,13 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); - var update = createUpdate(expirationTime, suspenseConfig); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ForceUpdate; if (callback !== undefined && callback !== null) { @@ -6994,7 +7069,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } }; @@ -7010,13 +7085,11 @@ function checkShouldComponentUpdate( var instance = workInProgress.stateNode; if (typeof instance.shouldComponentUpdate === "function") { - startPhaseTimer(workInProgress, "shouldComponentUpdate"); var shouldUpdate = instance.shouldComponentUpdate( newProps, newState, nextContext ); - stopPhaseTimer(); { if (shouldUpdate === undefined) { @@ -7419,7 +7492,7 @@ function constructClassInstance(workInProgress, ctor, props) { "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + - "https://fb.me/react-unsafe-component-lifecycles", + "https://reactjs.org/link/unsafe-component-lifecycles", _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : "", @@ -7442,7 +7515,6 @@ function constructClassInstance(workInProgress, ctor, props) { } function callComponentWillMount(workInProgress, instance) { - startPhaseTimer(workInProgress, "componentWillMount"); var oldState = instance.state; if (typeof instance.componentWillMount === "function") { @@ -7453,8 +7525,6 @@ function callComponentWillMount(workInProgress, instance) { instance.UNSAFE_componentWillMount(); } - stopPhaseTimer(); - if (oldState !== instance.state) { { error( @@ -7476,7 +7546,6 @@ function callComponentWillReceiveProps( nextContext ) { var oldState = instance.state; - startPhaseTimer(workInProgress, "componentWillReceiveProps"); if (typeof instance.componentWillReceiveProps === "function") { instance.componentWillReceiveProps(newProps, nextContext); @@ -7486,8 +7555,6 @@ function callComponentWillReceiveProps( instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); } - stopPhaseTimer(); - if (instance.state !== oldState) { { var componentName = getComponentName(workInProgress.type) || "Component"; @@ -7508,12 +7575,7 @@ function callComponentWillReceiveProps( } } // Invokes the mount life-cycles on a previously never rendered instance. -function mountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { +function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { { checkClassInstance(workInProgress, ctor, newProps); } @@ -7563,7 +7625,7 @@ function mountClassInstance( } } - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; @@ -7587,26 +7649,16 @@ function mountClassInstance( callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - processUpdateQueue( - workInProgress, - newProps, - instance, - renderExpirationTime - ); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; - } -} - -function resumeMountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { + workInProgress.flags |= Update; + } +} + +function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; instance.props = oldProps; @@ -7652,7 +7704,7 @@ function resumeMountClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); newState = workInProgress.memoizedState; if ( @@ -7664,7 +7716,7 @@ function resumeMountClassInstance( // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return false; @@ -7700,8 +7752,6 @@ function resumeMountClassInstance( (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function") ) { - startPhaseTimer(workInProgress, "componentWillMount"); - if (typeof instance.componentWillMount === "function") { instance.componentWillMount(); } @@ -7709,18 +7759,16 @@ function resumeMountClassInstance( if (typeof instance.UNSAFE_componentWillMount === "function") { instance.UNSAFE_componentWillMount(); } - - stopPhaseTimer(); } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the // memoized state to indicate that this work can be reused. @@ -7740,15 +7788,17 @@ function updateClassInstance( workInProgress, ctor, newProps, - renderExpirationTime + renderLanes ) { var instance = workInProgress.stateNode; cloneUpdateQueue(current, workInProgress); - var oldProps = workInProgress.memoizedProps; - instance.props = + var unresolvedOldProps = workInProgress.memoizedProps; + var oldProps = workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps); + ? unresolvedOldProps + : resolveDefaultProps(workInProgress.type, unresolvedOldProps); + instance.props = oldProps; + var unresolvedNewProps = workInProgress.pendingProps; var oldContext = instance.context; var contextType = ctor.contextType; var nextContext = emptyContextObject; @@ -7774,7 +7824,10 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if (oldProps !== newProps || oldContext !== nextContext) { + if ( + unresolvedOldProps !== unresolvedNewProps || + oldContext !== nextContext + ) { callComponentWillReceiveProps( workInProgress, instance, @@ -7787,11 +7840,11 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); newState = workInProgress.memoizedState; if ( - oldProps === newProps && + unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() @@ -7800,19 +7853,19 @@ function updateClassInstance( // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } @@ -7849,8 +7902,6 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillUpdate === "function" || typeof instance.componentWillUpdate === "function") ) { - startPhaseTimer(workInProgress, "componentWillUpdate"); - if (typeof instance.componentWillUpdate === "function") { instance.componentWillUpdate(newProps, newState, nextContext); } @@ -7858,35 +7909,33 @@ function updateClassInstance( if (typeof instance.UNSAFE_componentWillUpdate === "function") { instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); } - - stopPhaseTimer(); } if (typeof instance.componentDidUpdate === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } if (typeof instance.getSnapshotBeforeUpdate === "function") { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } // If shouldComponentUpdate returned false, we should still update the // memoized props/state to indicate that this work can be reused. @@ -7908,7 +7957,7 @@ var didWarnAboutStringRefs; var ownerHasKeyUseWarning; var ownerHasFunctionTypeWarning; -var warnForMissingKey = function(child) {}; +var warnForMissingKey = function(child, returnFiber) {}; { didWarnAboutMaps = false; @@ -7923,7 +7972,7 @@ var warnForMissingKey = function(child) {}; ownerHasKeyUseWarning = {}; ownerHasFunctionTypeWarning = {}; - warnForMissingKey = function(child) { + warnForMissingKey = function(child, returnFiber) { if (child === null || typeof child !== "object") { return; } @@ -7939,21 +7988,17 @@ var warnForMissingKey = function(child) {}; } child._store.validated = true; - var currentComponentErrorInfo = - "Each child in a list should have a unique " + - '"key" prop. See https://fb.me/react-warning-keys for ' + - "more information." + - getCurrentFiberStackInDev(); + var componentName = getComponentName(returnFiber.type) || "Component"; - if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { + if (ownerHasKeyUseWarning[componentName]) { return; } - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; + ownerHasKeyUseWarning[componentName] = true; error( "Each child in a list should have a unique " + - '"key" prop. See https://fb.me/react-warning-keys for ' + + '"key" prop. See https://reactjs.org/link/warning-keys for ' + "more information." ); }; @@ -7991,9 +8036,8 @@ function coerceRef(returnFiber, current, element) { "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-string-ref%s", - mixedRef, - getStackByFiberInDevAndProd(returnFiber) + "https://reactjs.org/link/strict-mode-string-ref", + mixedRef ); } @@ -8011,7 +8055,7 @@ function coerceRef(returnFiber, current, element) { if (!(ownerFiber.tag === ClassComponent)) { throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); } @@ -8065,7 +8109,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + mixedRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } } @@ -8076,41 +8120,27 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { if (returnFiber.type !== "textarea") { - var addendum = ""; - - { - addendum = - " If you meant to render a collection of children, use an array " + - "instead." + - getCurrentFiberStackInDev(); - } - { throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - ")." + - addendum + "). If you meant to render a collection of children, use an array instead." ); } } } -function warnOnFunctionType() { +function warnOnFunctionType(returnFiber) { { - var currentComponentErrorInfo = - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." + - getCurrentFiberStackInDev(); + var componentName = getComponentName(returnFiber.type) || "Component"; - if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { + if (ownerHasFunctionTypeWarning[componentName]) { return; } - ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; + ownerHasFunctionTypeWarning[componentName] = true; error( "Functions are not valid as a React child. This may happen if " + @@ -8118,7 +8148,7 @@ function warnOnFunctionType() { "Or maybe you meant to call this function rather than return it." ); } -} // This wrapper function exists because I expect to clone the code in each path +} // We avoid inlining this to avoid potential deopts from using try/catch. // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -8144,7 +8174,7 @@ function ChildReconciler(shouldTrackSideEffects) { } childToDelete.nextEffect = null; - childToDelete.effectTag = Deletion; + childToDelete.flags = Deletion; } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -8208,7 +8238,7 @@ function ChildReconciler(shouldTrackSideEffects) { if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -8216,7 +8246,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -8225,20 +8255,16 @@ function ChildReconciler(shouldTrackSideEffects) { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { - newFiber.effectTag = Placement; + newFiber.flags = Placement; } return newFiber; } - function updateTextNode(returnFiber, current, textContent, expirationTime) { + function updateTextNode(returnFiber, current, textContent, lanes) { if (current === null || current.tag !== HostText) { // Insert - var created = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromText(textContent, returnFiber.mode, lanes); created.return = returnFiber; return created; } else { @@ -8249,7 +8275,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateElement(returnFiber, current, element, expirationTime) { + function updateElement(returnFiber, current, element, lanes) { if (current !== null) { if ( current.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -8269,17 +8295,13 @@ function ChildReconciler(shouldTrackSideEffects) { } } // Insert - var created = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromElement(element, returnFiber.mode, lanes); created.ref = coerceRef(returnFiber, current, element); created.return = returnFiber; return created; } - function updatePortal(returnFiber, current, portal, expirationTime) { + function updatePortal(returnFiber, current, portal, lanes) { if ( current === null || current.tag !== HostPortal || @@ -8287,11 +8309,7 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) { // Insert - var created = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromPortal(portal, returnFiber.mode, lanes); created.return = returnFiber; return created; } else { @@ -8302,13 +8320,13 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateFragment(returnFiber, current, fragment, expirationTime, key) { + function updateFragment(returnFiber, current, fragment, lanes, key) { if (current === null || current.tag !== Fragment) { // Insert var created = createFiberFromFragment( fragment, returnFiber.mode, - expirationTime, + lanes, key ); created.return = returnFiber; @@ -8321,16 +8339,12 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function createChild(returnFiber, newChild, expirationTime) { + function createChild(returnFiber, newChild, lanes) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys. If the previous node is implicitly keyed // we can continue to replace it without aborting even if it is not a text // node. - var created = createFiberFromText( - "" + newChild, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromText("" + newChild, returnFiber.mode, lanes); created.return = returnFiber; return created; } @@ -8341,7 +8355,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created = createFiberFromElement( newChild, returnFiber.mode, - expirationTime + lanes ); _created.ref = coerceRef(returnFiber, null, newChild); @@ -8353,7 +8367,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created2 = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes ); _created2.return = returnFiber; @@ -8365,7 +8379,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created3 = createFiberFromFragment( newChild, returnFiber.mode, - expirationTime, + lanes, null ); @@ -8378,14 +8392,14 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } return null; } - function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { + function updateSlot(returnFiber, oldFiber, newChild, lanes) { // Update the fiber if the keys match, otherwise return null. var key = oldFiber !== null ? oldFiber.key : null; @@ -8397,12 +8411,7 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateTextNode( - returnFiber, - oldFiber, - "" + newChild, - expirationTime - ); + return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); } if (typeof newChild === "object" && newChild !== null) { @@ -8414,17 +8423,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - expirationTime, + lanes, key ); } - return updateElement( - returnFiber, - oldFiber, - newChild, - expirationTime - ); + return updateElement(returnFiber, oldFiber, newChild, lanes); } else { return null; } @@ -8432,12 +8436,7 @@ function ChildReconciler(shouldTrackSideEffects) { case REACT_PORTAL_TYPE: { if (newChild.key === key) { - return updatePortal( - returnFiber, - oldFiber, - newChild, - expirationTime - ); + return updatePortal(returnFiber, oldFiber, newChild, lanes); } else { return null; } @@ -8449,13 +8448,7 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateFragment( - returnFiber, - oldFiber, - newChild, - expirationTime, - null - ); + return updateFragment(returnFiber, oldFiber, newChild, lanes, null); } throwOnInvalidObjectType(returnFiber, newChild); @@ -8463,7 +8456,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } @@ -8475,18 +8468,13 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - expirationTime + lanes ) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys, so we neither have to check the old nor // new node for the key. If both are text nodes, they match. var matchedFiber = existingChildren.get(newIdx) || null; - return updateTextNode( - returnFiber, - matchedFiber, - "" + newChild, - expirationTime - ); + return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes); } if (typeof newChild === "object" && newChild !== null) { @@ -8502,17 +8490,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber, newChild.props.children, - expirationTime, + lanes, newChild.key ); } - return updateElement( - returnFiber, - _matchedFiber, - newChild, - expirationTime - ); + return updateElement(returnFiber, _matchedFiber, newChild, lanes); } case REACT_PORTAL_TYPE: { @@ -8521,12 +8504,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChild.key === null ? newIdx : newChild.key ) || null; - return updatePortal( - returnFiber, - _matchedFiber2, - newChild, - expirationTime - ); + return updatePortal(returnFiber, _matchedFiber2, newChild, lanes); } } @@ -8537,7 +8515,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber3, newChild, - expirationTime, + lanes, null ); } @@ -8547,7 +8525,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } @@ -8557,7 +8535,7 @@ function ChildReconciler(shouldTrackSideEffects) { * Warns if there is a duplicate or missing key */ - function warnOnInvalidKey(child, knownKeys) { + function warnOnInvalidKey(child, knownKeys, returnFiber) { { if (typeof child !== "object" || child === null) { return knownKeys; @@ -8566,7 +8544,7 @@ function ChildReconciler(shouldTrackSideEffects) { switch (child.$$typeof) { case REACT_ELEMENT_TYPE: case REACT_PORTAL_TYPE: - warnForMissingKey(child); + warnForMissingKey(child, returnFiber); var key = child.key; if (typeof key !== "string") { @@ -8604,7 +8582,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - expirationTime + lanes ) { // This algorithm can't optimize by searching from both ends since we // don't have backpointers on fibers. I'm trying to see how far we can get @@ -8627,7 +8605,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (var i = 0; i < newChildren.length; i++) { var child = newChildren[i]; - knownKeys = warnOnInvalidKey(child, knownKeys); + knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); } } @@ -8650,7 +8628,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - expirationTime + lanes ); if (newFiber === null) { @@ -8700,11 +8678,7 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; newIdx < newChildren.length; newIdx++) { - var _newFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - ); + var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes); if (_newFiber === null) { continue; @@ -8733,7 +8707,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - expirationTime + lanes ); if (_newFiber2 !== null) { @@ -8776,7 +8750,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - expirationTime + lanes ) { // This is the same implementation as reconcileChildrenArray(), // but using the iterator instead. @@ -8811,9 +8785,8 @@ function ChildReconciler(shouldTrackSideEffects) { if (newChildrenIterable.entries === iteratorFn) { if (!didWarnAboutMaps) { error( - "Using Maps as children is unsupported and will likely yield " + - "unexpected results. Convert it to a sequence/iterable of keyed " + - "ReactElements instead." + "Using Maps as children is not supported. " + + "Use an array of keyed ReactElements instead." ); } @@ -8830,7 +8803,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (; !_step.done; _step = _newChildren.next()) { var child = _step.value; - knownKeys = warnOnInvalidKey(child, knownKeys); + knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); } } } @@ -8861,12 +8834,7 @@ function ChildReconciler(shouldTrackSideEffects) { nextOldFiber = oldFiber.sibling; } - var newFiber = updateSlot( - returnFiber, - oldFiber, - step.value, - expirationTime - ); + var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); if (newFiber === null) { // TODO: This breaks on empty slots like null children. That's @@ -8915,7 +8883,7 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; !step.done; newIdx++, step = newChildren.next()) { - var _newFiber3 = createChild(returnFiber, step.value, expirationTime); + var _newFiber3 = createChild(returnFiber, step.value, lanes); if (_newFiber3 === null) { continue; @@ -8944,7 +8912,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, step.value, - expirationTime + lanes ); if (_newFiber4 !== null) { @@ -8987,7 +8955,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, textContent, - expirationTime + lanes ) { // There's no need to check for keys on text nodes since we don't have a // way to define them. @@ -9002,11 +8970,7 @@ function ChildReconciler(shouldTrackSideEffects) { // and delete the existing ones. deleteRemainingChildren(returnFiber, currentFirstChild); - var created = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromText(textContent, returnFiber.mode, lanes); created.return = returnFiber; return created; } @@ -9015,7 +8979,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, element, - expirationTime + lanes ) { var key = element.key; var child = currentFirstChild; @@ -9084,17 +9048,13 @@ function ChildReconciler(shouldTrackSideEffects) { var created = createFiberFromFragment( element.props.children, returnFiber.mode, - expirationTime, + lanes, element.key ); created.return = returnFiber; return created; } else { - var _created4 = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); + var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); _created4.ref = coerceRef(returnFiber, currentFirstChild, element); _created4.return = returnFiber; @@ -9106,7 +9066,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, portal, - expirationTime + lanes ) { var key = portal.key; var child = currentFirstChild; @@ -9135,11 +9095,7 @@ function ChildReconciler(shouldTrackSideEffects) { child = child.sibling; } - var created = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromPortal(portal, returnFiber.mode, lanes); created.return = returnFiber; return created; } // This API will tag the children with the side-effect of the reconciliation @@ -9150,7 +9106,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ) { // This function is not recursive. // If the top level item is an array, we treat it as a set of children, @@ -9179,7 +9135,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ) ); @@ -9189,7 +9145,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ) ); } @@ -9201,7 +9157,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, "" + newChild, - expirationTime + lanes ) ); } @@ -9211,7 +9167,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); } @@ -9220,7 +9176,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); } @@ -9230,7 +9186,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } @@ -9253,12 +9209,13 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case FunctionComponent: { - var Component = returnFiber.type; - + case Block: + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { { throw Error( - (Component.displayName || Component.name || "Component") + + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); } @@ -9300,11 +9257,11 @@ function cloneChildFibers(current, workInProgress) { newChild.sibling = null; } // Reset a workInProgress child set to prepare it for a second pass. -function resetChildFibers(workInProgress, renderExpirationTime) { +function resetChildFibers(workInProgress, lanes) { var child = workInProgress.child; while (child !== null) { - resetWorkInProgress(child, renderExpirationTime); + resetWorkInProgress(child, lanes); child = child.sibling; } } @@ -9476,7 +9433,7 @@ function findFirstSuspended(row) { // keep track of whether it suspended or not. node.memoizedProps.revealOrder !== undefined ) { - var didSuspend = (node.effectTag & DidCapture) !== NoEffect; + var didSuspend = (node.flags & DidCapture) !== NoFlags; if (didSuspend) { return node; @@ -9506,18 +9463,9 @@ function findFirstSuspended(row) { return null; } -function createDeprecatedResponderListener(responder, props) { - var eventResponderListener = { - responder: responder, - props: props - }; - - { - Object.freeze(eventResponderListener); - } - - return eventResponderListener; -} +var NoFlags$1 = + /* */ + 0; // Represents whether effect should fire. var HasEffect = /* */ @@ -9530,16 +9478,113 @@ var Passive$1 = /* */ 4; -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var isHydrating = false; + +function enterHydrationState(fiber) { + { + return false; + } +} + +function prepareToHydrateHostInstance( + fiber, + rootContainerInstance, + hostContext +) { + { + { + throw Error( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } +} + +function prepareToHydrateHostTextInstance(fiber) { + { + { + throw Error( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + var shouldUpdate = hydrateTextInstance(); +} + +function popHydrationState(fiber) { + { + return false; + } +} + +function getIsHydrating() { + return isHydrating; +} + +// and should be reset before starting a new render. +// This tracks which mutable sources need to be reset after a render. + +var workInProgressSources = []; +var rendererSigil$1; + +{ + // Used to detect multiple renderers using the same mutable source. + rendererSigil$1 = {}; +} + +function markSourceAsDirty(mutableSource) { + workInProgressSources.push(mutableSource); +} +function resetWorkInProgressVersions() { + for (var i = 0; i < workInProgressSources.length; i++) { + var mutableSource = workInProgressSources[i]; + + { + mutableSource._workInProgressVersionSecondary = null; + } + } + + workInProgressSources.length = 0; +} +function getWorkInProgressVersion(mutableSource) { + { + return mutableSource._workInProgressVersionSecondary; + } +} +function setWorkInProgressVersion(mutableSource, version) { + { + mutableSource._workInProgressVersionSecondary = version; + } + + workInProgressSources.push(mutableSource); +} +function warnAboutMultipleRenderersDEV(mutableSource) { + { + { + if (mutableSource._currentSecondaryRenderer == null) { + mutableSource._currentSecondaryRenderer = rendererSigil$1; + } else if (mutableSource._currentSecondaryRenderer !== rendererSigil$1) { + error( + "Detected multiple renderers concurrently rendering the " + + "same mutable source. This is currently unsupported." + ); + } + } + } +} // Eager reads the version of a mutable source and stores it on the root. + +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; +var didWarnAboutUseOpaqueIdentifier; { + didWarnAboutUseOpaqueIdentifier = {}; didWarnAboutMismatchedHooksForComponent = new Set(); } // These are set right before calling the component. -var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from +var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from // the work-in-progress hook. var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The @@ -9553,7 +9598,12 @@ var workInProgressHook = null; // Whether an update was scheduled at any point d // finished evaluating this component. This is an optimization so we know // whether we need to clear render phase updates after a throw. -var didScheduleRenderPhaseUpdate = false; +var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This +// gets reset after each attempt. +// TODO: Maybe there's some way to consolidate this with +// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. + +var didScheduleRenderPhaseUpdateDuringThisPass = false; var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. @@ -9637,7 +9687,7 @@ function warnOnHookMismatchInDev(currentHookName) { error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + - "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + + "For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n" + " Previous render Next render\n" + " ------------------------------------------------------\n" + "%s" + @@ -9653,7 +9703,7 @@ function warnOnHookMismatchInDev(currentHookName) { function throwInvalidHookError() { { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } } @@ -9712,9 +9762,9 @@ function renderWithHooks( Component, props, secondArg, - nextRenderExpirationTime + nextRenderLanes ) { - renderExpirationTime = nextRenderExpirationTime; + renderLanes = nextRenderLanes; currentlyRenderingFiber$1 = workInProgress; { @@ -9727,7 +9777,7 @@ function renderWithHooks( workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.expirationTime = NoWork; // The following should have already been reset + workInProgress.lanes = NoLanes; // The following should have already been reset // currentHook = null; // workInProgressHook = null; // didScheduleRenderPhaseUpdate = false; @@ -9740,28 +9790,28 @@ function renderWithHooks( { if (current !== null && current.memoizedState !== null) { - ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, // but no stateful hooks have been used. // We want to match the production code behavior (which will use HooksDispatcherOnMount), // but with the extra DEV validation to ensure hooks ordering hasn't changed. // This dispatcher does that. - ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; } else { - ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } var children = Component(props, secondArg); // Check if there was a render phase update - if (workInProgress.expirationTime === renderExpirationTime) { + if (didScheduleRenderPhaseUpdateDuringThisPass) { // Keep rendering in a loop for as long as render phase updates continue to // be scheduled. Use a counter to prevent infinite loops. var numberOfReRenders = 0; do { - workInProgress.expirationTime = NoWork; + didScheduleRenderPhaseUpdateDuringThisPass = false; if (!(numberOfReRenders < RE_RENDER_LIMIT)) { throw Error( @@ -9786,13 +9836,13 @@ function renderWithHooks( hookTypesUpdateIndexDev = -1; } - ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV; children = Component(props, secondArg); - } while (workInProgress.expirationTime === renderExpirationTime); + } while (didScheduleRenderPhaseUpdateDuringThisPass); } // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; { workInProgress._debugHookTypes = hookTypesDev; @@ -9800,7 +9850,7 @@ function renderWithHooks( // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; - renderExpirationTime = NoWork; + renderLanes = NoLanes; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -9821,18 +9871,15 @@ function renderWithHooks( return children; } -function bailoutHooks(current, workInProgress, expirationTime) { +function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; - workInProgress.effectTag &= ~(Passive | Update); - - if (current.expirationTime <= expirationTime) { - current.expirationTime = NoWork; - } + workInProgress.flags &= ~(Passive | Update); + current.lanes = removeLanes(current.lanes, lanes); } function resetHooksAfterThrow() { // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; if (didScheduleRenderPhaseUpdate) { // There were render phase updates. These are only valid for this render @@ -9854,9 +9901,11 @@ function resetHooksAfterThrow() { hook = hook.next; } + + didScheduleRenderPhaseUpdate = false; } - renderExpirationTime = NoWork; + renderLanes = NoLanes; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -9865,9 +9914,10 @@ function resetHooksAfterThrow() { hookTypesDev = null; hookTypesUpdateIndexDev = -1; currentHookNameInDev = null; + isUpdatingOpaqueValueInRenderPhase = false; } - didScheduleRenderPhaseUpdate = false; + didScheduleRenderPhaseUpdateDuringThisPass = false; } function mountWorkInProgressHook() { @@ -10014,6 +10064,17 @@ function updateReducer(reducer, initialArg, init) { pendingQueue.next = baseFirst; } + { + if (current.baseQueue !== baseQueue) { + // Internal invariant that should never happen, but feasibly could in + // the future if we implement resuming, or some form of that. + error( + "Internal error: Expected work-in-progress queue to be a clone. " + + "This is a bug in React." + ); + } + } + current.baseQueue = baseQueue = pendingQueue; queue.pending = null; } @@ -10028,15 +10089,14 @@ function updateReducer(reducer, initialArg, init) { var update = first; do { - var updateExpirationTime = update.expirationTime; + var updateLane = update.lane; - if (updateExpirationTime < renderExpirationTime) { + if (!isSubsetOfLanes(renderLanes, updateLane)) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, + lane: updateLane, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, @@ -10049,35 +10109,29 @@ function updateReducer(reducer, initialArg, init) { } else { newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. + // TODO: Don't need to accumulate this. Instead, we can remove + // renderLanes from the original lanes. - if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { - currentlyRenderingFiber$1.expirationTime = updateExpirationTime; - markUnprocessedUpdateTime(updateExpirationTime); - } + currentlyRenderingFiber$1.lanes = mergeLanes( + currentlyRenderingFiber$1.lanes, + updateLane + ); + markSkippedUpdateLanes(updateLane); } else { // This update does have sufficient priority. if (newBaseQueueLast !== null) { var _clone = { - expirationTime: Sync, - // This update is going to be committed so we never want uncommit it. - suspenseConfig: update.suspenseConfig, + // This update is going to be committed so we never want uncommit + // it. Using NoLane works because 0 is a subset of all bitmasks, so + // this will never be skipped by the check above. + lane: NoLane, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }; newBaseQueueLast = newBaseQueueLast.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ); // Process this update. + } // Process this update. if (update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -10165,6 +10219,251 @@ function rerenderReducer(reducer, initialArg, init) { return [newState, dispatch]; } +function readFromUnsubcribedMutableSource(root, source, getSnapshot) { + { + warnAboutMultipleRenderersDEV(source); + } + + var getVersion = source._getVersion; + var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render? + + var isSafeToReadFromSource = false; // Check the version first. + // If this render has already been started with a specific version, + // we can use it alone to determine if we can safely read from the source. + + var currentRenderVersion = getWorkInProgressVersion(source); + + if (currentRenderVersion !== null) { + // It's safe to read if the store hasn't been mutated since the last time + // we read something. + isSafeToReadFromSource = currentRenderVersion === version; + } else { + // If there's no version, then this is the first time we've read from the + // source during the current render pass, so we need to do a bit more work. + // What we need to determine is if there are any hooks that already + // subscribed to the source, and if so, whether there are any pending + // mutations that haven't been synchronized yet. + // + // If there are no pending mutations, then `root.mutableReadLanes` will be + // empty, and we know we can safely read. + // + // If there *are* pending mutations, we may still be able to safely read + // if the currently rendering lanes are inclusive of the pending mutation + // lanes, since that guarantees that the value we're about to read from + // the source is consistent with the values that we read during the most + // recent mutation. + isSafeToReadFromSource = isSubsetOfLanes( + renderLanes, + root.mutableReadLanes + ); + + if (isSafeToReadFromSource) { + // If it's safe to read from this source during the current render, + // store the version in case other components read from it. + // A changed version number will let those components know to throw and restart the render. + setWorkInProgressVersion(source, version); + } + } + + if (isSafeToReadFromSource) { + var snapshot = getSnapshot(source._source); + + { + if (typeof snapshot === "function") { + error( + "Mutable source should not return a function as the snapshot value. " + + "Functions may close over mutable values and cause tearing." + ); + } + } + + return snapshot; + } else { + // This handles the special case of a mutable source being shared between renderers. + // In that case, if the source is mutated between the first and second renderer, + // The second renderer don't know that it needs to reset the WIP version during unwind, + // (because the hook only marks sources as dirty if it's written to their WIP version). + // That would cause this tear check to throw again and eventually be visible to the user. + // We can avoid this infinite loop by explicitly marking the source as dirty. + // + // This can lead to tearing in the first renderer when it resumes, + // but there's nothing we can do about that (short of throwing here and refusing to continue the render). + markSourceAsDirty(source); + + { + throw Error( + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." + ); + } + } +} + +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = getWorkInProgressRoot(); + + if (!(root !== null)) { + throw Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var getVersion = source._getVersion; + var version = getVersion(source._source); + var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const + + var _dispatcher$useState = dispatcher.useState(function() { + return readFromUnsubcribedMutableSource(root, source, getSnapshot); + }), + currentSnapshot = _dispatcher$useState[0], + setSnapshot = _dispatcher$useState[1]; + + var snapshot = currentSnapshot; // Grab a handle to the state hook as well. + // We use it to clear the pending update queue if we have a new source. + + var stateHook = workInProgressHook; + var memoizedState = hook.memoizedState; + var refs = memoizedState.refs; + var prevGetSnapshot = refs.getSnapshot; + var prevSource = memoizedState.source; + var prevSubscribe = memoizedState.subscribe; + var fiber = currentlyRenderingFiber$1; + hook.memoizedState = { + refs: refs, + source: source, + subscribe: subscribe + }; // Sync the values needed by our subscription handler after each commit. + + dispatcher.useEffect( + function() { + refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes, + // but this hook recreates the queue in certain cases to avoid updates from stale sources. + // handleChange() below needs to reference the dispatch function without re-subscribing, + // so we use a ref to ensure that it always has the latest version. + + refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now. + + var maybeNewVersion = getVersion(source._source); + + if (!objectIs(version, maybeNewVersion)) { + var maybeNewSnapshot = getSnapshot(source._source); + + { + if (typeof maybeNewSnapshot === "function") { + error( + "Mutable source should not return a function as the snapshot value. " + + "Functions may close over mutable values and cause tearing." + ); + } + } + + if (!objectIs(snapshot, maybeNewSnapshot)) { + setSnapshot(maybeNewSnapshot); + var lane = requestUpdateLane(fiber); + markRootMutableRead(root, lane); + } // If the source mutated between render and now, + // there may be state updates already scheduled from the old source. + // Entangle the updates so that they render in the same batch. + + markRootEntangled(root, root.mutableReadLanes); + } + }, + [getSnapshot, source, subscribe] + ); // If we got a new source or subscribe function, re-subscribe in a passive effect. + + dispatcher.useEffect( + function() { + var handleChange = function() { + var latestGetSnapshot = refs.getSnapshot; + var latestSetSnapshot = refs.setSnapshot; + + try { + latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. + + var lane = requestUpdateLane(fiber); + markRootMutableRead(root, lane); + } catch (error) { + // A selector might throw after a source mutation. + // e.g. it might try to read from a part of the store that no longer exists. + // In this case we should still schedule an update with React. + // Worst case the selector will throw again and then an error boundary will handle it. + latestSetSnapshot(function() { + throw error; + }); + } + }; + + var unsubscribe = subscribe(source._source, handleChange); + + { + if (typeof unsubscribe !== "function") { + error( + "Mutable source subscribe function must return an unsubscribe function." + ); + } + } + + return unsubscribe; + }, + [source, subscribe] + ); // If any of the inputs to useMutableSource change, reading is potentially unsafe. + // + // If either the source or the subscription have changed we can't can't trust the update queue. + // Maybe the source changed in a way that the old subscription ignored but the new one depends on. + // + // If the getSnapshot function changed, we also shouldn't rely on the update queue. + // It's possible that the underlying source was mutated between the when the last "change" event fired, + // and when the current render (with the new getSnapshot function) is processed. + // + // In both cases, we need to throw away pending updates (since they are no longer relevant) + // and treat reading from the source as we do in the mount case. + + if ( + !objectIs(prevGetSnapshot, getSnapshot) || + !objectIs(prevSource, source) || + !objectIs(prevSubscribe, subscribe) + ) { + // Create a new queue and setState method, + // So if there are interleaved updates, they get pushed to the older queue. + // When this becomes current, the previous queue and dispatch method will be discarded, + // including any interleaving updates that occur. + var newQueue = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }; + newQueue.dispatch = setSnapshot = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + newQueue + ); + stateHook.queue = newQueue; + stateHook.baseQueue = null; + snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot); + stateHook.memoizedState = stateHook.baseState = snapshot; + } + + return snapshot; +} + +function mountMutableSource(source, getSnapshot, subscribe) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = { + refs: { + getSnapshot: getSnapshot, + setSnapshot: null + }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); +} + +function updateMutableSource(source, getSnapshot, subscribe) { + var hook = updateWorkInProgressHook(); + return useMutableSource(hook, source, getSnapshot, subscribe); +} + function mountState(initialState) { var hook = mountWorkInProgressHook(); @@ -10229,16 +10528,14 @@ function pushEffect(tag, create, destroy, deps) { function mountRef(initialValue) { var hook = mountWorkInProgressHook(); - var ref = { - current: initialValue - }; { - Object.seal(ref); + var _ref2 = { + current: initialValue + }; + hook.memoizedState = _ref2; + return _ref2; } - - hook.memoizedState = ref; - return ref; } function updateRef(initialValue) { @@ -10246,19 +10543,19 @@ function updateRef(initialValue) { return hook.memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, undefined, nextDeps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var destroy = undefined; @@ -10271,15 +10568,15 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - pushEffect(hookEffectTag, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, destroy, nextDeps @@ -10439,129 +10736,175 @@ function updateMemo(nextCreate, deps) { return nextValue; } -function mountDeferredValue(value, config) { +function mountDeferredValue(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function updateDeferredValue(value, config) { +function updateDeferredValue(value) { var _updateState = updateState(), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function rerenderDeferredValue(value, config) { +function rerenderDeferredValue(value) { var _rerenderState = rerenderState(), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); - runWithPriority( - priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, - function() { - setPending(true); - } - ); - runWithPriority( - priorityLevel > NormalPriority ? NormalPriority : priorityLevel, - function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + { + runWithPriority( + priorityLevel < UserBlockingPriority$1 + ? UserBlockingPriority$1 + : priorityLevel, + function() { + setPending(true); + } + ); + runWithPriority( + priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, + function() { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } } - } - ); + ); + } } -function mountTransition(config) { +function mountTransition() { var _mountState2 = mountState(false), isPending = _mountState2[0], - setPending = _mountState2[1]; + setPending = _mountState2[1]; // The `start` method never changes. - var start = mountCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var start = startTransition.bind(null, setPending); + var hook = mountWorkInProgressHook(); + hook.memoizedState = start; return [start, isPending]; } -function updateTransition(config) { +function updateTransition() { var _updateState2 = updateState(), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } -function rerenderTransition(config) { +function rerenderTransition() { var _rerenderState2 = rerenderState(), - isPending = _rerenderState2[0], - setPending = _rerenderState2[1]; + isPending = _rerenderState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } +var isUpdatingOpaqueValueInRenderPhase = false; +function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { + { + return isUpdatingOpaqueValueInRenderPhase; + } +} + +function warnOnOpaqueIdentifierAccessInDEV(fiber) { + { + // TODO: Should warn in effects and callbacks, too + var name = getComponentName(fiber.type) || "Unknown"; + + if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) { + error( + "The object passed back from useOpaqueIdentifier is meant to be " + + "passed through to attributes only. Do not read the " + + "value directly." + ); + + didWarnAboutUseOpaqueIdentifier[name] = true; + } + } +} + +function mountOpaqueIdentifier() { + var makeId = makeClientIdInDEV.bind( + null, + warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1) + ); + + { + var _id = makeId(); + + mountState(_id); + return _id; + } +} + +function updateOpaqueIdentifier() { + var id = updateState()[0]; + return id; +} + +function rerenderOpaqueIdentifier() { + var id = rerenderState()[0]; + return id; +} + function dispatchAction(fiber, queue, action) { { if (typeof arguments[3] === "function") { @@ -10573,25 +10916,15 @@ function dispatchAction(fiber, queue, action) { } } - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); var update = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, + lane: lane, action: action, eagerReducer: null, eagerState: null, next: null - }; - - { - update.priority = getCurrentPriorityLevel(); - } // Append the update to the end of the list. + }; // Append the update to the end of the list. var pending = queue.pending; @@ -10613,13 +10946,11 @@ function dispatchAction(fiber, queue, action) { // This is a render phase update. Stash it in a lazily-created map of // queue -> linked list of updates. After this render pass, we'll restart // and apply the stashed updates on top of the work-in-progress hook. - didScheduleRenderPhaseUpdate = true; - update.expirationTime = renderExpirationTime; - currentlyRenderingFiber$1.expirationTime = renderExpirationTime; + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; } else { if ( - fiber.expirationTime === NoWork && - (alternate === null || alternate.expirationTime === NoWork) + fiber.lanes === NoLanes && + (alternate === null || alternate.lanes === NoLanes) ) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the @@ -10630,8 +10961,8 @@ function dispatchAction(fiber, queue, action) { var prevDispatcher; { - prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { @@ -10655,24 +10986,16 @@ function dispatchAction(fiber, queue, action) { // Suppress the error. It will throw again in the render phase. } finally { { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } } } } - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } -function mountEventListener(event) { - return undefined; -} - -function updateEventListener(event) { - return undefined; -} - var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -10685,10 +11008,11 @@ var ContextOnlyDispatcher = { useRef: throwInvalidHookError, useState: throwInvalidHookError, useDebugValue: throwInvalidHookError, - useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useEvent: throwInvalidHookError + useMutableSource: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, + unstable_isNewReconciler: enableNewReconciler }; var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; @@ -10713,7 +11037,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; "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" + "https://reactjs.org/link/rules-of-hooks" ); }; @@ -10754,25 +11078,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; mountHookTypesDev(); checkDepsAreArrayDev(deps); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -10783,13 +11107,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -10797,26 +11121,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - mountHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; mountHookTypesDev(); - return mountEventListener(); - } + return mountMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + mountHookTypesDev(); + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function(context, observedBits) { @@ -10850,25 +11175,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -10879,13 +11204,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -10893,26 +11218,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return mountEventListener(); - } + return mountMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + updateHookTypesDev(); + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; HooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -10946,25 +11272,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -10975,13 +11301,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -10989,26 +11315,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateEventListener(); - } + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + updateHookTypesDev(); + return updateOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; HooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -11042,25 +11369,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11071,13 +11398,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11085,26 +11412,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateEventListener(); - } + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + updateHookTypesDev(); + return rerenderOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function(context, observedBits) { @@ -11145,26 +11473,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11177,13 +11505,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11192,30 +11520,31 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; + useDeferredValue: function(value) { + currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); mountHookTypesDev(); - return createDeprecatedResponderListener(responder, props); + return mountDeferredValue(value); }, - useDeferredValue: function(value, config) { - currentHookNameInDev = "useDeferredValue"; + useTransition: function() { + currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountTransition(); }, - useTransition: function(config) { - currentHookNameInDev = "useTransition"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountTransition(config); + return mountMutableSource(source, getSnapshot, subscribe); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountEventListener(); - } + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -11256,26 +11585,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11288,13 +11617,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11303,30 +11632,31 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; + useDeferredValue: function(value) { + currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); + return updateDeferredValue(value); }, - useDeferredValue: function(value, config) { - currentHookNameInDev = "useDeferredValue"; + useTransition: function() { + currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateTransition(); }, - useTransition: function(config) { - currentHookNameInDev = "useTransition"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateTransition(config); + return updateMutableSource(source, getSnapshot, subscribe); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateEventListener(); - } + return updateOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -11367,26 +11697,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11399,13 +11729,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11414,30 +11744,31 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; + useDeferredValue: function(value) { + currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); + return rerenderDeferredValue(value); }, - useDeferredValue: function(value, config) { - currentHookNameInDev = "useDeferredValue"; + useTransition: function() { + currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderTransition(); }, - useTransition: function(config) { - currentHookNameInDev = "useTransition"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderTransition(config); + return updateMutableSource(source, getSnapshot, subscribe); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateEventListener(); - } + return rerenderOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; } @@ -11478,40 +11809,15 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } } -function enterHydrationState(fiber) { - { - return false; - } -} - -function prepareToHydrateHostInstance( - fiber, - rootContainerInstance, - hostContext -) { - { - { - throw Error( - "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } -} - -function prepareToHydrateHostTextInstance(fiber) { - { - { - throw Error( - "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - var shouldUpdate = hydrateTextInstance(); -} +function transferActualDuration(fiber) { + // Transfer time spent rendering these children so we don't lose it + // after we rerender. This is used as a helper in special cases + // where we should count the work of multiple passes. + var child = fiber.child; -function popHydrationState(fiber) { - { - return false; + while (child) { + fiber.actualDuration += child.actualDuration; + child = child.sibling; } } @@ -11537,12 +11843,7 @@ var didWarnAboutTailOptions; didWarnAboutTailOptions = {}; } -function reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime -) { +function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { if (current === null) { // If this is a fresh new component that hasn't been rendered yet, we // won't update its child set by applying minimal side-effects. Instead, @@ -11552,7 +11853,7 @@ function reconcileChildren( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); } else { // If the current child is the same as the work in progress, it means that @@ -11564,7 +11865,7 @@ function reconcileChildren( workInProgress, current.child, nextChildren, - renderExpirationTime + renderLanes ); } } @@ -11573,7 +11874,7 @@ function forceUnmountCurrentAndReconcile( current, workInProgress, nextChildren, - renderExpirationTime + renderLanes ) { // This function is fork of reconcileChildren. It's used in cases where we // want to reconcile without matching against the existing set. This has the @@ -11587,7 +11888,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, current.child, null, - renderExpirationTime + renderLanes ); // In the second pass, we mount the new children. The trick here is that we // pass null in place of where we usually pass the current child set. This has // the effect of remounting all children regardless of whether their @@ -11597,7 +11898,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); } @@ -11606,7 +11907,7 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens after the first render suspends. @@ -11632,7 +11933,7 @@ function updateForwardRef( var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent var nextChildren; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); { ReactCurrentOwner$1.current = workInProgress; @@ -11643,28 +11944,19 @@ function updateForwardRef( render, nextProps, ref, - renderExpirationTime + renderLanes ); setIsRendering(false); } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderExpirationTime); - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + bailoutHooks(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -11673,8 +11965,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (current === null) { var type = Component.type; @@ -11704,8 +11996,8 @@ function updateMemoComponent( workInProgress, resolvedType, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -11728,9 +12020,9 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, - renderExpirationTime + renderLanes ); child.ref = workInProgress.ref; child.return = workInProgress; @@ -11756,7 +12048,7 @@ function updateMemoComponent( var currentChild = current.child; // This is always exactly one child - if (updateExpirationTime < renderExpirationTime) { + if (!includesSomeLane(updateLanes, renderLanes)) { // This will be the props with resolved defaultProps, // unlike current.memoizedProps which will be the unresolved ones. var prevProps = currentChild.memoizedProps; // Default to shallow comparison @@ -11765,15 +12057,11 @@ function updateMemoComponent( compare = compare !== null ? compare : shallowEqual; if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; var newChild = createWorkInProgress(currentChild, nextProps); newChild.ref = workInProgress.ref; newChild.return = workInProgress; @@ -11786,8 +12074,8 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens when the inner render suspends. @@ -11802,19 +12090,27 @@ function updateSimpleMemoComponent( // We warn when you define propTypes on lazy() // so let's just skip over it to find memo() outer wrapper. // Inner props for memo are validated later. - outerMemoType = refineResolvedLazyComponent(outerMemoType); - } + var lazyComponent = outerMemoType; + var payload = lazyComponent._payload; + var init = lazyComponent._init; - var outerPropTypes = outerMemoType && outerMemoType.propTypes; - - if (outerPropTypes) { - checkPropTypes( - outerPropTypes, - nextProps, // Resolved (SimpleMemoComponent has no defaultProps) - "prop", - getComponentName(outerMemoType) - ); - } // Inner propTypes will be validated in the function component path. + try { + outerMemoType = init(payload); + } catch (x) { + outerMemoType = null; + } // Inner propTypes will be validated in the function component path. + + var outerPropTypes = outerMemoType && outerMemoType.propTypes; + + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + nextProps, // Resolved (SimpleMemoComponent has no defaultProps) + "prop", + getComponentName(outerMemoType) + ); + } + } } } @@ -11828,10 +12124,10 @@ function updateSimpleMemoComponent( ) { didReceiveUpdate = false; - if (updateExpirationTime < renderExpirationTime) { - // The pending update priority was cleared at the beginning of - // beginWork. We're about to bail out, but there might be additional - // updates at a lower priority. Usually, the priority level of the + if (!includesSomeLane(renderLanes, updateLanes)) { + // The pending lanes were cleared at the beginning of beginWork. We're + // about to bail out, but there might be other lanes that weren't + // included in the current render. Usually, the priority level of the // remaining updates is accumlated during the evaluation of the // component (i.e. when processing the update queue). But since since // we're bailing out early *without* evaluating the component, we need @@ -11842,12 +12138,16 @@ function updateSimpleMemoComponent( // contains hooks. // TODO: Move the reset at in beginWork out of the common path so that // this is no longer necessary. - workInProgress.expirationTime = current.expirationTime; + workInProgress.lanes = current.lanes; return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); + } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { + // This is a special case that only exists for legacy mode. + // See https://github.com/facebook/react/pull/19216. + didReceiveUpdate = true; } } } @@ -11857,35 +12157,103 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ); } -function updateFragment(current, workInProgress, renderExpirationTime) { +function updateOffscreenComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + var prevState = current !== null ? current.memoizedState : null; + + if ( + nextProps.mode === "hidden" || + nextProps.mode === "unstable-defer-without-hiding" + ) { + if ((workInProgress.mode & ConcurrentMode) === NoMode) { + // In legacy sync mode, don't defer the subtree. Render it now. + // TODO: Figure out what we should do in Blocking mode. + var nextState = { + baseLanes: NoLanes + }; + workInProgress.memoizedState = nextState; + pushRenderLanes(workInProgress, renderLanes); + } else if (!includesSomeLane(renderLanes, OffscreenLane)) { + var nextBaseLanes; + + if (prevState !== null) { + var prevBaseLanes = prevState.baseLanes; + nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes); + } else { + nextBaseLanes = renderLanes; + } // Schedule this fiber to re-render at offscreen priority. Then bailout. + + { + markSpawnedWork(OffscreenLane); + } + + workInProgress.lanes = workInProgress.childLanes = laneToLanes( + OffscreenLane + ); + var _nextState = { + baseLanes: nextBaseLanes + }; + workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway + // to avoid a push/pop misalignment. + + pushRenderLanes(workInProgress, nextBaseLanes); + return null; + } else { + // Rendering at offscreen, so we can clear the base lanes. + var _nextState2 = { + baseLanes: NoLanes + }; + workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. + + var subtreeRenderLanes = + prevState !== null ? prevState.baseLanes : renderLanes; + pushRenderLanes(workInProgress, subtreeRenderLanes); + } + } else { + var _subtreeRenderLanes; + + if (prevState !== null) { + _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state + + workInProgress.memoizedState = null; + } else { + // We weren't previously hidden, and we still aren't, so there's nothing + // special to do. Need to push to the stack regardless, though, to avoid + // a push/pop misalignment. + _subtreeRenderLanes = renderLanes; + } + + pushRenderLanes(workInProgress, _subtreeRenderLanes); + } + + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; +} // Note: These happen to have identical begin phases, for now. We shouldn't hold +// ourselves to this constraint, though. If the behavior diverges, we should +// fork the function. + +var updateLegacyHiddenComponent = updateOffscreenComponent; + +function updateFragment(current, workInProgress, renderLanes) { var nextChildren = workInProgress.pendingProps; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } -function updateMode(current, workInProgress, renderExpirationTime) { +function updateMode(current, workInProgress, renderLanes) { var nextChildren = workInProgress.pendingProps.children; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } -function updateProfiler(current, workInProgress, renderExpirationTime) { +function updateProfiler(current, workInProgress, renderLanes) { { - workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase. + workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, var stateNode = workInProgress.stateNode; @@ -11895,12 +12263,7 @@ function updateProfiler(current, workInProgress, renderExpirationTime) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -11912,7 +12275,7 @@ function markRef(current, workInProgress) { (current !== null && current.ref !== ref) ) { // Schedule a Ref effect - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } } @@ -11921,7 +12284,7 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -11948,7 +12311,7 @@ function updateFunctionComponent( } var nextChildren; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); { ReactCurrentOwner$1.current = workInProgress; @@ -11959,28 +12322,19 @@ function updateFunctionComponent( Component, nextProps, context, - renderExpirationTime + renderLanes ); setIsRendering(false); } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderExpirationTime); - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + bailoutHooks(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -11989,7 +12343,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -12019,7 +12373,7 @@ function updateClassComponent( hasContext = false; } - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); var instance = workInProgress.stateNode; var shouldUpdate; @@ -12032,16 +12386,11 @@ function updateClassComponent( current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); + mountClassInstance(workInProgress, Component, nextProps, renderLanes); shouldUpdate = true; } else if (current === null) { // In a resume, we'll already have an instance we can reuse. @@ -12049,7 +12398,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ); } else { shouldUpdate = updateClassInstance( @@ -12057,7 +12406,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ); } @@ -12067,13 +12416,13 @@ function updateClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ); { var inst = workInProgress.stateNode; - if (inst.props !== nextProps) { + if (shouldUpdate && inst.props !== nextProps) { if (!didWarnAboutReassigningProps) { error( "It looks like %s is reassigning its own `this.props` while rendering. " + @@ -12095,11 +12444,11 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ) { // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); - var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; + var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags; if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering @@ -12107,11 +12456,7 @@ function finishClassComponent( invalidateContextProvider(workInProgress, Component, false); } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } var instance = workInProgress.stateNode; // Rerender @@ -12142,7 +12487,7 @@ function finishClassComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (current !== null && didCaptureError) { // If we're recovering from an error, reconcile without reusing any of @@ -12153,15 +12498,10 @@ function finishClassComponent( current, workInProgress, nextChildren, - renderExpirationTime + renderLanes ); } else { - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); } // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. @@ -12191,7 +12531,7 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } -function updateHostRoot(current, workInProgress, renderExpirationTime) { +function updateHostRoot(current, workInProgress, renderLanes) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; @@ -12205,32 +12545,24 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) { var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); + processUpdateQueue(workInProgress, nextProps, null, renderLanes); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". var nextChildren = nextState.element; if (nextChildren === prevChildren) { - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } var root = workInProgress.stateNode; if (root.hydrate && enterHydrationState()) { - // If we don't have any current children this might be the first pass. - // We always try to hydrate. If this isn't a hydration pass there won't - // be any children to hydrate which is effectively the same thing as - // not hydrating. var child = mountChildFibers( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); workInProgress.child = child; var node = child; @@ -12242,24 +12574,19 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) { // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - node.effectTag = (node.effectTag & ~Placement) | Hydrating; + node.flags = (node.flags & ~Placement) | Hydrating; node = node.sibling; } } else { // Otherwise reset hydration state in case we aborted and resumed another // root. - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); } return workInProgress.child; } -function updateHostComponent(current, workInProgress, renderExpirationTime) { +function updateHostComponent(current, workInProgress, renderLanes) { pushHostContext(workInProgress); var type = workInProgress.type; @@ -12270,30 +12597,11 @@ function updateHostComponent(current, workInProgress, renderExpirationTime) { if (prevProps !== null && shouldSetTextContent()) { // If we're switching from a direct text child to a normal child, or to // empty, we need to schedule the text content to be reset. - workInProgress.effectTag |= ContentReset; - } - - markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden. - - if ( - workInProgress.mode & ConcurrentMode && - renderExpirationTime !== Never && - shouldDeprioritizeSubtree() - ) { - { - markSpawnedWork(Never); - } // Schedule this fiber to re-render at offscreen priority. Then bailout. - - workInProgress.expirationTime = workInProgress.childExpirationTime = Never; - return null; + workInProgress.flags |= ContentReset; } - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + markRef(current, workInProgress); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12307,8 +12615,8 @@ function mountLazyComponent( _current, workInProgress, elementType, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (_current !== null) { // A lazy component only mounts if it suspended inside a non- @@ -12318,18 +12626,17 @@ function mountLazyComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } - var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet. - // Cancel and resume right after we know the tag. - - cancelWorkTimer(workInProgress); - var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type. + var props = workInProgress.pendingProps; + var lazyComponent = elementType; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + var Component = init(payload); // Store the unwrapped component in the type. workInProgress.type = Component; var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component)); - startWorkTimer(workInProgress); var resolvedProps = resolveDefaultProps(Component, props); var child; @@ -12347,7 +12654,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderExpirationTime + renderLanes ); return child; } @@ -12364,7 +12671,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderExpirationTime + renderLanes ); return child; } @@ -12381,7 +12688,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderExpirationTime + renderLanes ); return child; } @@ -12407,8 +12714,8 @@ function mountLazyComponent( workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); return child; } @@ -12443,7 +12750,7 @@ function mountIncompleteClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { if (_current !== null) { // An incomplete component only mounts if it suspended inside a non- @@ -12453,7 +12760,7 @@ function mountIncompleteClassComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // Promote the fiber to a class and try rendering again. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` @@ -12470,21 +12777,16 @@ function mountIncompleteClassComponent( hasContext = false; } - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); + mountClassInstance(workInProgress, Component, nextProps, renderLanes); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderExpirationTime + renderLanes ); } @@ -12492,7 +12794,7 @@ function mountIndeterminateComponent( _current, workInProgress, Component, - renderExpirationTime + renderLanes ) { if (_current !== null) { // An indeterminate component only mounts if it suspended inside a non- @@ -12502,7 +12804,7 @@ function mountIndeterminateComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } var props = workInProgress.pendingProps; @@ -12513,7 +12815,7 @@ function mountIndeterminateComponent( context = getMaskedContext(workInProgress, unmaskedContext); } - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); var value; { @@ -12539,6 +12841,7 @@ function mountIndeterminateComponent( ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); } + setIsRendering(true); ReactCurrentOwner$1.current = workInProgress; value = renderWithHooks( null, @@ -12546,34 +12849,65 @@ function mountIndeterminateComponent( Component, props, context, - renderExpirationTime + renderLanes ); + setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; + + { + // Support for module components is deprecated and is removed behind a flag. + // Whether or not it would crash later, we want to show a good message in DEV first. + if ( + typeof value === "object" && + value !== null && + typeof value.render === "function" && + value.$$typeof === undefined + ) { + var _componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutModulePatternComponent[_componentName]) { + error( + "The <%s /> component appears to be a function component that returns a class instance. " + + "Change %s to a class that extends React.Component instead. " + + "If you can't use a class try assigning the prototype on the function as a workaround. " + + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + + "cannot be called with `new` by React.", + _componentName, + _componentName, + _componentName + ); + + didWarnAboutModulePatternComponent[_componentName] = true; + } + } + } if ( + // Run these checks in production only if the flag is off. + // Eventually we'll delete this branch altogether. typeof value === "object" && value !== null && typeof value.render === "function" && value.$$typeof === undefined ) { { - var _componentName = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutModulePatternComponent[_componentName]) { + if (!didWarnAboutModulePatternComponent[_componentName2]) { error( "The <%s /> component appears to be a function component that returns a class instance. " + "Change %s to a class that extends React.Component instead. " + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + "cannot be called with `new` by React.", - _componentName, - _componentName, - _componentName + _componentName2, + _componentName2, + _componentName2 ); - didWarnAboutModulePatternComponent[_componentName] = true; + didWarnAboutModulePatternComponent[_componentName2] = true; } } // Proceed under the assumption that this is a class instance @@ -12608,20 +12942,20 @@ function mountIndeterminateComponent( } adoptClassInstance(workInProgress, value); - mountClassInstance(workInProgress, Component, props, renderExpirationTime); + mountClassInstance(workInProgress, Component, props, renderLanes); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderExpirationTime + renderLanes ); } else { // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; - reconcileChildren(null, workInProgress, value, renderExpirationTime); + reconcileChildren(null, workInProgress, value, renderLanes); { validateFunctionComponentInDev(workInProgress, Component); @@ -12670,15 +13004,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { } if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName2 = getComponentName(Component) || "Unknown"; + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) { error( "%s: Function components do not support getDerivedStateFromProps.", - _componentName2 + _componentName3 ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true; } } @@ -12686,15 +13020,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName3 = getComponentName(Component) || "Unknown"; + var _componentName4 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) { error( "%s: Function components do not support contextType.", - _componentName3 + _componentName4 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true; } } } @@ -12702,41 +13036,68 @@ function validateFunctionComponentInDev(workInProgress, Component) { var SUSPENDED_MARKER = { dehydrated: null, - retryTime: NoWork + retryLane: NoLane }; -function shouldRemainOnFallback(suspenseContext, current, workInProgress) { - // If the context is telling us that we should show a fallback, and we're not - // already showing content, then we should show the fallback instead. - return ( - hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && - (current === null || current.memoizedState !== null) - ); +function mountSuspenseOffscreenState(renderLanes) { + return { + baseLanes: renderLanes + }; } -function updateSuspenseComponent( +function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { + return { + baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) + }; +} // TODO: Probably should inline this back + +function shouldRemainOnFallback( + suspenseContext, current, workInProgress, - renderExpirationTime + renderLanes ) { - var mode = workInProgress.mode; + // If we're already showing a fallback, there are cases where we need to + // remain on that fallback regardless of whether the content has resolved. + // For example, SuspenseList coordinates when nested content appears. + if (current !== null) { + var suspenseState = current.memoizedState; + + if (suspenseState === null) { + // Currently showing content. Don't hide it, even if ForceSuspenseFallack + // is true. More precise name might be "ForceRemainSuspenseFallback". + // Note: This is a factoring smell. Can't remain on a fallback if there's + // no fallback to remain on. + return false; + } + } // Not currently showing content. Consult the Suspense context. + + return hasSuspenseContext(suspenseContext, ForceSuspenseFallback); +} + +function getRemainingWorkInPrimaryTree(current, renderLanes) { + // TODO: Should not remove render lanes that were pinged during this render + return removeLanes(current.childLanes, renderLanes); +} + +function updateSuspenseComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. { if (shouldSuspend(workInProgress)) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } } var suspenseContext = suspenseStackCursor.current; - var nextDidTimeout = false; - var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; + var showFallback = false; + var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags; if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. - nextDidTimeout = true; - workInProgress.effectTag &= ~DidCapture; + showFallback = true; + workInProgress.flags &= ~DidCapture; } else { // Attempting the main content if (current === null || current.memoizedState !== null) { @@ -12758,290 +13119,411 @@ function updateSuspenseComponent( } suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); - pushSuspenseContext(workInProgress, suspenseContext); // This next part is a bit confusing. If the children timeout, we switch to - // showing the fallback children in place of the "primary" children. - // However, we don't want to delete the primary children because then their - // state will be lost (both the React state and the host state, e.g. - // uncontrolled form inputs). Instead we keep them mounted and hide them. - // Both the fallback children AND the primary children are rendered at the - // same time. Once the primary children are un-suspended, we can delete - // the fallback children — don't need to preserve their state. + pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense + // boundary's children. This involves some custom reconcilation logic. Two + // main reasons this is so complicated. // - // The two sets of children are siblings in the host environment, but - // semantically, for purposes of reconciliation, they are two separate sets. - // So we store them using two fragment fibers. + // First, Legacy Mode has different semantics for backwards compatibility. The + // primary tree will commit in an inconsistent state, so when we do the + // second pass to render the fallback, we do some exceedingly, uh, clever + // hacks to make that not totally break. Like transferring effects and + // deletions from hidden tree. In Concurrent Mode, it's much simpler, + // because we bailout on the primary tree completely and leave it in its old + // state, no effects. Same as what we do for Offscreen (except that + // Offscreen doesn't have the first render pass). // - // However, we want to avoid allocating extra fibers for every placeholder. - // They're only necessary when the children time out, because that's the - // only time when both sets are mounted. + // Second is hydration. During hydration, the Suspense fiber has a slightly + // different layout, where the child points to a dehydrated fragment, which + // contains the DOM rendered by the server. // - // So, the extra fragment fibers are only used if the children time out. - // Otherwise, we render the primary children directly. This requires some - // custom reconciliation logic to preserve the state of the primary - // children. It's essentially a very basic form of re-parenting. + // Third, even if you set all that aside, Suspense is like error boundaries in + // that we first we try to render one tree, and if that fails, we render again + // and switch to a different tree. Like a try/catch block. So we have to track + // which branch we're currently rendering. Ideally we would model this using + // a stack. if (current === null) { + // Initial mount // If we're currently hydrating, try to hydrate this boundary. // But only if this has a fallback. - if (nextProps.fallback !== undefined); // This is the initial mount. This branch is pretty simple because there's - // no previous state that needs to be preserved. + if (nextProps.fallback !== undefined); - if (nextDidTimeout) { - // Mount separate fragments for primary and fallback children. - var nextFallbackChildren = nextProps.fallback; - var primaryChildFragment = createFiberFromFragment( - null, - mode, - NoWork, - null - ); - primaryChildFragment.return = workInProgress; - - if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, we commit the effects from the - // partially completed, timed-out tree, too. - var progressedState = workInProgress.memoizedState; - var progressedPrimaryChild = - progressedState !== null - ? workInProgress.child.child - : workInProgress.child; - primaryChildFragment.child = progressedPrimaryChild; - var progressedChild = progressedPrimaryChild; - - while (progressedChild !== null) { - progressedChild.return = primaryChildFragment; - progressedChild = progressedChild.sibling; - } - } + var nextPrimaryChildren = nextProps.children; + var nextFallbackChildren = nextProps.fallback; - var fallbackChildFragment = createFiberFromFragment( + if (showFallback) { + var fallbackFragment = mountSuspenseFallbackChildren( + workInProgress, + nextPrimaryChildren, nextFallbackChildren, - mode, - renderExpirationTime, - null + renderLanes + ); + var primaryChildFragment = workInProgress.child; + primaryChildFragment.memoizedState = mountSuspenseOffscreenState( + renderLanes ); - fallbackChildFragment.return = workInProgress; - primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the - // fallback children. - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = primaryChildFragment; - return fallbackChildFragment; + return fallbackFragment; + } else if (typeof nextProps.unstable_expectedLoadTime === "number") { + // This is a CPU-bound tree. Skip this tree and show a placeholder to + // unblock the surrounding content. Then immediately retry after the + // initial commit. + var _fallbackFragment = mountSuspenseFallbackChildren( + workInProgress, + nextPrimaryChildren, + nextFallbackChildren, + renderLanes + ); + + var _primaryChildFragment = workInProgress.child; + _primaryChildFragment.memoizedState = mountSuspenseOffscreenState( + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to + // get it started back up to attempt the next item. While in terms of + // priority this work has the same priority as this current render, it's + // not part of the same transition once the transition has committed. If + // it's sync, we still want to yield so that it can be painted. + // Conceptually, this is really the same as pinging. We can use any + // RetryLane even if it's the one currently rendering since we're leaving + // it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + + return _fallbackFragment; } else { - // Mount the primary children without an intermediate fragment fiber. - var nextPrimaryChildren = nextProps.children; - workInProgress.memoizedState = null; - return (workInProgress.child = mountChildFibers( + return mountSuspensePrimaryChildren( workInProgress, - null, nextPrimaryChildren, - renderExpirationTime - )); + renderLanes + ); } } else { - // This is an update. This branch is more complicated because we need to - // ensure the state of the primary children is preserved. + // This is an update. + // If the current fiber has a SuspenseState, that means it's already showing + // a fallback. var prevState = current.memoizedState; if (prevState !== null) { - // wrapped in a fragment fiber. - - var currentPrimaryChildFragment = current.child; - var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; - - if (nextDidTimeout) { - // Still timed out. Reuse the current primary children by cloning - // its fragment. We're going to skip over these entirely. + if (showFallback) { var _nextFallbackChildren2 = nextProps.fallback; + var _nextPrimaryChildren2 = nextProps.children; - var _primaryChildFragment2 = createWorkInProgress( - currentPrimaryChildFragment, - currentPrimaryChildFragment.pendingProps + var _fallbackChildFragment = updateSuspenseFallbackChildren( + current, + workInProgress, + _nextPrimaryChildren2, + _nextFallbackChildren2, + renderLanes ); - _primaryChildFragment2.return = workInProgress; - - if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, we commit the effects from the - // partially completed, timed-out tree, too. - var _progressedState = workInProgress.memoizedState; - - var _progressedPrimaryChild = - _progressedState !== null - ? workInProgress.child.child - : workInProgress.child; - - if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { - _primaryChildFragment2.child = _progressedPrimaryChild; - var _progressedChild2 = _progressedPrimaryChild; - - while (_progressedChild2 !== null) { - _progressedChild2.return = _primaryChildFragment2; - _progressedChild2 = _progressedChild2.sibling; - } - } - } // Because primaryChildFragment is a new fiber that we're inserting as the - // parent of a new tree, we need to set its treeBaseDuration. - - if (workInProgress.mode & ProfileMode) { - // treeBaseDuration is the sum of all the child tree base durations. - var _treeBaseDuration = 0; - var _hiddenChild = _primaryChildFragment2.child; + var _primaryChildFragment3 = workInProgress.child; + var prevOffscreenState = current.child.memoizedState; + _primaryChildFragment3.memoizedState = + prevOffscreenState === null + ? mountSuspenseOffscreenState(renderLanes) + : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); + _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree( + current, + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return _fallbackChildFragment; + } else { + var _nextPrimaryChildren3 = nextProps.children; - while (_hiddenChild !== null) { - _treeBaseDuration += _hiddenChild.treeBaseDuration; - _hiddenChild = _hiddenChild.sibling; - } + var _primaryChildFragment4 = updateSuspensePrimaryChildren( + current, + workInProgress, + _nextPrimaryChildren3, + renderLanes + ); - _primaryChildFragment2.treeBaseDuration = _treeBaseDuration; - } // Clone the fallback child fragment, too. These we'll continue - // working on. + workInProgress.memoizedState = null; + return _primaryChildFragment4; + } + } else { + // The current tree is not already showing a fallback. + if (showFallback) { + // Timed out. + var _nextFallbackChildren3 = nextProps.fallback; + var _nextPrimaryChildren4 = nextProps.children; - var _fallbackChildFragment2 = createWorkInProgress( - currentFallbackChildFragment, - _nextFallbackChildren2 + var _fallbackChildFragment2 = updateSuspenseFallbackChildren( + current, + workInProgress, + _nextPrimaryChildren4, + _nextFallbackChildren3, + renderLanes ); - _fallbackChildFragment2.return = workInProgress; - _primaryChildFragment2.sibling = _fallbackChildFragment2; - _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the + var _primaryChildFragment5 = workInProgress.child; + var _prevOffscreenState = current.child.memoizedState; + _primaryChildFragment5.memoizedState = + _prevOffscreenState === null + ? mountSuspenseOffscreenState(renderLanes) + : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); + _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree( + current, + renderLanes + ); // Skip the primary children, and continue working on the // fallback children. workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = _primaryChildFragment2; return _fallbackChildFragment2; } else { - // No longer suspended. Switch back to showing the primary children, - // and remove the intermediate fragment fiber. - var _nextPrimaryChildren = nextProps.children; - var currentPrimaryChild = currentPrimaryChildFragment.child; - var primaryChild = reconcileChildFibers( + // Still haven't timed out. Continue rendering the children, like we + // normally do. + var _nextPrimaryChildren5 = nextProps.children; + + var _primaryChildFragment6 = updateSuspensePrimaryChildren( + current, workInProgress, - currentPrimaryChild, - _nextPrimaryChildren, - renderExpirationTime - ); // If this render doesn't suspend, we need to delete the fallback - // children. Wait until the complete phase, after we've confirmed the - // fallback is no longer needed. - // TODO: Would it be better to store the fallback fragment on - // the stateNode? - // Continue rendering the children, like we normally do. + _nextPrimaryChildren5, + renderLanes + ); workInProgress.memoizedState = null; - return (workInProgress.child = primaryChild); + return _primaryChildFragment6; } - } else { - // The current tree has not already timed out. That means the primary - // children are not wrapped in a fragment fiber. - var _currentPrimaryChild = current.child; + } + } +} - if (nextDidTimeout) { - // Timed out. Wrap the children in a fragment fiber to keep them - // separate from the fallback children. - var _nextFallbackChildren3 = nextProps.fallback; +function mountSuspensePrimaryChildren( + workInProgress, + primaryChildren, + renderLanes +) { + var mode = workInProgress.mode; + var primaryChildProps = { + mode: "visible", + children: primaryChildren + }; + var primaryChildFragment = createFiberFromOffscreen( + primaryChildProps, + mode, + renderLanes, + null + ); + primaryChildFragment.return = workInProgress; + workInProgress.child = primaryChildFragment; + return primaryChildFragment; +} - var _primaryChildFragment3 = createFiberFromFragment( - // It shouldn't matter what the pending props are because we aren't - // going to render this fragment. - null, - mode, - NoWork, - null - ); +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode; + var progressedPrimaryFragment = workInProgress.child; + var primaryChildProps = { + mode: "hidden", + children: primaryChildren + }; + var primaryChildFragment; + var fallbackChildFragment; + + if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) { + // In legacy mode, we commit the primary tree as if it successfully + // completed, even though it's in an inconsistent state. + primaryChildFragment = progressedPrimaryFragment; + primaryChildFragment.childLanes = NoLanes; + primaryChildFragment.pendingProps = primaryChildProps; + + if (workInProgress.mode & ProfileMode) { + // Reset the durations from the first pass so they aren't included in the + // final amounts. This seems counterintuitive, since we're intentionally + // not measuring part of the render phase, but this makes it match what we + // do in Concurrent Mode. + primaryChildFragment.actualDuration = 0; + primaryChildFragment.actualStartTime = -1; + primaryChildFragment.selfBaseDuration = 0; + primaryChildFragment.treeBaseDuration = 0; + } + + fallbackChildFragment = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + } else { + primaryChildFragment = createFiberFromOffscreen( + primaryChildProps, + mode, + NoLanes, + null + ); + fallbackChildFragment = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + } - _primaryChildFragment3.return = workInProgress; - _primaryChildFragment3.child = _currentPrimaryChild; + primaryChildFragment.return = workInProgress; + fallbackChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; +} - if (_currentPrimaryChild !== null) { - _currentPrimaryChild.return = _primaryChildFragment3; - } // Even though we're creating a new fiber, there are no new children, - // because we're reusing an already mounted tree. So we don't need to - // schedule a placement. - // primaryChildFragment.effectTag |= Placement; +function createWorkInProgressOffscreenFiber(current, offscreenProps) { + // The props argument to `createWorkInProgress` is `any` typed, so we use this + // wrapper function to constrain it. + return createWorkInProgress(current, offscreenProps); +} - if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, we commit the effects from the - // partially completed, timed-out tree, too. - var _progressedState2 = workInProgress.memoizedState; +function updateSuspensePrimaryChildren( + current, + workInProgress, + primaryChildren, + renderLanes +) { + var currentPrimaryChildFragment = current.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + var primaryChildFragment = createWorkInProgressOffscreenFiber( + currentPrimaryChildFragment, + { + mode: "visible", + children: primaryChildren + } + ); - var _progressedPrimaryChild2 = - _progressedState2 !== null - ? workInProgress.child.child - : workInProgress.child; + if ((workInProgress.mode & BlockingMode) === NoMode) { + primaryChildFragment.lanes = renderLanes; + } - _primaryChildFragment3.child = _progressedPrimaryChild2; - var _progressedChild3 = _progressedPrimaryChild2; + primaryChildFragment.return = workInProgress; + primaryChildFragment.sibling = null; - while (_progressedChild3 !== null) { - _progressedChild3.return = _primaryChildFragment3; - _progressedChild3 = _progressedChild3.sibling; - } - } // Because primaryChildFragment is a new fiber that we're inserting as the - // parent of a new tree, we need to set its treeBaseDuration. + if (currentFallbackChildFragment !== null) { + // Delete the fallback child fragment + currentFallbackChildFragment.nextEffect = null; + currentFallbackChildFragment.flags = Deletion; + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; + } - if (workInProgress.mode & ProfileMode) { - // treeBaseDuration is the sum of all the child tree base durations. - var _treeBaseDuration2 = 0; - var _hiddenChild2 = _primaryChildFragment3.child; + workInProgress.child = primaryChildFragment; + return primaryChildFragment; +} - while (_hiddenChild2 !== null) { - _treeBaseDuration2 += _hiddenChild2.treeBaseDuration; - _hiddenChild2 = _hiddenChild2.sibling; - } +function updateSuspenseFallbackChildren( + current, + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode; + var currentPrimaryChildFragment = current.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + var primaryChildProps = { + mode: "hidden", + children: primaryChildren + }; + var primaryChildFragment; - _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2; - } // Create a fragment from the fallback children, too. + if ( + // In legacy mode, we commit the primary tree as if it successfully + // completed, even though it's in an inconsistent state. + (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was + // already cloned. In legacy mode, the only case where this isn't true is + // when DevTools forces us to display a fallback; we skip the first render + // pass entirely and go straight to rendering the fallback. (In Concurrent + // Mode, SuspenseList can also trigger this scenario, but this is a legacy- + // only codepath.) + workInProgress.child !== currentPrimaryChildFragment + ) { + var progressedPrimaryFragment = workInProgress.child; + primaryChildFragment = progressedPrimaryFragment; + primaryChildFragment.childLanes = NoLanes; + primaryChildFragment.pendingProps = primaryChildProps; + + if (workInProgress.mode & ProfileMode) { + // Reset the durations from the first pass so they aren't included in the + // final amounts. This seems counterintuitive, since we're intentionally + // not measuring part of the render phase, but this makes it match what we + // do in Concurrent Mode. + primaryChildFragment.actualDuration = 0; + primaryChildFragment.actualStartTime = -1; + primaryChildFragment.selfBaseDuration = + currentPrimaryChildFragment.selfBaseDuration; + primaryChildFragment.treeBaseDuration = + currentPrimaryChildFragment.treeBaseDuration; + } // The fallback fiber was added as a deletion effect during the first pass. + // However, since we're going to remain on the fallback, we no longer want + // to delete it. So we need to remove it from the list. Deletions are stored + // on the same list as effects. We want to keep the effects from the primary + // tree. So we copy the primary child fragment's effect list, which does not + // include the fallback deletion effect. + + var progressedLastEffect = primaryChildFragment.lastEffect; + + if (progressedLastEffect !== null) { + workInProgress.firstEffect = primaryChildFragment.firstEffect; + workInProgress.lastEffect = progressedLastEffect; + progressedLastEffect.nextEffect = null; + } else { + // TODO: Reset this somewhere else? Lol legacy mode is so weird. + workInProgress.firstEffect = workInProgress.lastEffect = null; + } + } else { + primaryChildFragment = createWorkInProgressOffscreenFiber( + currentPrimaryChildFragment, + primaryChildProps + ); + } - var _fallbackChildFragment3 = createFiberFromFragment( - _nextFallbackChildren3, - mode, - renderExpirationTime, - null - ); + var fallbackChildFragment; - _fallbackChildFragment3.return = workInProgress; - _primaryChildFragment3.sibling = _fallbackChildFragment3; - _fallbackChildFragment3.effectTag |= Placement; - _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the - // fallback children. + if (currentFallbackChildFragment !== null) { + fallbackChildFragment = createWorkInProgress( + currentFallbackChildFragment, + fallbackChildren + ); + } else { + fallbackChildFragment = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); // Needs a placement effect because the parent (the Suspense boundary) already + // mounted but this is a new fiber. - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = _primaryChildFragment3; - return _fallbackChildFragment3; - } else { - // Still haven't timed out. Continue rendering the children, like we - // normally do. - workInProgress.memoizedState = null; - var _nextPrimaryChildren2 = nextProps.children; - return (workInProgress.child = reconcileChildFibers( - workInProgress, - _currentPrimaryChild, - _nextPrimaryChildren2, - renderExpirationTime - )); - } - } + fallbackChildFragment.flags |= Placement; } -} -function scheduleWorkOnFiber(fiber, renderExpirationTime) { - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } + fallbackChildFragment.return = workInProgress; + primaryChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; +} +function scheduleWorkOnFiber(fiber, renderLanes) { + fiber.lanes = mergeLanes(fiber.lanes, renderLanes); var alternate = fiber.alternate; - if (alternate !== null && alternate.expirationTime < renderExpirationTime) { - alternate.expirationTime = renderExpirationTime; + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, renderLanes); } - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + scheduleWorkOnParentPath(fiber.return, renderLanes); } function propagateSuspenseContextChange( workInProgress, firstChild, - renderExpirationTime + renderLanes ) { // Mark any Suspense boundaries with fallbacks as having work to do. // If they were previously forced into fallbacks, they may now be able @@ -13053,7 +13535,7 @@ function propagateSuspenseContextChange( var state = node.memoizedState; if (state !== null) { - scheduleWorkOnFiber(node, renderExpirationTime); + scheduleWorkOnFiber(node, renderLanes); } } else if (node.tag === SuspenseListComponent) { // If the tail is hidden there might not be an Suspense boundaries @@ -13061,7 +13543,7 @@ function propagateSuspenseContextChange( // list itself. // We don't have to traverse to the children of the list since // the list will propagate the change when it rerenders. - scheduleWorkOnFiber(node, renderExpirationTime); + scheduleWorkOnFiber(node, renderLanes); } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -13280,7 +13762,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }; @@ -13291,7 +13772,6 @@ function initSuspenseListRenderState( renderState.renderingStartTime = 0; renderState.last = lastContentRow; renderState.tail = tail; - renderState.tailExpiration = 0; renderState.tailMode = tailMode; renderState.lastEffect = lastEffectBeforeRendering; } @@ -13303,11 +13783,7 @@ function initSuspenseListRenderState( // in fallback state. Then we render each row in the tail one-by-one. // That happens in the completeWork phase without going back to beginWork. -function updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime -) { +function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var revealOrder = nextProps.revealOrder; var tailMode = nextProps.tail; @@ -13315,7 +13791,7 @@ function updateSuspenseListComponent( validateRevealOrder(revealOrder); validateTailOptions(tailMode, revealOrder); validateSuspenseListChildren(newChildren, revealOrder); - reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); + reconcileChildren(current, workInProgress, newChildren, renderLanes); var suspenseContext = suspenseStackCursor.current; var shouldForceFallback = hasSuspenseContext( suspenseContext, @@ -13327,10 +13803,10 @@ function updateSuspenseListComponent( suspenseContext, ForceSuspenseFallback ); - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } else { var didSuspendBefore = - current !== null && (current.effectTag & DidCapture) !== NoEffect; + current !== null && (current.flags & DidCapture) !== NoFlags; if (didSuspendBefore) { // If we previously forced a fallback, we need to schedule work @@ -13339,7 +13815,7 @@ function updateSuspenseListComponent( propagateSuspenseContextChange( workInProgress, workInProgress.child, - renderExpirationTime + renderLanes ); } @@ -13349,7 +13825,7 @@ function updateSuspenseListComponent( pushSuspenseContext(workInProgress, suspenseContext); if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, SuspenseList doesn't work so we just + // In legacy mode, SuspenseList doesn't work so we just // use make it a noop by treating it as the default revealOrder. workInProgress.memoizedState = null; } else { @@ -13439,7 +13915,7 @@ function updateSuspenseListComponent( return workInProgress.child; } -function updatePortalComponent(current, workInProgress, renderExpirationTime) { +function updatePortalComponent(current, workInProgress, renderLanes) { pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); var nextChildren = workInProgress.pendingProps; @@ -13453,21 +13929,18 @@ function updatePortalComponent(current, workInProgress, renderExpirationTime) { workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); } else { - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); } return workInProgress.child; } -function updateContextProvider(current, workInProgress, renderExpirationTime) { +var hasWarnedAboutUsingNoValuePropOnContextProvider = false; + +function updateContextProvider(current, workInProgress, renderLanes) { var providerType = workInProgress.type; var context = providerType._context; var newProps = workInProgress.pendingProps; @@ -13475,6 +13948,16 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) { var newValue = newProps.value; { + if (!("value" in newProps)) { + if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { + hasWarnedAboutUsingNoValuePropOnContextProvider = true; + + error( + "The `value` prop is required for the ``. Did you misspell it or forget to pass it?" + ); + } + } + var providerPropTypes = workInProgress.type.propTypes; if (providerPropTypes) { @@ -13494,29 +13977,24 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) { return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); } } else { // The context value changed. Search for matching consumers and schedule // them to update. - propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime - ); + propagateContextChange(workInProgress, context, changedBits, renderLanes); } } var newChildren = newProps.children; - reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); + reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } var hasWarnedAboutUsingContextAsConsumer = false; -function updateContextConsumer(current, workInProgress, renderExpirationTime) { +function updateContextConsumer(current, workInProgress, renderLanes) { var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In // DEV mode, we create a separate object for Context.Consumer that acts // like a proxy to Context. This proxy object adds unnecessary code in PROD @@ -13559,7 +14037,7 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) { } } - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); var newValue = readContext(context, newProps.unstable_observedBits); var newChildren; @@ -13570,8 +14048,8 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) { setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } @@ -13579,13 +14057,7 @@ function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } -function bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime -) { - cancelWorkTimer(workInProgress); - +function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { if (current !== null) { // Reuse previous dependencies workInProgress.dependencies = current.dependencies; @@ -13596,15 +14068,9 @@ function bailoutOnAlreadyFinishedWork( stopProfilerTimerIfRunning(); } - var updateExpirationTime = workInProgress.expirationTime; - - if (updateExpirationTime !== NoWork) { - markUnprocessedUpdateTime(updateExpirationTime); - } // Check if the children have any pending work. + markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work. - var childExpirationTime = workInProgress.childExpirationTime; - - if (childExpirationTime < renderExpirationTime) { + if (!includesSomeLane(renderLanes, workInProgress.childLanes)) { // The children don't have any work either. We can skip them. // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. @@ -13665,15 +14131,15 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } current.nextEffect = null; - current.effectTag = Deletion; - newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber. + current.flags = Deletion; + newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; } } -function beginWork(current, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; +function beginWork(current, workInProgress, renderLanes) { + var updateLanes = workInProgress.lanes; { if (workInProgress._debugNeedsRemount && current !== null) { @@ -13687,7 +14153,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, - workInProgress.expirationTime + workInProgress.lanes ) ); } @@ -13705,7 +14171,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { // If props or context changed, mark the fiber as having performed work. // This may be unset if the props are determined to be equal later (memo). didReceiveUpdate = true; - } else if (updateExpirationTime < renderExpirationTime) { + } else if (!includesSomeLane(renderLanes, updateLanes)) { didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering // the begin phase. There's still some bookkeeping we that needs to be done // in this optimized path, mostly pushing stuff onto the stack. @@ -13717,20 +14183,6 @@ function beginWork(current, workInProgress, renderExpirationTime) { case HostComponent: pushHostContext(workInProgress); - - if ( - workInProgress.mode & ConcurrentMode && - renderExpirationTime !== Never && - shouldDeprioritizeSubtree(workInProgress.type) - ) { - { - markSpawnedWork(Never); - } // Schedule this fiber to re-render at offscreen priority. Then bailout. - - workInProgress.expirationTime = workInProgress.childExpirationTime = Never; - return null; - } - break; case ClassComponent: { @@ -13759,11 +14211,13 @@ function beginWork(current, workInProgress, renderExpirationTime) { case Profiler: { // Profiler should only call onRender when one of its descendants actually rendered. - var hasChildWork = - workInProgress.childExpirationTime >= renderExpirationTime; + var hasChildWork = includesSomeLane( + renderLanes, + workInProgress.childLanes + ); if (hasChildWork) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -13783,21 +14237,19 @@ function beginWork(current, workInProgress, renderExpirationTime) { // child fragment. var primaryChildFragment = workInProgress.child; - var primaryChildExpirationTime = - primaryChildFragment.childExpirationTime; + var primaryChildLanes = primaryChildFragment.childLanes; - if ( - primaryChildExpirationTime !== NoWork && - primaryChildExpirationTime >= renderExpirationTime - ) { + if (includesSomeLane(renderLanes, primaryChildLanes)) { // The primary children have pending work. Use the normal path // to attempt to render the primary children again. return updateSuspenseComponent( current, workInProgress, - renderExpirationTime + renderLanes ); } else { + // The primary child fragment does not have pending work marked + // on it pushSuspenseContext( workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current) @@ -13807,7 +14259,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { var child = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); if (child !== null) { @@ -13829,10 +14281,12 @@ function beginWork(current, workInProgress, renderExpirationTime) { } case SuspenseListComponent: { - var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; + var didSuspendBefore = (current.flags & DidCapture) !== NoFlags; - var _hasChildWork = - workInProgress.childExpirationTime >= renderExpirationTime; + var _hasChildWork = includesSomeLane( + renderLanes, + workInProgress.childLanes + ); if (didSuspendBefore) { if (_hasChildWork) { @@ -13844,13 +14298,13 @@ function beginWork(current, workInProgress, renderExpirationTime) { return updateSuspenseListComponent( current, workInProgress, - renderExpirationTime + renderLanes ); } // If none of the children had any work, that means that none of // them got retried so they'll still be blocked in the same way // as before. We can fast bail out. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } // If nothing suspended before and we're rendering the same children, // then the tail doesn't matter. Anything new that suspends will work // in the "together" mode, so we can continue from the state we had. @@ -13862,6 +14316,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { // update in the past but didn't complete it. renderState.rendering = null; renderState.tail = null; + renderState.lastEffect = null; } pushSuspenseContext(workInProgress, suspenseStackCursor.current); @@ -13875,19 +14330,35 @@ function beginWork(current, workInProgress, renderExpirationTime) { return null; } } + + case OffscreenComponent: + case LegacyHiddenComponent: { + // Need to check if the tree still needs to be deferred. This is + // almost identical to the logic used in the normal update path, + // so we'll just enter that. The only difference is we'll bail out + // at the next level instead of this one, because the child props + // have not changed. Which is fine. + // TODO: Probably should refactor `beginWork` to split the bailout + // path from the normal path. I'm tempted to do a labeled break here + // but I won't :) + workInProgress.lanes = NoLanes; + return updateOffscreenComponent(current, workInProgress, renderLanes); + } } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else { - // An update was scheduled on this fiber, but there are no new props - // nor legacy context. Set this to false. If an update queue or context - // consumer produces a changed value, it will set this to true. Otherwise, - // the component will assume the children have not changed and bail out. - didReceiveUpdate = false; + if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { + // This is a special case that only exists for legacy mode. + // See https://github.com/facebook/react/pull/19216. + didReceiveUpdate = true; + } else { + // An update was scheduled on this fiber, but there are no new props + // nor legacy context. Set this to false. If an update queue or context + // consumer produces a changed value, it will set this to true. Otherwise, + // the component will assume the children have not changed and bail out. + didReceiveUpdate = false; + } } } else { didReceiveUpdate = false; @@ -13897,7 +14368,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { // sometimes bails out later in the begin phase. This indicates that we should // move this assignment out of the common path and into each branch. - workInProgress.expirationTime = NoWork; + workInProgress.lanes = NoLanes; switch (workInProgress.tag) { case IndeterminateComponent: { @@ -13905,7 +14376,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.type, - renderExpirationTime + renderLanes ); } @@ -13915,8 +14386,8 @@ function beginWork(current, workInProgress, renderExpirationTime) { current, workInProgress, elementType, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -13932,7 +14403,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _Component, resolvedProps, - renderExpirationTime + renderLanes ); } @@ -13950,32 +14421,24 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _Component2, _resolvedProps, - renderExpirationTime + renderLanes ); } case HostRoot: - return updateHostRoot(current, workInProgress, renderExpirationTime); + return updateHostRoot(current, workInProgress, renderLanes); case HostComponent: - return updateHostComponent(current, workInProgress, renderExpirationTime); + return updateHostComponent(current, workInProgress, renderLanes); case HostText: return updateHostText(); case SuspenseComponent: - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseComponent(current, workInProgress, renderLanes); case HostPortal: - return updatePortalComponent( - current, - workInProgress, - renderExpirationTime - ); + return updatePortalComponent(current, workInProgress, renderLanes); case ForwardRef: { var type = workInProgress.type; @@ -13991,32 +14454,24 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, type, _resolvedProps2, - renderExpirationTime + renderLanes ); } case Fragment: - return updateFragment(current, workInProgress, renderExpirationTime); + return updateFragment(current, workInProgress, renderLanes); case Mode: - return updateMode(current, workInProgress, renderExpirationTime); + return updateMode(current, workInProgress, renderLanes); case Profiler: - return updateProfiler(current, workInProgress, renderExpirationTime); + return updateProfiler(current, workInProgress, renderLanes); case ContextProvider: - return updateContextProvider( - current, - workInProgress, - renderExpirationTime - ); + return updateContextProvider(current, workInProgress, renderLanes); case ContextConsumer: - return updateContextConsumer( - current, - workInProgress, - renderExpirationTime - ); + return updateContextConsumer(current, workInProgress, renderLanes); case MemoComponent: { var _type2 = workInProgress.type; @@ -14045,8 +14500,8 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _type2, _resolvedProps3, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -14056,8 +14511,8 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -14075,16 +14530,32 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _Component3, _resolvedProps4, - renderExpirationTime + renderLanes ); } case SuspenseListComponent: { - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseListComponent(current, workInProgress, renderLanes); + } + + case FundamentalComponent: { + break; + } + + case ScopeComponent: { + break; + } + + case Block: { + break; + } + + case OffscreenComponent: { + return updateOffscreenComponent(current, workInProgress, renderLanes); + } + + case LegacyHiddenComponent: { + return updateLegacyHiddenComponent(current, workInProgress, renderLanes); } } @@ -14100,11 +14571,11 @@ function beginWork(current, workInProgress, renderExpirationTime) { function markUpdate(workInProgress) { // Tag the fiber with an update effect. This turns a Placement into // a PlacementAndUpdate. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } function markRef$1(workInProgress) { - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } var appendAllChildren; @@ -14149,7 +14620,7 @@ var updateHostText$1; appendInitialChild(parent, _instance); } else if (node.tag === HostPortal); else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoFlags) { // Need to toggle the visibility of the primary children. var newIsHidden = node.memoizedState !== null; @@ -14244,7 +14715,7 @@ var updateHostText$1; appendChildToContainerChildSet(containerChildSet, _instance3); } else if (node.tag === HostPortal); else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoFlags) { // Need to toggle the visibility of the primary children. var newIsHidden = node.memoizedState !== null; @@ -14474,7 +14945,7 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { } } -function completeWork(current, workInProgress, renderExpirationTime) { +function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -14503,6 +14974,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); + resetWorkInProgressVersions(); var fiberRoot = workInProgress.stateNode; if (fiberRoot.pendingContext) { @@ -14519,6 +14991,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); + } else if (!fiberRoot.hydrate) { + // Schedule an effect to clear this container at the start of the next commit. + // This handles the case of React rendering into a container with previous children. + // It's also safe to do for updates too, because current.child would only be null + // if the previous render was null (so the the container would already be empty). + workInProgress.flags |= Snapshot; } } @@ -14577,9 +15055,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { currentHostContext, workInProgress ); - appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners - - workInProgress.stateNode = instance; + appendAllChildren(instance, workInProgress, false, false); + workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount. } if (workInProgress.ref !== null) { @@ -14635,9 +15112,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; - if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + if ((workInProgress.flags & DidCapture) !== NoFlags) { // Something suspended. Re-render with the fallback children. - workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list. + workInProgress.lanes = renderLanes; // Do not reset the effect list. + + if ((workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } return workInProgress; } @@ -14650,29 +15131,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { } else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; - - if (!nextDidTimeout && prevState !== null) { - // We just switched from the fallback to the normal children. - // Delete the fallback. - // TODO: Would it be better to store the fallback fragment on - // the stateNode during the begin phase? - var currentFallbackChild = current.child.sibling; - - if (currentFallbackChild !== null) { - // Deletions go at the beginning of the return fiber's effect list - var first = workInProgress.firstEffect; - - if (first !== null) { - workInProgress.firstEffect = currentFallbackChild; - currentFallbackChild.nextEffect = first; - } else { - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; - currentFallbackChild.nextEffect = null; - } - - currentFallbackChild.effectTag = Deletion; - } - } } if (nextDidTimeout && !prevDidTimeout) { @@ -14717,7 +15175,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // If this boundary just timed out, schedule an effect to attach a // retry listener to the promise. This flag is also used to hide the // primary children. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -14727,6 +15185,11 @@ function completeWork(current, workInProgress, renderExpirationTime) { case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); + + if (current === null) { + preparePortalMount(workInProgress.stateNode.containerInfo); + } + return null; case ContextProvider: @@ -14756,8 +15219,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } - var didSuspendAlready = - (workInProgress.effectTag & DidCapture) !== NoEffect; + var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags; var renderedTail = renderState.rendering; if (renderedTail === null) { @@ -14774,7 +15236,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // findFirstSuspended. var cannotBeSuspended = renderHasNotSuspendedYet() && - (current === null || (current.effectTag & DidCapture) === NoEffect); + (current === null || (current.flags & DidCapture) === NoFlags); if (!cannotBeSuspended) { var row = workInProgress.child; @@ -14784,7 +15246,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (suspended !== null) { didSuspendAlready = true; - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as // part of the second pass. In that case nothing will subscribe to // its thennables. Instead, we'll transfer its thennables to the @@ -14802,7 +15264,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks // to stay in place. // Reset the effect list before doing the second pass since that's now invalid. @@ -14813,7 +15275,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. - resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately + resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately // rerender the children. pushSuspenseContext( @@ -14826,7 +15288,29 @@ function completeWork(current, workInProgress, renderExpirationTime) { return workInProgress.child; } - row = row.sibling; + row = row.sibling; + } + } + + if (renderState.tail !== null && now() > getRenderTargetTime()) { + // We have already passed our CPU deadline but we still have rows + // left in the tail. We'll just give up further attempts to render + // the main content and only render fallbacks. + workInProgress.flags |= DidCapture; + didSuspendAlready = true; + cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); } } } else { @@ -14838,7 +15322,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { var _suspended = findFirstSuspended(renderedTail); if (_suspended !== null) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't // get lost if this row ends up dropped during a second pass. @@ -14846,7 +15330,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (_newThennables !== null) { workInProgress.updateQueue = _newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } cutOffTailIfNeeded(renderState, true); // This might have been modified. @@ -14854,7 +15338,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { if ( renderState.tail === null && renderState.tailMode === "hidden" && - !renderedTail.alternate + !renderedTail.alternate && + !getIsHydrating() // We don't cut it if we're hydrating. ) { // We need to delete the row we just rendered. // Reset the effect list to what it was before we rendered this @@ -14869,28 +15354,31 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } } else if ( - // The time it took to render last row is greater than time until - // the expiration. + // The time it took to render last row is greater than the remaining + // time we have to render. So rendering one more row would likely + // exceed it. now() * 2 - renderState.renderingStartTime > - renderState.tailExpiration && - renderExpirationTime > Never + getRenderTargetTime() && + renderLanes !== OffscreenLane ) { // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. // The assumption is that this is usually faster. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this - // to get it started back up to attempt the next item. If we can show - // them, then they really have the same priority as this render. - // So we'll pick it back up the very next render pass once we've had - // an opportunity to yield for paint. + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. - var nextPriority = renderExpirationTime - 1; - workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority; + workInProgress.lanes = SomeRetryLane; { - markSpawnedWork(nextPriority); + markSpawnedWork(SomeRetryLane); } } } @@ -14918,18 +15406,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (renderState.tail !== null) { // We still have tail rows to render. - if (renderState.tailExpiration === 0) { - // Heuristic for how long we're willing to spend rendering rows - // until we just give up and show what we have so far. - var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this - // is a per component value. It should really be since the start - // of the total render or last commit. Consider using something like - // globalMostRecentFallbackTime. That doesn't account for being - // suspended for part of the time or when it's a new render. - // It should probably use a global start time value instead. - } // Pop a row. - + // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; @@ -14957,6 +15434,38 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } + + case FundamentalComponent: { + break; + } + + case ScopeComponent: { + break; + } + + case Block: + break; + + case OffscreenComponent: + case LegacyHiddenComponent: { + popRenderLanes(workInProgress); + + if (current !== null) { + var _nextState = workInProgress.memoizedState; + var _prevState = current.memoizedState; + var prevIsHidden = _prevState !== null; + var nextIsHidden = _nextState !== null; + + if ( + prevIsHidden !== nextIsHidden && + newProps.mode !== "unstable-defer-without-hiding" + ) { + workInProgress.flags |= Update; + } + } + + return null; + } } { @@ -14968,7 +15477,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } -function unwindWork(workInProgress, renderExpirationTime) { +function unwindWork(workInProgress, renderLanes) { switch (workInProgress.tag) { case ClassComponent: { var Component = workInProgress.type; @@ -14977,10 +15486,15 @@ function unwindWork(workInProgress, renderExpirationTime) { popContext(workInProgress); } - var effectTag = workInProgress.effectTag; + var flags = workInProgress.flags; + + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; + + if ((workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } @@ -14990,198 +15504,553 @@ function unwindWork(workInProgress, renderExpirationTime) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag = workInProgress.effectTag; + resetWorkInProgressVersions(); + var _flags = workInProgress.flags; - if (!((_effectTag & DidCapture) === NoEffect)) { + if (!((_flags & DidCapture) === NoFlags)) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); } - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; - return workInProgress; - } + workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; + return workInProgress; + } + + case HostComponent: { + // TODO: popHydrationState + popHostContext(workInProgress); + return null; + } + + case SuspenseComponent: { + popSuspenseContext(workInProgress); + + var _flags2 = workInProgress.flags; + + if (_flags2 & ShouldCapture) { + workInProgress.flags = (_flags2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. + + if ((workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } + + return workInProgress; + } + + return null; + } + + case SuspenseListComponent: { + popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been + // caught by a nested boundary. If not, it should bubble through. + + return null; + } + + case HostPortal: + popHostContainer(workInProgress); + return null; + + case ContextProvider: + popProvider(workInProgress); + return null; + + case OffscreenComponent: + case LegacyHiddenComponent: + popRenderLanes(workInProgress); + return null; + + default: + return null; + } +} + +function unwindInterruptedWork(interruptedWork) { + switch (interruptedWork.tag) { + case ClassComponent: { + var childContextTypes = interruptedWork.type.childContextTypes; + + if (childContextTypes !== null && childContextTypes !== undefined) { + popContext(interruptedWork); + } + + break; + } + + case HostRoot: { + popHostContainer(interruptedWork); + popTopLevelContextObject(interruptedWork); + resetWorkInProgressVersions(); + break; + } + + case HostComponent: { + popHostContext(interruptedWork); + break; + } + + case HostPortal: + popHostContainer(interruptedWork); + break; + + case SuspenseComponent: + popSuspenseContext(interruptedWork); + break; + + case SuspenseListComponent: + popSuspenseContext(interruptedWork); + break; + + case ContextProvider: + popProvider(interruptedWork); + break; + + case OffscreenComponent: + case LegacyHiddenComponent: + popRenderLanes(interruptedWork); + break; + } +} + +function createCapturedValue(value, source) { + // If the value is an error, call this function immediately after it is thrown + // so the stack is accurate. + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} + +if ( + !( + typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === + "function" + ) +) { + throw Error( + "Expected ReactFiberErrorDialog.showErrorDialog to be a function." + ); +} + +function showErrorDialog(boundary, errorInfo) { + var capturedError = { + componentStack: errorInfo.stack !== null ? errorInfo.stack : "", + error: errorInfo.value, + errorBoundary: + boundary !== null && boundary.tag === ClassComponent + ? boundary.stateNode + : null + }; + return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( + capturedError + ); +} + +function logCapturedError(boundary, errorInfo) { + try { + var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + var error = errorInfo.value; + + if (true) { + var source = errorInfo.source; + var stack = errorInfo.stack; + var componentStack = stack !== null ? stack : ""; // Browsers support silencing uncaught errors by calling + // `preventDefault()` in window `error` handler. + // We record this information as an expando on the error. + + if (error != null && error._suppressLogging) { + if (boundary.tag === ClassComponent) { + // The error is recoverable and was silenced. + // Ignore it and don't print the stack addendum. + // This is handy for testing error boundaries without noise. + return; + } // The error is fatal. Since the silencing might have + // been accidental, we'll surface it anyway. + // However, the browser would have silenced the original error + // so we'll print it first, and then print the stack addendum. + + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: + // https://github.com/facebook/react/pull/13384 + } + + var componentName = source ? getComponentName(source.type) : null; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; + var errorBoundaryMessage; + var errorBoundaryName = getComponentName(boundary.type); + + if (errorBoundaryName) { + errorBoundaryMessage = + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + errorBoundaryName + "."); + } else { + errorBoundaryMessage = + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries."; + } + + var combinedMessage = + componentNameMessage + + "\n" + + componentStack + + "\n\n" + + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. + // We don't include the original error message and JS stack because the browser + // has already printed it. Even if the application swallows the error, it is still + // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. + + console["error"](combinedMessage); // Don't transform to our wrapper + } else { + // In production, we print the error directly. + // This will include the message, the JS stack, and anything the browser wants to show. + // We pass the error object instead of custom message so that the browser displays the error natively. + console["error"](error); // Don't transform to our wrapper + } + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function() { + throw e; + }); + } +} + +var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; + +function createRootErrorUpdate(fiber, errorInfo, lane) { + var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. + + update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property + // being called "element". + + update.payload = { + element: null + }; + var error = errorInfo.value; + + update.callback = function() { + onUncaughtError(error); + logCapturedError(fiber, errorInfo); + }; + + return update; +} + +function createClassErrorUpdate(fiber, errorInfo, lane) { + var update = createUpdate(NoTimestamp, lane); + update.tag = CaptureUpdate; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + + if (typeof getDerivedStateFromError === "function") { + var error$1 = errorInfo.value; + + update.payload = function() { + logCapturedError(fiber, errorInfo); + return getDerivedStateFromError(error$1); + }; + } + + var inst = fiber.stateNode; + + if (inst !== null && typeof inst.componentDidCatch === "function") { + update.callback = function callback() { + { + markFailedErrorBoundaryForHotReloading(fiber); + } + + if (typeof getDerivedStateFromError !== "function") { + // To preserve the preexisting retry behavior of error boundaries, + // we keep track of which ones already failed during this batch. + // This gets reset before we yield back to the browser. + // TODO: Warn in strict mode if getDerivedStateFromError is + // not defined. + markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined + + logCapturedError(fiber, errorInfo); + } + + var error$1 = errorInfo.value; + var stack = errorInfo.stack; + this.componentDidCatch(error$1, { + componentStack: stack !== null ? stack : "" + }); + + { + if (typeof getDerivedStateFromError !== "function") { + // If componentDidCatch is the only error boundary method defined, + // then it needs to call setState to recover from errors. + // If no state update is scheduled then the boundary will swallow the error. + if (!includesSomeLane(fiber.lanes, SyncLane)) { + error( + "%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" + ); + } + } + } + }; + } else { + update.callback = function() { + markFailedErrorBoundaryForHotReloading(fiber); + }; + } + + return update; +} + +function attachPingListener(root, wakeable, lanes) { + // Attach a listener to the promise to "ping" the root and retry. But only if + // one does not already exist for the lanes we're currently rendering (which + // acts like a "thread ID" here). + var pingCache = root.pingCache; + var threadIDs; - case HostComponent: { - // TODO: popHydrationState - popHostContext(workInProgress); - return null; - } + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap$1(); + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else { + threadIDs = pingCache.get(wakeable); - case SuspenseComponent: { - popSuspenseContext(workInProgress); + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } + } - var _effectTag2 = workInProgress.effectTag; + if (!threadIDs.has(lanes)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(lanes); + var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); + wakeable.then(ping, ping); + } +} - if (_effectTag2 & ShouldCapture) { - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. +function throwException( + root, + returnFiber, + sourceFiber, + value, + rootRenderLanes +) { + // The source fiber did not complete. + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. - return workInProgress; - } + sourceFiber.firstEffect = sourceFiber.lastEffect = null; - return null; - } + if ( + value !== null && + typeof value === "object" && + typeof value.then === "function" + ) { + // This is a wakeable. + var wakeable = value; - case SuspenseListComponent: { - popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been - // caught by a nested boundary. If not, it should bubble through. + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; - return null; + if (currentSource) { + sourceFiber.updateQueue = currentSource.updateQueue; + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.lanes = currentSource.lanes; + } else { + sourceFiber.updateQueue = null; + sourceFiber.memoizedState = null; + } } - case HostPortal: - popHostContainer(workInProgress); - return null; - - case ContextProvider: - popProvider(workInProgress); - return null; + var hasInvisibleParentBoundary = hasSuspenseContext( + suspenseStackCursor.current, + InvisibleParentSuspenseContext + ); // Schedule the nearest Suspense to re-render the timed out view. - default: - return null; - } -} + var _workInProgress = returnFiber; -function unwindInterruptedWork(interruptedWork) { - switch (interruptedWork.tag) { - case ClassComponent: { - var childContextTypes = interruptedWork.type.childContextTypes; + do { + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) + ) { + // Found the nearest boundary. + // Stash the promise on the boundary fiber. If the boundary times out, we'll + // attach another listener to flip the boundary back to its normal state. + var wakeables = _workInProgress.updateQueue; - if (childContextTypes !== null && childContextTypes !== undefined) { - popContext(interruptedWork); - } + if (wakeables === null) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + _workInProgress.updateQueue = updateQueue; + } else { + wakeables.add(wakeable); + } // If the boundary is outside of blocking mode, we should *not* + // suspend the commit. Pretend as if the suspended component rendered + // null and keep rendering. In the commit phase, we'll schedule a + // subsequent synchronous update to re-render the Suspense. + // + // Note: It doesn't matter whether the component that suspended was + // inside a blocking mode tree. If the Suspense is outside of it, we + // should *not* suspend the commit. - break; - } + if ((_workInProgress.mode & BlockingMode) === NoMode) { + _workInProgress.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. + // But we shouldn't call any lifecycle methods or callbacks. Remove + // all lifecycle effect tags. - case HostRoot: { - popHostContainer(interruptedWork); - popTopLevelContextObject(interruptedWork); - break; - } + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); - case HostComponent: { - popHostContext(interruptedWork); - break; - } + if (sourceFiber.tag === ClassComponent) { + var currentSourceFiber = sourceFiber.alternate; - case HostPortal: - popHostContainer(interruptedWork); - break; + if (currentSourceFiber === null) { + // This is a new mount. Change the tag so it's not mistaken for a + // completed class component. For example, we should not call + // componentWillUnmount if it is deleted. + sourceFiber.tag = IncompleteClassComponent; + } else { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force update to + // prevent a bail out. + var update = createUpdate(NoTimestamp, SyncLane); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } // The source fiber did not complete. Mark it with Sync priority to + // indicate that it still has pending work. - case SuspenseComponent: - popSuspenseContext(interruptedWork); - break; + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. - case SuspenseListComponent: - popSuspenseContext(interruptedWork); - break; + return; + } // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + // + // After this we'll use a set of heuristics to determine whether this + // render pass will run to completion or restart or "suspend" the commit. + // The actual logic for this is spread out in different places. + // + // This first principle is that if we're going to suspend when we complete + // a root, then we should also restart if we get an update or ping that + // might unsuspend it, and vice versa. The only reason to suspend is + // because you think you might want to restart before committing. However, + // it doesn't make sense to restart only while in the period we're suspended. + // + // Restarting too aggressively is also not good because it starves out any + // intermediate loading state. So we use heuristics to determine when. + // Suspense Heuristics + // + // If nothing threw a Promise or all the same fallbacks are already showing, + // then don't suspend/restart. + // + // If this is an initial render of a new tree of Suspense boundaries and + // those trigger a fallback, then don't suspend/restart. We want to ensure + // that we can show the initial loading state as quickly as possible. + // + // If we hit a "Delayed" case, such as when we'd switch from content back into + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. + // + // If we're already showing a fallback and it gets "retried", allowing us to show + // another level, but there's still an inner boundary that would show a fallback, + // then we suspend/restart for 500ms since the last time we showed a fallback + // anywhere in the tree. This effectively throttles progressive loading into a + // consistent train of commits. This also gives us an opportunity to restart to + // get to the completed state slightly earlier. + // + // If there's ambiguity due to batching it's resolved in preference of: + // 1) "delayed", 2) "initial render", 3) "retry". + // + // We want to ensure that a "busy" state doesn't get force committed. We want to + // ensure that new initial loading states can commit as soon as possible. - case ContextProvider: - popProvider(interruptedWork); - break; - } -} + attachPingListener(root, wakeable, rootRenderLanes); + _workInProgress.flags |= ShouldCapture; + _workInProgress.lanes = rootRenderLanes; + return; + } // This boundary already captured during this render. Continue to the next + // boundary. -function createCapturedValue(value, source) { - // If the value is an error, call this function immediately after it is thrown - // so the stack is accurate. - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; -} + _workInProgress = _workInProgress.return; + } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. + // TODO: Use invariant so the message is stripped in prod? -// Module provided by RN: + value = new Error( + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + ); + } // We didn't find a boundary that could handle this type of exception. Start + // over and traverse parent path again, this time treating the exception + // as an error. -if ( - !( - typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === - "function" - ) -) { - throw Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); -} + renderDidError(); + value = createCapturedValue(value, sourceFiber); + var workInProgress = returnFiber; -function showErrorDialog(capturedError) { - return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( - capturedError - ); -} + do { + switch (workInProgress.tag) { + case HostRoot: { + var _errorInfo = value; + workInProgress.flags |= ShouldCapture; + var lane = pickArbitraryLane(rootRenderLanes); + workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); -function logCapturedError(capturedError) { - var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); - if (logError === false) { - return; - } + enqueueCapturedUpdate(workInProgress, _update); + return; + } - var error = capturedError.error; + case ClassComponent: + // Capture and retry + var errorInfo = value; + var ctor = workInProgress.type; + var instance = workInProgress.stateNode; - { - var componentName = capturedError.componentName, - componentStack = capturedError.componentStack, - errorBoundaryName = capturedError.errorBoundaryName, - errorBoundaryFound = capturedError.errorBoundaryFound, - willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling - // `preventDefault()` in window `error` handler. - // We record this information as an expando on the error. - - if (error != null && error._suppressLogging) { - if (errorBoundaryFound && willRetry) { - // The error is recoverable and was silenced. - // Ignore it and don't print the stack addendum. - // This is handy for testing error boundaries without noise. - return; - } // The error is fatal. Since the silencing might have - // been accidental, we'll surface it anyway. - // However, the browser would have silenced the original error - // so we'll print it first, and then print the stack addendum. + if ( + (workInProgress.flags & DidCapture) === NoFlags && + (typeof ctor.getDerivedStateFromError === "function" || + (instance !== null && + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance))) + ) { + workInProgress.flags |= ShouldCapture; - console["error"](error); // Don't transform to our wrapper - // For a more detailed description of this block, see: - // https://github.com/facebook/react/pull/13384 - } + var _lane = pickArbitraryLane(rootRenderLanes); - var componentNameMessage = componentName - ? "The above error occurred in the <" + componentName + "> component:" - : "The above error occurred in one of your React components:"; - var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. + workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - if (errorBoundaryFound && errorBoundaryName) { - if (willRetry) { - errorBoundaryMessage = - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + errorBoundaryName + "."); - } else { - errorBoundaryMessage = - "This error was initially handled by the error boundary " + - errorBoundaryName + - ".\n" + - "Recreating the tree from scratch failed so React will unmount the tree."; - } - } else { - 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."; - } + var _update2 = createClassErrorUpdate( + workInProgress, + errorInfo, + _lane + ); - var combinedMessage = - "" + - componentNameMessage + - componentStack + - "\n\n" + - ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. - // We don't include the original error message and JS stack because the browser - // has already printed it. Even if the application swallows the error, it is still - // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. + enqueueCapturedUpdate(workInProgress, _update2); + return; + } - console["error"](combinedMessage); // Don't transform to our wrapper - } + break; + } + + workInProgress = workInProgress.return; + } while (workInProgress !== null); } var didWarnAboutUndefinedSnapshotBeforeUpdate = null; @@ -15191,54 +16060,14 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null; } var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; -function logError(boundary, errorInfo) { - var source = errorInfo.source; - var stack = errorInfo.stack; - - if (stack === null && source !== null) { - stack = getStackByFiberInDevAndProd(source); - } - - var capturedError = { - componentName: source !== null ? getComponentName(source.type) : null, - componentStack: stack !== null ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: false, - willRetry: false - }; - - if (boundary !== null && boundary.tag === ClassComponent) { - capturedError.errorBoundary = boundary.stateNode; - capturedError.errorBoundaryName = getComponentName(boundary.type); - capturedError.errorBoundaryFound = true; - capturedError.willRetry = true; - } - - try { - logCapturedError(capturedError); - } catch (e) { - // This method must not throw, or React internal state will get messed up. - // If console.error is overridden, or logCapturedError() shows a dialog that throws, - // we want to report this error outside of the normal stack as a last resort. - // https://github.com/facebook/react/issues/13188 - setTimeout(function() { - throw e; - }); - } -} var callComponentWillUnmountWithTimer = function(current, instance) { - startPhaseTimer(current, "componentWillUnmount"); instance.props = current.memoizedProps; instance.state = current.memoizedState; { instance.componentWillUnmount(); } - - stopPhaseTimer(); }; // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount(current, instance) { @@ -15264,7 +16093,9 @@ function safelyDetachRef(current) { if (ref !== null) { if (typeof ref === "function") { { - invokeGuardedCallback(null, ref, null, null); + { + invokeGuardedCallback(null, ref, null, null); + } if (hasCaughtError()) { var refError = clearCaughtError(); @@ -15298,11 +16129,10 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } case ClassComponent: { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; - startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate"); var instance = finishedWork.stateNode; // We could update instance props and state here, // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. @@ -15358,14 +16188,16 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } instance.__reactInternalSnapshotBeforeUpdate = snapshot; - stopPhaseTimer(); } } return; } - case HostRoot: + case HostRoot: { + return; + } + case HostComponent: case HostText: case HostPortal: @@ -15442,16 +16274,15 @@ function commitHookEffectListMount(tag, finishedWork) { " }\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"; + "Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching"; } else { addendum = " You returned: " + destroy; } error( "An effect function must not return anything besides a function, " + - "which is used for clean-up.%s%s", - addendum, - getStackByFiberInDevAndProd(finishedWork) + "which is used for clean-up.%s", + addendum ); } } @@ -15462,33 +16293,30 @@ function commitHookEffectListMount(tag, finishedWork) { } } -function commitPassiveHookEffects(finishedWork) { - if ((finishedWork.effectTag & Passive) !== NoEffect) { - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: - case Block: { - // TODO (#17945) We should call all passive destroy functions (for all fibers) - // before calling any create functions. The current approach only serializes - // these for a single fiber. - { - commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork); - commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); - } +function schedulePassiveEffects(finishedWork) { + var updateQueue = finishedWork.updateQueue; + var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; - break; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + + do { + var _effect = effect, + next = _effect.next, + tag = _effect.tag; + + if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); + enqueuePendingPassiveHookEffectMount(finishedWork, effect); } - } + + effect = next; + } while (effect !== firstEffect); } } -function commitLifeCycles( - finishedRoot, - current, - finishedWork, - committedExpirationTime -) { +function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: @@ -15502,18 +16330,18 @@ function commitLifeCycles( commitHookEffectListMount(Layout | HasEffect, finishedWork); } + schedulePassiveEffects(finishedWork); return; } case ClassComponent: { var instance = finishedWork.stateNode; - if (finishedWork.effectTag & Update) { + if (finishedWork.flags & Update) { if (current === null) { - startPhaseTimer(finishedWork, "componentDidMount"); // We could update instance props and state here, + // We could update instance props and state here, // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. - { if ( finishedWork.type === finishedWork.elementType && @@ -15546,15 +16374,12 @@ function commitLifeCycles( { instance.componentDidMount(); } - - stopPhaseTimer(); } else { var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); - var prevState = current.memoizedState; - startPhaseTimer(finishedWork, "componentDidUpdate"); // We could update instance props and state here, + var prevState = current.memoizedState; // We could update instance props and state here, // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. @@ -15594,10 +16419,9 @@ function commitLifeCycles( instance.__reactInternalSnapshotBeforeUpdate ); } - - stopPhaseTimer(); } - } + } // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. var updateQueue = finishedWork.updateQueue; @@ -15640,6 +16464,8 @@ function commitLifeCycles( } case HostRoot: { + // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. var _updateQueue = finishedWork.updateQueue; if (_updateQueue !== null) { @@ -15669,7 +16495,7 @@ function commitLifeCycles( // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. - if (current === null && finishedWork.effectTag & Update) { + if (current === null && finishedWork.flags & Update) { var type = finishedWork.type; var props = finishedWork.memoizedProps; commitMount(); @@ -15722,6 +16548,8 @@ function commitLifeCycles( case IncompleteClassComponent: case FundamentalComponent: case ScopeComponent: + case OffscreenComponent: + case LegacyHiddenComponent: return; } @@ -15749,15 +16577,16 @@ function commitAttachRef(finishedWork) { } // Moved outside to ensure DCE works with this flag if (typeof ref === "function") { - ref(instanceToUse); + { + ref(instanceToUse); + } } else { { if (!ref.hasOwnProperty("current")) { error( "Unexpected ref object provided for %s. " + - "Use either a ref-setter function or React.createRef().%s", - getComponentName(finishedWork.type), - getStackByFiberInDevAndProd(finishedWork) + "Use either a ref-setter function or React.createRef().", + getComponentName(finishedWork.type) ); } } @@ -15772,7 +16601,9 @@ function commitDetachRef(current) { if (currentRef !== null) { if (typeof currentRef === "function") { - currentRef(null); + { + currentRef(null); + } } else { currentRef.current = null; } @@ -15797,42 +16628,25 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { if (lastEffect !== null) { var firstEffect = lastEffect.next; + var effect = firstEffect; - { - // When the owner fiber is deleted, the destroy function of a passive - // effect hook is called during the synchronous commit phase. This is - // a concession to implementation complexity. Calling it in the - // passive effect phase (like they usually are, when dependencies - // change during an update) would require either traversing the - // children of the deleted fiber again, or including unmount effects - // as part of the fiber effect list. - // - // Because this is during the sync commit phase, we need to change - // the priority. - // - // TODO: Reconsider this implementation trade off. - var priorityLevel = - renderPriorityLevel > NormalPriority - ? NormalPriority - : renderPriorityLevel; - runWithPriority(priorityLevel, function() { - var effect = firstEffect; - - do { - var _effect3 = effect, - _destroy = _effect3.destroy, - _tag = _effect3.tag; - - if (_destroy !== undefined) { - { - safelyCallDestroy(current, _destroy); - } + do { + var _effect2 = effect, + destroy = _effect2.destroy, + tag = _effect2.tag; + + if (destroy !== undefined) { + if ((tag & Passive$1) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(current, effect); + } else { + { + safelyCallDestroy(current, destroy); } + } + } - effect = effect.next; - } while (effect !== firstEffect); - }); - } + effect = effect.next; + } while (effect !== firstEffect); } } @@ -15889,7 +16703,7 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { var node = root; while (true) { - commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes. + commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes. // Skip portals because commitUnmount() currently visits them recursively. if ( @@ -15904,506 +16718,222 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { if (node === root) { return; - } - - while (node.sibling === null) { - if (node.return === null || node.return === root) { - return; - } - - node = node.return; - } - - node.sibling.return = node.return; - node = node.sibling; - } -} - -function detachFiber(current) { - var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we - // should clear the child pointer of the parent alternate to let this - // get GC:ed but we don't know which for sure which parent is the current - // one so we'll settle for GC:ing the subtree of this child. This child - // itself will be GC:ed when the parent updates the next time. - - current.return = null; - current.child = null; - current.memoizedState = null; - current.updateQueue = null; - current.dependencies = null; - current.alternate = null; - current.firstEffect = null; - current.lastEffect = null; - current.pendingProps = null; - current.memoizedProps = null; - current.stateNode = null; - - if (alternate !== null) { - detachFiber(alternate); - } -} - -function emptyPortalContainer(current) { - var portal = current.stateNode; - var containerInfo = portal.containerInfo; - var emptyChildSet = createContainerChildSet(containerInfo); -} - -function commitContainer(finishedWork) { - switch (finishedWork.tag) { - case ClassComponent: - case HostComponent: - case HostText: - case FundamentalComponent: { - return; - } - - case HostRoot: - case HostPortal: { - var portalOrRoot = finishedWork.stateNode; - var containerInfo = portalOrRoot.containerInfo, - pendingChildren = portalOrRoot.pendingChildren; - return; - } - } - - { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } -} - -function commitDeletion(finishedRoot, current, renderPriorityLevel) { - { - // Detach refs and call componentWillUnmount() on the whole subtree. - commitNestedUnmounts(finishedRoot, current, renderPriorityLevel); - } - - detachFiber(current); -} - -function commitWork(current, finishedWork) { - { - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case MemoComponent: - case SimpleMemoComponent: - case Block: { - // Layout effects are destroyed during the mutation phase so that all - // destroy functions for all fibers are called before any create functions. - // This prevents sibling component effects from interfering with each other, - // e.g. a destroy function in one component should never override a ref set - // by a create function in another component during the same commit. - { - commitHookEffectListUnmount(Layout | HasEffect, finishedWork); - } - - return; - } - - case Profiler: { - return; - } - - case SuspenseComponent: { - commitSuspenseComponent(finishedWork); - attachSuspenseRetryListeners(finishedWork); - return; - } - - case SuspenseListComponent: { - attachSuspenseRetryListeners(finishedWork); - return; - } - } - - commitContainer(finishedWork); - return; - } -} - -function commitSuspenseComponent(finishedWork) { - var newState = finishedWork.memoizedState; - var primaryChildParent = finishedWork; - - if (newState === null); - else { - primaryChildParent = finishedWork.child; - markCommitTimeOfFallback(); - } -} - -function attachSuspenseRetryListeners(finishedWork) { - // If this boundary just timed out, then it will have a set of thenables. - // For each thenable, attach a listener so that when it resolves, React - // attempts to re-render the boundary in the primary (pre-timeout) state. - var thenables = finishedWork.updateQueue; - - if (thenables !== null) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - - if (retryCache === null) { - retryCache = finishedWork.stateNode = new PossiblyWeakSet(); - } - - thenables.forEach(function(thenable) { - // Memoize using the boundary fiber to prevent redundant listeners. - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - - if (!retryCache.has(thenable)) { - { - if (thenable.__reactDoNotTraceInteractions !== true) { - retry = tracing.unstable_wrap(retry); - } - } - - retryCache.add(thenable); - thenable.then(retry, retry); - } - }); - } -} - -var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; - -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - var update = createUpdate(expirationTime, null); // Unmount the root by rendering null. - - update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property - // being called "element". - - update.payload = { - element: null - }; - var error = errorInfo.value; - - update.callback = function() { - onUncaughtError(error); - logError(fiber, errorInfo); - }; - - return update; -} - -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - var update = createUpdate(expirationTime, null); - update.tag = CaptureUpdate; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - - if (typeof getDerivedStateFromError === "function") { - var error$1 = errorInfo.value; - - update.payload = function() { - logError(fiber, errorInfo); - return getDerivedStateFromError(error$1); - }; - } - - var inst = fiber.stateNode; - - if (inst !== null && typeof inst.componentDidCatch === "function") { - update.callback = function callback() { - { - markFailedErrorBoundaryForHotReloading(fiber); - } - - if (typeof getDerivedStateFromError !== "function") { - // To preserve the preexisting retry behavior of error boundaries, - // we keep track of which ones already failed during this batch. - // This gets reset before we yield back to the browser. - // TODO: Warn in strict mode if getDerivedStateFromError is - // not defined. - markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined + } - logError(fiber, errorInfo); + while (node.sibling === null) { + if (node.return === null || node.return === root) { + return; } - var error$1 = errorInfo.value; - var stack = errorInfo.stack; - this.componentDidCatch(error$1, { - componentStack: stack !== null ? stack : "" - }); + node = node.return; + } - { - if (typeof getDerivedStateFromError !== "function") { - // If componentDidCatch is the only error boundary method defined, - // then it needs to call setState to recover from errors. - // If no state update is scheduled then the boundary will swallow the error. - if (fiber.expirationTime !== Sync) { - error( - "%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" - ); - } - } - } - }; - } else { - update.callback = function() { - markFailedErrorBoundaryForHotReloading(fiber); - }; + node.sibling.return = node.return; + node = node.sibling; } +} - return update; +function detachFiberMutation(fiber) { + // Cut off the return pointers to disconnect it from the tree. Ideally, we + // should clear the child pointer of the parent alternate to let this + // get GC:ed but we don't know which for sure which parent is the current + // one so we'll settle for GC:ing the subtree of this child. This child + // itself will be GC:ed when the parent updates the next time. + // Note: we cannot null out sibling here, otherwise it can cause issues + // with findDOMNode and how it requires the sibling field to carry out + // traversal in a later effect. See PR #16820. We now clear the sibling + // field after effects, see: detachFiberAfterEffects. + // + // Don't disconnect stateNode now; it will be detached in detachFiberAfterEffects. + // It may be required if the current component is an error boundary, + // and one of its descendants throws while unmounting a passive effect. + fiber.alternate = null; + fiber.child = null; + fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.return = null; + fiber.updateQueue = null; + + { + fiber._debugOwner = null; + } } -function attachPingListener(root, renderExpirationTime, thenable) { - // Attach a listener to the promise to "ping" the root and retry. But - // only if one does not already exist for the current render expiration - // time (which acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs; +function emptyPortalContainer(current) { + var portal = current.stateNode; + var containerInfo = portal.containerInfo; + var emptyChildSet = createContainerChildSet(containerInfo); +} - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap(); - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); - } else { - threadIDs = pingCache.get(thenable); +function commitContainer(finishedWork) { + switch (finishedWork.tag) { + case ClassComponent: + case HostComponent: + case HostText: + case FundamentalComponent: { + return; + } - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); + case HostRoot: + case HostPortal: { + var portalOrRoot = finishedWork.stateNode; + var containerInfo = portalOrRoot.containerInfo, + pendingChildren = portalOrRoot.pendingChildren; + return; } } - if (!threadIDs.has(renderExpirationTime)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(renderExpirationTime); - var ping = pingSuspendedRoot.bind( - null, - root, - thenable, - renderExpirationTime + { + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); - thenable.then(ping, ping); } } -function throwException( - root, - returnFiber, - sourceFiber, - value, - renderExpirationTime -) { - // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. +function commitDeletion(finishedRoot, current, renderPriorityLevel) { + { + // Detach refs and call componentWillUnmount() on the whole subtree. + commitNestedUnmounts(finishedRoot, current); + } - sourceFiber.firstEffect = sourceFiber.lastEffect = null; + var alternate = current.alternate; + detachFiberMutation(current); - if ( - value !== null && - typeof value === "object" && - typeof value.then === "function" - ) { - // This is a thenable. - var thenable = value; + if (alternate !== null) { + detachFiberMutation(alternate); + } +} - if ((sourceFiber.mode & BlockingMode) === NoMode) { - // Reset the memoizedState to what it was before we attempted - // to render it. - var currentSource = sourceFiber.alternate; +function commitWork(current, finishedWork) { + { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: + case Block: { + // Layout effects are destroyed during the mutation phase so that all + // destroy functions for all fibers are called before any create functions. + // This prevents sibling component effects from interfering with each other, + // e.g. a destroy function in one component should never override a ref set + // by a create function in another component during the same commit. + { + commitHookEffectListUnmount(Layout | HasEffect, finishedWork); + } - if (currentSource) { - sourceFiber.updateQueue = currentSource.updateQueue; - sourceFiber.memoizedState = currentSource.memoizedState; - sourceFiber.expirationTime = currentSource.expirationTime; - } else { - sourceFiber.updateQueue = null; - sourceFiber.memoizedState = null; + return; } - } - - var hasInvisibleParentBoundary = hasSuspenseContext( - suspenseStackCursor.current, - InvisibleParentSuspenseContext - ); // Schedule the nearest Suspense to re-render the timed out view. - - var _workInProgress = returnFiber; - - do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) - ) { - // Found the nearest boundary. - // Stash the promise on the boundary fiber. If the boundary times out, we'll - // attach another listener to flip the boundary back to its normal state. - var thenables = _workInProgress.updateQueue; - if (thenables === null) { - var updateQueue = new Set(); - updateQueue.add(thenable); - _workInProgress.updateQueue = updateQueue; - } else { - thenables.add(thenable); - } // If the boundary is outside of blocking mode, we should *not* - // suspend the commit. Pretend as if the suspended component rendered - // null and keep rendering. In the commit phase, we'll schedule a - // subsequent synchronous update to re-render the Suspense. - // - // Note: It doesn't matter whether the component that suspended was - // inside a blocking mode tree. If the Suspense is outside of it, we - // should *not* suspend the commit. + case Profiler: { + return; + } - if ((_workInProgress.mode & BlockingMode) === NoMode) { - _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. - // But we shouldn't call any lifecycle methods or callbacks. Remove - // all lifecycle effect tags. + case SuspenseComponent: { + commitSuspenseComponent(finishedWork); + attachSuspenseRetryListeners(finishedWork); + return; + } - sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); + case SuspenseListComponent: { + attachSuspenseRetryListeners(finishedWork); + return; + } - if (sourceFiber.tag === ClassComponent) { - var currentSourceFiber = sourceFiber.alternate; + case HostRoot: { + break; + } - if (currentSourceFiber === null) { - // This is a new mount. Change the tag so it's not mistaken for a - // completed class component. For example, we should not call - // componentWillUnmount if it is deleted. - sourceFiber.tag = IncompleteClassComponent; - } else { - // When we try rendering again, we should not reuse the current fiber, - // since it's known to be in an inconsistent state. Use a force update to - // prevent a bail out. - var update = createUpdate(Sync, null); - update.tag = ForceUpdate; - enqueueUpdate(sourceFiber, update); - } - } // The source fiber did not complete. Mark it with Sync priority to - // indicate that it still has pending work. + case OffscreenComponent: + case LegacyHiddenComponent: { + return; + } + } - sourceFiber.expirationTime = Sync; // Exit without suspending. + commitContainer(finishedWork); + return; + } +} - return; - } // Confirmed that the boundary is in a concurrent mode tree. Continue - // with the normal suspend path. - // - // After this we'll use a set of heuristics to determine whether this - // render pass will run to completion or restart or "suspend" the commit. - // The actual logic for this is spread out in different places. - // - // This first principle is that if we're going to suspend when we complete - // a root, then we should also restart if we get an update or ping that - // might unsuspend it, and vice versa. The only reason to suspend is - // because you think you might want to restart before committing. However, - // it doesn't make sense to restart only while in the period we're suspended. - // - // Restarting too aggressively is also not good because it starves out any - // intermediate loading state. So we use heuristics to determine when. - // Suspense Heuristics - // - // If nothing threw a Promise or all the same fallbacks are already showing, - // then don't suspend/restart. - // - // If this is an initial render of a new tree of Suspense boundaries and - // those trigger a fallback, then don't suspend/restart. We want to ensure - // that we can show the initial loading state as quickly as possible. - // - // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. - // - // If we're already showing a fallback and it gets "retried", allowing us to show - // another level, but there's still an inner boundary that would show a fallback, - // then we suspend/restart for 500ms since the last time we showed a fallback - // anywhere in the tree. This effectively throttles progressive loading into a - // consistent train of commits. This also gives us an opportunity to restart to - // get to the completed state slightly earlier. - // - // If there's ambiguity due to batching it's resolved in preference of: - // 1) "delayed", 2) "initial render", 3) "retry". - // - // We want to ensure that a "busy" state doesn't get force committed. We want to - // ensure that new initial loading states can commit as soon as possible. +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; - attachPingListener(root, renderExpirationTime, thenable); - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.expirationTime = renderExpirationTime; - return; - } // This boundary already captured during this render. Continue to the next - // boundary. + if (newState !== null) { + markCommitTimeOfFallback(); + } +} - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. - // TODO: Use invariant so the message is stripped in prod? +function attachSuspenseRetryListeners(finishedWork) { + // If this boundary just timed out, then it will have a set of wakeables. + // For each wakeable, attach a listener so that when it resolves, React + // attempts to re-render the boundary in the primary (pre-timeout) state. + var wakeables = finishedWork.updateQueue; - value = new Error( - (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n" + - "\n" + - "Add a component higher in the tree to " + - "provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) - ); - } // We didn't find a boundary that could handle this type of exception. Start - // over and traverse parent path again, this time treating the exception - // as an error. + if (wakeables !== null) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; - renderDidError(); - value = createCapturedValue(value, sourceFiber); - var workInProgress = returnFiber; + if (retryCache === null) { + retryCache = finishedWork.stateNode = new PossiblyWeakSet(); + } - do { - switch (workInProgress.tag) { - case HostRoot: { - var _errorInfo = value; - workInProgress.effectTag |= ShouldCapture; - workInProgress.expirationTime = renderExpirationTime; + wakeables.forEach(function(wakeable) { + // Memoize using the boundary fiber to prevent redundant listeners. + var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); - var _update = createRootErrorUpdate( - workInProgress, - _errorInfo, - renderExpirationTime - ); + if (!retryCache.has(wakeable)) { + { + if (wakeable.__reactDoNotTraceInteractions !== true) { + retry = tracing.unstable_wrap(retry); + } + } - enqueueCapturedUpdate(workInProgress, _update); - return; + retryCache.add(wakeable); + wakeable.then(retry, retry); } + }); + } +} // This function detects when a Suspense boundary goes from visible to hidden. +// It returns false if the boundary is already hidden. +// TODO: Use an effect tag. - case ClassComponent: - // Capture and retry - var errorInfo = value; - var ctor = workInProgress.type; - var instance = workInProgress.stateNode; - - if ( - (workInProgress.effectTag & DidCapture) === NoEffect && - (typeof ctor.getDerivedStateFromError === "function" || - (instance !== null && - typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance))) - ) { - workInProgress.effectTag |= ShouldCapture; - workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state +function isSuspenseBoundaryBeingHidden(current, finishedWork) { + if (current !== null) { + var oldState = current.memoizedState; - var _update2 = createClassErrorUpdate( - workInProgress, - errorInfo, - renderExpirationTime - ); + if (oldState === null || oldState.dehydrated !== null) { + var newState = finishedWork.memoizedState; + return newState !== null && newState.dehydrated === null; + } + } - enqueueCapturedUpdate(workInProgress, _update2); - return; - } + return false; +} - break; - } +var COMPONENT_TYPE = 0; +var HAS_PSEUDO_CLASS_TYPE = 1; +var ROLE_TYPE = 2; +var TEST_NAME_TYPE = 3; +var TEXT_TYPE = 4; - workInProgress = workInProgress.return; - } while (workInProgress !== null); +if (typeof Symbol === "function" && Symbol.for) { + var symbolFor$1 = Symbol.for; + COMPONENT_TYPE = symbolFor$1("selector.component"); + HAS_PSEUDO_CLASS_TYPE = symbolFor$1("selector.has_pseudo_class"); + ROLE_TYPE = symbolFor$1("selector.role"); + TEST_NAME_TYPE = symbolFor$1("selector.test_id"); + TEXT_TYPE = symbolFor$1("selector.text"); } var ceil = Math.ceil; -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; var NoContext = - /* */ + /* */ 0; var BatchedContext = /* */ @@ -16420,2608 +16950,3026 @@ var RenderContext = var CommitContext = /* */ 32; +var RetryAfterError = + /* */ + 64; var RootIncomplete = 0; var RootFatalErrored = 1; var RootErrored = 2; var RootSuspended = 3; var RootSuspendedWithDelay = 4; -var RootCompleted = 5; -// Describes where we are in the React execution stack +var RootCompleted = 5; // Describes where we are in the React execution stack + var executionContext = NoContext; // The root we're working on var workInProgressRoot = null; // The fiber we're working on -var workInProgress = null; // The expiration time we're rendering +var workInProgress = null; // The lanes we're rendering + +var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree +// This is a superset of the lanes we started working on at the root. The only +// case where it's different from `workInProgressRootRenderLanes` is when we +// enter a subtree that is hidden and needs to be unhidden: Suspense and +// Offscreen component. +// +// Most things in the work loop should deal with workInProgressRootRenderLanes. +// Most things in begin/complete phases should deal with subtreeRenderLanes. -var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc. +var subtreeRenderLanes = NoLanes; +var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown -var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render. -// This is conceptually a time stamp but expressed in terms of an ExpirationTime -// because we deal mostly with expiration times in the hot path, so this avoids -// the conversion happening in the hot path. +var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's +// slightly different than `renderLanes` because `renderLanes` can change as you +// enter and exit an Offscreen tree. This value is the combination of all render +// lanes for the entire render phase. -var workInProgressRootLatestProcessedExpirationTime = Sync; -var workInProgressRootLatestSuspenseTimeout = Sync; -var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only +var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only // includes unprocessed updates, not work in bailed out children. -var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately. -// This flag determines if it might be worthwhile to restart if an opportunity -// happens latere. +var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. + +var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. + +var workInProgressRootPingedLanes = NoLanes; +var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train +// model where we don't commit new loading states in too quick succession. + +var globalMostRecentFallbackTime = 0; +var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering +// more and prefer CPU suspense heuristics instead. + +var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU +// suspense heuristics and opt out of rendering more content. + +var RENDER_TIMEOUT_MS = 500; + +function resetRenderTimer() { + workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS; +} + +function getRenderTargetTime() { + return workInProgressRootRenderTargetTime; +} +var nextEffect = null; +var hasUncaughtError = false; +var firstUncaughtError = null; +var legacyErrorBoundariesThatAlreadyFailed = null; +var rootDoesHavePassiveEffects = false; +var rootWithPendingPassiveEffects = null; +var pendingPassiveEffectsRenderPriority = NoPriority$1; +var pendingPassiveEffectsLanes = NoLanes; +var pendingPassiveHookEffectsMount = []; +var pendingPassiveHookEffectsUnmount = []; +var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates + +var NESTED_UPDATE_LIMIT = 50; +var nestedUpdateCount = 0; +var rootWithNestedUpdates = null; +var NESTED_PASSIVE_UPDATE_LIMIT = 50; +var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes +// during the commit phase. This enables them to be traced across components +// that spawn new work during render. E.g. hidden boundaries, suspended SSR +// hydration or SuspenseList. +// TODO: Can use a bitmask instead of an array + +var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their +// event times as simultaneous, even if the actual clock time has advanced +// between the first and second call. + +var currentEventTime = NoTimestamp; +var currentEventWipLanes = NoLanes; +var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. +// We warn about state updates for unmounted components differently in this case. + +var isFlushingPassiveEffects = false; +var focusedInstanceHandle = null; +var shouldFireAfterActiveInstanceBlur = false; +function getWorkInProgressRoot() { + return workInProgressRoot; +} +function requestEventTime() { + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + // We're inside React, so it's fine to read the actual time. + return now(); + } // We're not inside React, so we may be in the middle of a browser event. + + if (currentEventTime !== NoTimestamp) { + // Use the same start time for all updates until we enter React again. + return currentEventTime; + } // This is the first update since React yielded. Compute a new start time. + + currentEventTime = now(); + return currentEventTime; +} +function requestUpdateLane(fiber) { + // Special cases + var mode = fiber.mode; + + if ((mode & BlockingMode) === NoMode) { + return SyncLane; + } else if ((mode & ConcurrentMode) === NoMode) { + return getCurrentPriorityLevel() === ImmediatePriority$1 + ? SyncLane + : SyncBatchedLane; + } // The algorithm for assigning an update to a lane should be stable for all + // updates at the same priority within the same event. To do this, the inputs + // to the algorithm must be the same. For example, we use the `renderLanes` + // to avoid choosing a lane that is already in the middle of rendering. + // + // However, the "included" lanes could be mutated in between updates in the + // same event, like if you perform an update inside `flushSync`. Or any other + // code path that might call `prepareFreshStack`. + // + // The trick we use is to cache the first of each of these inputs within an + // event. Then reset the cached values once we can be sure the event is over. + // Our heuristic for that is whenever we enter a concurrent work loop. + // + // We'll do the same for `currentEventPendingLanes` below. + + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; + } + + var isTransition = requestCurrentTransition() !== NoTransition; + + if (isTransition) { + if (currentEventPendingLanes !== NoLanes) { + currentEventPendingLanes = + mostRecentlyUpdatedRoot !== null + ? mostRecentlyUpdatedRoot.pendingLanes + : NoLanes; + } + + return findTransitionLane(currentEventWipLanes, currentEventPendingLanes); + } // TODO: Remove this dependency on the Scheduler priority. + // To do that, we're replacing it with an update lane priority. + + var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler. + // This couples React to the Scheduler internals, so we're replacing it + // with the currentUpdateLanePriority above. As an example of how this + // could be problematic, if we're not inside `Scheduler.runWithPriority`, + // then we'll get the priority of the current running Scheduler task, + // which is probably not what we want. + + var lane; + + if ( + // TODO: Temporary. We're removing the concept of discrete updates. + (executionContext & DiscreteEventContext) !== NoContext && + schedulerPriority === UserBlockingPriority$1 + ) { + lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); + } else { + var schedulerLanePriority = schedulerPriorityToLanePriority( + schedulerPriority + ); + + lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); + } + + return lane; +} + +function requestRetryLane(fiber) { + // This is a fork of `requestUpdateLane` designed specifically for Suspense + // "retries" — a special update that attempts to flip a Suspense boundary + // from its placeholder state to its primary/resolved state. + // Special cases + var mode = fiber.mode; + + if ((mode & BlockingMode) === NoMode) { + return SyncLane; + } else if ((mode & ConcurrentMode) === NoMode) { + return getCurrentPriorityLevel() === ImmediatePriority$1 + ? SyncLane + : SyncBatchedLane; + } // See `requestUpdateLane` for explanation of `currentEventWipLanes` + + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; + } + + return findRetryLane(currentEventWipLanes); +} + +function scheduleUpdateOnFiber(fiber, lane, eventTime) { + checkForNestedUpdates(); + warnAboutRenderPhaseUpdatesInDEV(fiber); + var root = markUpdateLaneFromFiberToRoot(fiber, lane); + + if (root === null) { + warnAboutUpdateOnUnmountedFiberInDEV(fiber); + return null; + } // Mark that the root has a pending update. + + markRootUpdated(root, lane, eventTime); + + if (root === workInProgressRoot) { + // Received an update to a tree that's in the middle of rendering. Mark + // that there was an interleaved update work on this root. Unless the + // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render + // phase update. In that case, we don't treat render phase updates as if + // they were interleaved, for backwards compat reasons. + { + workInProgressRootUpdatedLanes = mergeLanes( + workInProgressRootUpdatedLanes, + lane + ); + } + + if (workInProgressRootExitStatus === RootSuspendedWithDelay) { + // The root already suspended with a delay, which means this render + // definitely won't finish. Since we have a new update, let's mark it as + // suspended now, right before marking the incoming update. This has the + // effect of interrupting the current render and switching to the update. + // TODO: Make sure this doesn't override pings that happen while we've + // already started rendering. + markRootSuspended$1(root, workInProgressRootRenderLanes); + } + } // TODO: requestUpdateLanePriority also reads the priority. Pass the + // priority as an argument to that function and this one. + + var priorityLevel = getCurrentPriorityLevel(); + + if (lane === SyncLane) { + if ( + // Check if we're inside unbatchedUpdates + (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering + (executionContext & (RenderContext | CommitContext)) === NoContext + ) { + // Register pending interactions on the root to avoid losing traced interaction data. + schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + // root inside of batchedUpdates should be synchronous, but layout updates + // should be deferred until the end of the batch. + + performSyncWorkOnRoot(root); + } else { + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, lane); + + if (executionContext === NoContext) { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncCallbackQueue(); + } + } + } else { + // Schedule a discrete update but only if it's not Sync. + if ( + (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered + // discrete, even inside a discrete event. + (priorityLevel === UserBlockingPriority$1 || + priorityLevel === ImmediatePriority$1) + ) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Set([root]); + } else { + rootsWithPendingDiscreteUpdates.add(root); + } + } // Schedule other updates after in case the callback is sync. + + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, lane); + } // We use this when assigning a lane for a transition inside + // `requestUpdateLane`. We assume it's the same as the root being updated, + // since in the common case of a single root app it probably is. If it's not + // the same root, then it's not a huge deal, we just might batch more stuff + // together more than necessary. + + mostRecentlyUpdatedRoot = root; +} // This is split into a separate function so we can mark a fiber with pending +// work without treating it as a typical update that originates from an event; +// e.g. retrying a Suspense boundary isn't an update, but it does schedule work +// on a fiber. + +function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + // Update the source fiber's lanes + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); + var alternate = sourceFiber.alternate; + + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); + } + + { + if ( + alternate === null && + (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags + ) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); + } + } // Walk the parent path to the root and update the child expiration time. + + var node = sourceFiber; + var parent = sourceFiber.return; + + while (parent !== null) { + parent.childLanes = mergeLanes(parent.childLanes, lane); + alternate = parent.alternate; + + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, lane); + } else { + { + if ((parent.flags & (Placement | Hydrating)) !== NoFlags) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); + } + } + } + + node = parent; + parent = parent.return; + } + + if (node.tag === HostRoot) { + var root = node.stateNode; + return root; + } else { + return null; + } +} // Use this function to schedule a task for a root. There's only one task per +// root; if a task was already scheduled, we'll check to make sure the priority +// of the existing task is the same as the priority of the next level that the +// root has work on. This function is called on every update, and right before +// exiting a task. + +function ensureRootIsScheduled(root, currentTime) { + var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); // This returns the priority level computed during the `getNextLanes` call. + + var newCallbackPriority = returnNextLanesPriority(); + + if (nextLanes === NoLanes) { + // Special case: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + root.callbackNode = null; + root.callbackPriority = NoLanePriority; + } + + return; + } // Check if there's an existing task. We may be able to reuse it. + + if (existingCallbackNode !== null) { + var existingCallbackPriority = root.callbackPriority; + + if (existingCallbackPriority === newCallbackPriority) { + // The priority hasn't changed. We can reuse the existing task. Exit. + return; + } // The priority changed. Cancel the existing callback. We'll schedule a new + // one below. + + cancelCallback(existingCallbackNode); + } // Schedule a new callback. + + var newCallbackNode; + + if (newCallbackPriority === SyncLanePriority) { + // Special case: Sync React callbacks are scheduled on a special + // internal queue + newCallbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + ); + } else if (newCallbackPriority === SyncBatchedLanePriority) { + newCallbackNode = scheduleCallback( + ImmediatePriority$1, + performSyncWorkOnRoot.bind(null, root) + ); + } else { + var schedulerPriorityLevel = lanePriorityToSchedulerPriority( + newCallbackPriority + ); + newCallbackNode = scheduleCallback( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + } + + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; +} // This is the entry point for every concurrent task, i.e. anything that +// goes through Scheduler. + +function performConcurrentWorkOnRoot(root) { + // Since we know we're in a React event, we can clear the current + // event time. The next update will compute a new event time. + currentEventTime = NoTimestamp; + currentEventWipLanes = NoLanes; + currentEventPendingLanes = NoLanes; + + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } // Flush any pending passive effects before deciding which lanes to work on, + // in case they schedule additional work. + + var originalCallbackNode = root.callbackNode; + var didFlushPassiveEffects = flushPassiveEffects(); + + if (didFlushPassiveEffects) { + // Something in the passive effect phase may have canceled the current task. + // Check if the task node for this root was changed. + if (root.callbackNode !== originalCallbackNode) { + // The current task was canceled. Exit. We don't need to call + // `ensureRootIsScheduled` because the check above implies either that + // there's a new task, or that there's no remaining work on this root. + return null; + } + } // Determine the next expiration time to work on, using the fields stored + // on the root. + + var lanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (lanes === NoLanes) { + // Defensive coding. This is never expected to happen. + return null; + } + + var exitStatus = renderRootConcurrent(root, lanes); + + if ( + includesSomeLane( + workInProgressRootIncludedLanes, + workInProgressRootUpdatedLanes + ) + ) { + // The render included lanes that were updated during the render phase. + // For example, when unhiding a hidden tree, we include all the lanes + // that were previously skipped when the tree was hidden. That set of + // lanes is a superset of the lanes we started rendering with. + // + // So we'll throw out the current work and restart. + prepareFreshStack(root, NoLanes); + } else if (exitStatus !== RootIncomplete) { + if (exitStatus === RootErrored) { + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. + + if (root.hydrate) { + root.hydrate = false; + clearContainer(root.containerInfo); + } // If something threw an error, try rendering one more time. We'll render + // synchronously to block concurrent data mutations, and we'll includes + // all pending updates are included. If it still fails after the second + // attempt, we'll give up and commit the resulting tree. -var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train -// model where we don't commit new loading states in too quick succession. + lanes = getLanesToRetrySynchronouslyOnError(root); -var globalMostRecentFallbackTime = 0; -var FALLBACK_THROTTLE_MS = 500; -var nextEffect = null; -var hasUncaughtError = false; -var firstUncaughtError = null; -var legacyErrorBoundariesThatAlreadyFailed = null; -var rootDoesHavePassiveEffects = false; -var rootWithPendingPassiveEffects = null; -var pendingPassiveEffectsRenderPriority = NoPriority; -var pendingPassiveEffectsExpirationTime = NoWork; -var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates + if (lanes !== NoLanes) { + exitStatus = renderRootSync(root, lanes); + } + } -var NESTED_UPDATE_LIMIT = 50; -var nestedUpdateCount = 0; -var rootWithNestedUpdates = null; -var NESTED_PASSIVE_UPDATE_LIMIT = 50; -var nestedPassiveUpdateCount = 0; -var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times -// during the commit phase. This enables them to be traced across components -// that spawn new work during render. E.g. hidden boundaries, suspended SSR -// hydration or SuspenseList. + if (exitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw fatalError; + } // We now have a consistent tree. The next step is either to commit it, + // or, if something suspended, wait to commit it after a timeout. -var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start -// time). However, if two updates are scheduled within the same event, we -// should treat their start times as simultaneous, even if the actual clock -// time has advanced between the first and second call. -// In other words, because expiration times determine how updates are batched, -// we want all updates of like priority that occur within the same event to -// receive the same expiration time. Otherwise we get tearing. + var finishedWork = root.current.alternate; + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + finishConcurrentRender(root, exitStatus, lanes); + } -var currentEventTime = NoWork; -function requestCurrentTimeForUpdate() { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { - // We're inside React, so it's fine to read the actual time. - return msToExpirationTime(now()); - } // We're not inside React, so we may be in the middle of a browser event. + ensureRootIsScheduled(root, now()); - if (currentEventTime !== NoWork) { - // Use the same start time for all updates until we enter React again. - return currentEventTime; - } // This is the first update since React yielded. Compute a new start time. + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } - currentEventTime = msToExpirationTime(now()); - return currentEventTime; -} -function getCurrentTime() { - return msToExpirationTime(now()); + return null; } -function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { - var mode = fiber.mode; - if ((mode & BlockingMode) === NoMode) { - return Sync; - } +function finishConcurrentRender(root, exitStatus, lanes) { + switch (exitStatus) { + case RootIncomplete: + case RootFatalErrored: { + { + throw Error("Root did not complete. This is a bug in React."); + } + } + // Flow knows about invariant, so it complains if I add a break + // statement, but eslint doesn't know about invariant, so it complains + // if I do. eslint-disable-next-line no-fallthrough - var priorityLevel = getCurrentPriorityLevel(); + case RootErrored: { + // We should have already attempted to retry this tree. If we reached + // this point, it errored again. Commit it. + commitRoot(root); + break; + } - if ((mode & ConcurrentMode) === NoMode) { - return priorityLevel === ImmediatePriority ? Sync : Batched; - } + case RootSuspended: { + markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we + // should immediately commit it or wait a bit. - if ((executionContext & RenderContext) !== NoContext) { - // Use whatever time we're already rendering - // TODO: Should there be a way to opt out, like with `runWithPriority`? - return renderExpirationTime$1; - } + if ( + includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope + !shouldForceFlushFallbacksInDEV() + ) { + // This render only included retries, no updates. Throttle committing + // retries so that we don't show too many loading states too quickly. + var msUntilTimeout = + globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. - var expirationTime; + if (msUntilTimeout > 10) { + var nextLanes = getNextLanes(root, NoLanes); - if (suspenseConfig !== null) { - // Compute an expiration time based on the Suspense timeout. - expirationTime = computeSuspenseExpiration( - currentTime, - suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION - ); - } else { - // Compute an expiration time based on the Scheduler priority. - switch (priorityLevel) { - case ImmediatePriority: - expirationTime = Sync; - break; + if (nextLanes !== NoLanes) { + // There's additional work on this root. + break; + } - case UserBlockingPriority: - // TODO: Rename this to computeUserBlockingExpiration - expirationTime = computeInteractiveExpiration(currentTime); - break; + var suspendedLanes = root.suspendedLanes; - case NormalPriority: - case LowPriority: - // TODO: Handle LowPriority - // TODO: Rename this to... something better. - expirationTime = computeAsyncExpiration(currentTime); - break; + if (!isSubsetOfLanes(suspendedLanes, lanes)) { + // We should prefer to render the fallback of at the last + // suspended level. Ping the last suspended level to try + // rendering it again. + // FIXME: What if the suspended lanes are Idle? Should not restart. + var eventTime = requestEventTime(); + markRootPinged(root, suspendedLanes); + break; + } // The render is suspended, it hasn't timed out, and there's no + // lower priority work to do. Instead of committing the fallback + // immediately, wait for more data to arrive. - case IdlePriority: - expirationTime = Idle; - break; + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + msUntilTimeout + ); + break; + } + } // The work expired. Commit immediately. - default: { - throw Error("Expected a valid priority level"); - } + commitRoot(root); + break; } - } // If we're in the middle of rendering a tree, do not update at the same - // expiration time that is already rendering. - // TODO: We shouldn't have to do this if the update is on a different root. - // Refactor computeExpirationForFiber + scheduleUpdate so we have access to - // the root when we check for this condition. - - if ( - workInProgressRoot !== null && - expirationTime === renderExpirationTime$1 - ) { - // This is a trick to move this update into a separate batch - expirationTime -= 1; - } - - return expirationTime; -} -function scheduleUpdateOnFiber(fiber, expirationTime) { - checkForNestedUpdates(); - warnAboutRenderPhaseUpdatesInDEV(fiber); - var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); - if (root === null) { - warnAboutUpdateOnUnmountedFiberInDEV(fiber); - return; - } + case RootSuspendedWithDelay: { + markRootSuspended$1(root, lanes); - checkForInterruption(fiber, expirationTime); - recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the - // priority as an argument to that function and this one. + if (includesOnlyTransitions(lanes)) { + // This is a transition, so we should exit without committing a + // placeholder and without scheduling a timeout. Delay indefinitely + // until we receive more data. + break; + } - var priorityLevel = getCurrentPriorityLevel(); + if (!shouldForceFlushFallbacksInDEV()) { + // This is not a transition, but we did trigger an avoided state. + // Schedule a placeholder to display after a short delay, using the Just + // Noticeable Difference. + // TODO: Is the JND optimization worth the added complexity? If this is + // the only reason we track the event time, then probably not. + // Consider removing. + var mostRecentEventTime = getMostRecentEventTime(root, lanes); + var eventTimeMs = mostRecentEventTime; + var timeElapsedMs = now() - eventTimeMs; - if (expirationTime === Sync) { - if ( - // Check if we're inside unbatchedUpdates - (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering - (executionContext & (RenderContext | CommitContext)) === NoContext - ) { - // Register pending interactions on the root to avoid losing traced interaction data. - schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed - // root inside of batchedUpdates should be synchronous, but layout updates - // should be deferred until the end of the batch. + var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time. - performSyncWorkOnRoot(root); - } else { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, expirationTime); + if (_msUntilTimeout > 10) { + // Instead of committing the fallback immediately, wait for more data + // to arrive. + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + _msUntilTimeout + ); + break; + } + } // Commit the placeholder. - if (executionContext === NoContext) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - flushSyncCallbackQueue(); - } + commitRoot(root); + break; } - } else { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, expirationTime); - } - if ( - (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered - // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority || - priorityLevel === ImmediatePriority) - ) { - // This is the result of a discrete event. Track the lowest priority - // discrete update per root so we can flush them early, if needed. - if (rootsWithPendingDiscreteUpdates === null) { - rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); - } else { - var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + case RootCompleted: { + // The work completed. Ready to commit. + commitRoot(root); + break; + } - if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) { - rootsWithPendingDiscreteUpdates.set(root, expirationTime); + default: { + { + throw Error("Unknown root exit status."); } } } } -var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending -// work without treating it as a typical update that originates from an event; -// e.g. retrying a Suspense boundary isn't an update, but it does schedule work -// on a fiber. -function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { - // Update the source fiber's expiration time - if (fiber.expirationTime < expirationTime) { - fiber.expirationTime = expirationTime; - } +function markRootSuspended$1(root, suspendedLanes) { + // When suspending, we should always exclude lanes that were pinged or (more + // rarely, since we try to avoid it) updated during the render phase. + // TODO: Lol maybe there's a better way to factor this besides this + // obnoxiously named function :) + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); + markRootSuspended(root, suspendedLanes); +} // This is the entry point for synchronous tasks that don't go +// through Scheduler - var alternate = fiber.alternate; +function performSyncWorkOnRoot(root) { + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } - if (alternate !== null && alternate.expirationTime < expirationTime) { - alternate.expirationTime = expirationTime; - } // Walk the parent path to the root and update the child expiration time. + flushPassiveEffects(); + var lanes; + var exitStatus; - var node = fiber.return; - var root = null; + if ( + root === workInProgressRoot && + includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes) + ) { + // There's a partial tree, and at least one of its lanes has expired. Finish + // rendering it before rendering the rest of the expired work. + lanes = workInProgressRootRenderLanes; + exitStatus = renderRootSync(root, lanes); - if (node === null && fiber.tag === HostRoot) { - root = fiber.stateNode; + if ( + includesSomeLane( + workInProgressRootIncludedLanes, + workInProgressRootUpdatedLanes + ) + ) { + // The render included lanes that were updated during the render phase. + // For example, when unhiding a hidden tree, we include all the lanes + // that were previously skipped when the tree was hidden. That set of + // lanes is a superset of the lanes we started rendering with. + // + // Note that this only happens when part of the tree is rendered + // concurrently. If the whole tree is rendered synchronously, then there + // are no interleaved events. + lanes = getNextLanes(root, lanes); + exitStatus = renderRootSync(root, lanes); + } } else { - while (node !== null) { - alternate = node.alternate; + lanes = getNextLanes(root, NoLanes); + exitStatus = renderRootSync(root, lanes); + } - if (node.childExpirationTime < expirationTime) { - node.childExpirationTime = expirationTime; + if (root.tag !== LegacyRoot && exitStatus === RootErrored) { + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. - if ( - alternate !== null && - alternate.childExpirationTime < expirationTime - ) { - alternate.childExpirationTime = expirationTime; - } - } else if ( - alternate !== null && - alternate.childExpirationTime < expirationTime - ) { - alternate.childExpirationTime = expirationTime; - } + if (root.hydrate) { + root.hydrate = false; + clearContainer(root.containerInfo); + } // If something threw an error, try rendering one more time. We'll render + // synchronously to block concurrent data mutations, and we'll includes + // all pending updates are included. If it still fails after the second + // attempt, we'll give up and commit the resulting tree. - if (node.return === null && node.tag === HostRoot) { - root = node.stateNode; - break; - } + lanes = getLanesToRetrySynchronouslyOnError(root); - node = node.return; + if (lanes !== NoLanes) { + exitStatus = renderRootSync(root, lanes); } } - if (root !== null) { - if (workInProgressRoot === root) { - // Received an update to a tree that's in the middle of rendering. Mark - // that's unprocessed work on this root. - markUnprocessedUpdateTime(expirationTime); - - if (workInProgressRootExitStatus === RootSuspendedWithDelay) { - // The root already suspended with a delay, which means this render - // definitely won't finish. Since we have a new update, let's mark it as - // suspended now, right before marking the incoming update. This has the - // effect of interrupting the current render and switching to the update. - // TODO: This happens to work when receiving an update during the render - // phase, because of the trick inside computeExpirationForFiber to - // subtract 1 from `renderExpirationTime` to move it into a - // separate bucket. But we should probably model it with an exception, - // using the same mechanism we use to force hydration of a subtree. - // TODO: This does not account for low pri updates that were already - // scheduled before the root started rendering. Need to track the next - // pending expiration time (perhaps by backtracking the return path) and - // then trigger a restart in the `renderDidSuspendDelayIfPossible` path. - markRootSuspendedAtTime(root, renderExpirationTime$1); - } - } // Mark that the root has a pending update. - - markRootUpdatedAtTime(root, expirationTime); - } + if (exitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw fatalError; + } // We now have a consistent tree. Because this is a sync render, we + // will commit it even if something suspended. - return root; -} + var finishedWork = root.current.alternate; + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next + // pending level. -function getNextRootExpirationTimeToWorkOn(root) { - // Determines the next expiration time that the root should render, taking - // into account levels that may be suspended, or levels that may have - // received a ping. - var lastExpiredTime = root.lastExpiredTime; + ensureRootIsScheduled(root, now()); + return null; +} - if (lastExpiredTime !== NoWork) { - return lastExpiredTime; - } // "Pending" refers to any update that hasn't committed yet, including if it - // suspended. The "suspended" range is therefore a subset. +function batchedUpdates$1(fn, a) { + var prevExecutionContext = executionContext; + executionContext |= BatchedContext; - var firstPendingTime = root.firstPendingTime; + try { + return fn(a); + } finally { + executionContext = prevExecutionContext; - if (!isRootSuspendedAtTime(root, firstPendingTime)) { - // The highest priority pending time is not suspended. Let's work on that. - return firstPendingTime; - } // If the first pending time is suspended, check if there's a lower priority - // pending level that we know about. Or check if we received a ping. Work - // on whichever is higher priority. + if (executionContext === NoContext) { + // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); + flushSyncCallbackQueue(); + } + } +} +function flushSync(fn, a) { + var prevExecutionContext = executionContext; - var lastPingedTime = root.lastPingedTime; - var nextKnownPendingLevel = root.nextKnownPendingLevel; - var nextLevel = - lastPingedTime > nextKnownPendingLevel - ? lastPingedTime - : nextKnownPendingLevel; + if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) { + { + error( + "flushSync was called from inside a lifecycle method. React cannot " + + "flush when React is already rendering. Consider moving this call to " + + "a scheduler task or micro task." + ); + } - if (nextLevel <= Idle && firstPendingTime !== nextLevel) { - // Don't work on Idle/Never priority unless everything else is committed. - return NoWork; + return fn(a); } - return nextLevel; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the -// expiration time of the existing task is the same as the expiration time of -// the next level that the root has work on. This function is called on every -// update, and right before exiting a task. - -function ensureRootIsScheduled(root) { - var lastExpiredTime = root.lastExpiredTime; - - if (lastExpiredTime !== NoWork) { - // Special case: Expired work should flush synchronously. - root.callbackExpirationTime = Sync; - root.callbackPriority = ImmediatePriority; - root.callbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - ); - return; - } + executionContext |= BatchedContext; - var expirationTime = getNextRootExpirationTimeToWorkOn(root); - var existingCallbackNode = root.callbackNode; + { + try { + if (fn) { + return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); + } else { + return undefined; + } + } finally { + executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. + // Note that this will happen even if batchedUpdates is higher up + // the stack. - if (expirationTime === NoWork) { - // There's nothing to work on. - if (existingCallbackNode !== null) { - root.callbackNode = null; - root.callbackExpirationTime = NoWork; - root.callbackPriority = NoPriority; + flushSyncCallbackQueue(); } + } +} +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); + subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes); + workInProgressRootIncludedLanes = mergeLanes( + workInProgressRootIncludedLanes, + lanes + ); +} +function popRenderLanes(fiber) { + subtreeRenderLanes = subtreeRenderLanesCursor.current; + pop(subtreeRenderLanesCursor, fiber); +} - return; - } // TODO: If this is an update, we already read the current time. Pass the - // time as an argument. +function prepareFreshStack(root, lanes) { + root.finishedWork = null; + root.finishedLanes = NoLanes; + var timeoutHandle = root.timeoutHandle; + + if (timeoutHandle !== noTimeout) { + // The root previous suspended and scheduled a timeout to commit a fallback + // state. Now that we have additional work, cancel the timeout. + root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above - var currentTime = requestCurrentTimeForUpdate(); - var priorityLevel = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); // If there's an existing render task, confirm it has the correct priority and - // expiration time. Otherwise, we'll cancel it and schedule a new one. + cancelTimeout(timeoutHandle); + } - if (existingCallbackNode !== null) { - var existingCallbackPriority = root.callbackPriority; - var existingCallbackExpirationTime = root.callbackExpirationTime; + if (workInProgress !== null) { + var interruptedWork = workInProgress.return; + + while (interruptedWork !== null) { + unwindInterruptedWork(interruptedWork); + interruptedWork = interruptedWork.return; + } + } - if ( - // Callback must have the exact same expiration time. - existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. - existingCallbackPriority >= priorityLevel - ) { - // Existing callback is sufficient. - return; - } // Need to schedule a new task. - // TODO: Instead of scheduling a new task, we should be able to change the - // priority of the existing one. + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null); + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootFatalError = null; + workInProgressRootSkippedLanes = NoLanes; + workInProgressRootUpdatedLanes = NoLanes; + workInProgressRootPingedLanes = NoLanes; - cancelCallback(existingCallbackNode); + { + spawnedWorkDuringRender = null; } - root.callbackExpirationTime = expirationTime; - root.callbackPriority = priorityLevel; - var callbackNode; - - if (expirationTime === Sync) { - // Sync React callbacks are scheduled on a special internal queue - callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - callbackNode = scheduleCallback( - priorityLevel, - performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects - // ordering because tasks are processed in timeout order. - { - timeout: expirationTimeToMs(expirationTime) - now() - } - ); + { + ReactStrictModeWarnings.discardPendingWarnings(); } +} - root.callbackNode = callbackNode; -} // This is the entry point for every concurrent task, i.e. anything that -// goes through Scheduler. +function handleError(root, thrownValue) { + do { + var erroredWork = workInProgress; -function performConcurrentWorkOnRoot(root, didTimeout) { - // Since we know we're in a React event, we can clear the current - // event time. The next update will compute a new event time. - currentEventTime = NoWork; // Check if the render expired. + try { + // Reset module-level state that was set during the render phase. + resetContextDependencies(); + resetHooksAfterThrow(); + resetCurrentFiber(); // TODO: I found and added this missing line while investigating a + // separate issue. Write a regression test using string refs. - if (didTimeout) { - // The render task took too long to complete. Mark the current time as - // expired to synchronously render all expired work in a single batch. - var currentTime = requestCurrentTimeForUpdate(); - markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback. + ReactCurrentOwner$2.current = null; - ensureRootIsScheduled(root); - return null; - } // Determine the next expiration time to work on, using the fields stored - // on the root. + if (erroredWork === null || erroredWork.return === null) { + // Expected to be working on a non-root fiber. This is a fatal error + // because there's no ancestor that can handle it; the root is + // supposed to capture all errors that weren't caught by an error + // boundary. + workInProgressRootExitStatus = RootFatalErrored; + workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next + // sibling, or the parent if there are no siblings. But since the root + // has no siblings nor a parent, we set it to null. Usually this is + // handled by `completeUnitOfWork` or `unwindWork`, but since we're + // intentionally not calling those, we need set it here. + // TODO: Consider calling `unwindWork` to pop the contexts. - var expirationTime = getNextRootExpirationTimeToWorkOn(root); + workInProgress = null; + return; + } - if (expirationTime === NoWork) { - return null; - } + if (enableProfilerTimer && erroredWork.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. This + // avoids inaccurate Profiler durations in the case of a + // suspended render. + stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); + } - var originalCallbackNode = root.callbackNode; + throwException( + root, + erroredWork.return, + erroredWork, + thrownValue, + workInProgressRootRenderLanes + ); + completeUnitOfWork(erroredWork); + } catch (yetAnotherThrownValue) { + // Something in the return path also threw. + thrownValue = yetAnotherThrownValue; - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } + if (workInProgress === erroredWork && erroredWork !== null) { + // If this boundary has already errored, then we had trouble processing + // the error. Bubble it to the next boundary. + erroredWork = erroredWork.return; + workInProgress = erroredWork; + } else { + erroredWork = workInProgress; + } - flushPassiveEffects(); - var exitStatus = renderRootConcurrent(root, expirationTime); + continue; + } // Return to the normal work loop. - if (exitStatus !== RootIncomplete) { - if (exitStatus === RootErrored) { - // If something threw an error, try rendering one more time. We'll - // render synchronously to block concurrent data mutations, and we'll - // render at Idle (or lower) so that all pending updates are included. - // If it still fails after the second attempt, we'll give up and commit - // the resulting tree. - expirationTime = expirationTime > Idle ? Idle : expirationTime; - exitStatus = renderRootSync(root, expirationTime); - } + return; + } while (true); +} - if (exitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } // We now have a consistent tree. The next step is either to commit it, - // or, if something suspended, wait to commit it after a timeout. +function pushDispatcher() { + var prevDispatcher = ReactCurrentDispatcher$2.current; + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; - var finishedWork = (root.finishedWork = root.current.alternate); - root.finishedExpirationTime = expirationTime; - finishConcurrentRender(root, finishedWork, exitStatus, expirationTime); + if (prevDispatcher === null) { + // The React isomorphic package does not include a default dispatcher. + // Instead the first renderer will lazily attach one, in order to give + // nicer error messages. + return ContextOnlyDispatcher; + } else { + return prevDispatcher; } +} - ensureRootIsScheduled(root); +function popDispatcher(prevDispatcher) { + ReactCurrentDispatcher$2.current = prevDispatcher; +} - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); +function pushInteractions(root) { + { + var prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + return prevInteractions; } - - return null; } -function finishConcurrentRender( - root, - finishedWork, - exitStatus, - expirationTime -) { - switch (exitStatus) { - case RootIncomplete: - case RootFatalErrored: { - { - throw Error("Root did not complete. This is a bug in React."); - } - } - // Flow knows about invariant, so it complains if I add a break - // statement, but eslint doesn't know about invariant, so it complains - // if I do. eslint-disable-next-line no-fallthrough - - case RootErrored: { - // We should have already attempted to retry this tree. If we reached - // this point, it errored again. Commit it. - commitRoot(root); - break; - } - - case RootSuspended: { - markRootSuspendedAtTime(root, expirationTime); - var lastSuspendedTime = root.lastSuspendedTime; - - if (expirationTime === lastSuspendedTime) { - root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); - } // We have an acceptable loading state. We need to figure out if we - // should immediately commit it or wait a bit. - // If we have processed new updates during this render, we may now - // have a new loading state ready. We want to ensure that we commit - // that as soon as possible. - - var hasNotProcessedNewUpdates = - workInProgressRootLatestProcessedExpirationTime === Sync; +function popInteractions(prevInteractions) { + { + tracing.__interactionsRef.current = prevInteractions; + } +} - if ( - hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope - !IsThisRendererActing.current - ) { - // If we have not processed any new updates during this pass, then - // this is either a retry of an existing fallback state or a - // hidden tree. Hidden trees shouldn't be batched with other work - // and after that's fixed it can only be a retry. We're going to - // throttle committing retries so that we don't show too many - // loading states too quickly. - var msUntilTimeout = - globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. +function markCommitTimeOfFallback() { + globalMostRecentFallbackTime = now(); +} +function markSkippedUpdateLanes(lane) { + workInProgressRootSkippedLanes = mergeLanes( + lane, + workInProgressRootSkippedLanes + ); +} +function renderDidSuspend() { + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootSuspended; + } +} +function renderDidSuspendDelayIfPossible() { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) { + workInProgressRootExitStatus = RootSuspendedWithDelay; + } // Check if there are updates that we skipped tree that might have unblocked + // this render. - if (msUntilTimeout > 10) { - if (workInProgressRootHasPendingPing) { - var lastPingedTime = root.lastPingedTime; - - if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) { - // This render was pinged but we didn't get to restart - // earlier so try restarting now instead. - root.lastPingedTime = expirationTime; - prepareFreshStack(root, expirationTime); - break; - } - } + if ( + workInProgressRoot !== null && + (includesNonIdleWork(workInProgressRootSkippedLanes) || + includesNonIdleWork(workInProgressRootUpdatedLanes)) + ) { + // Mark the current render as suspended so that we switch to working on + // the updates that were skipped. Usually we only suspend at the end of + // the render phase. + // TODO: We should probably always mark the root as suspended immediately + // (inside this function), since by suspending at the end of the render + // phase introduces a potential mistake where we suspend lanes that were + // pinged or updated while we were rendering. + markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); + } +} +function renderDidError() { + if (workInProgressRootExitStatus !== RootCompleted) { + workInProgressRootExitStatus = RootErrored; + } +} // Called during render to determine if anything has suspended. +// Returns false if we're not sure. - var nextTime = getNextRootExpirationTimeToWorkOn(root); +function renderHasNotSuspendedYet() { + // If something errored or completed, we can't really be sure, + // so those are false. + return workInProgressRootExitStatus === RootIncomplete; +} - if (nextTime !== NoWork && nextTime !== expirationTime) { - // There's additional work on this root. - break; - } +function renderRootSync(root, lanes) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - if ( - lastSuspendedTime !== NoWork && - lastSuspendedTime !== expirationTime - ) { - // We should prefer to render the fallback of at the last - // suspended level. Ping the last suspended level to try - // rendering it again. - root.lastPingedTime = lastSuspendedTime; - break; - } // The render is suspended, it hasn't timed out, and there's no - // lower priority work to do. Instead of committing the fallback - // immediately, wait for more data to arrive. + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + prepareFreshStack(root, lanes); + startWorkOnPendingInteractions(root, lanes); + } - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - msUntilTimeout - ); - break; - } - } // The work expired. Commit immediately. + var prevInteractions = pushInteractions(root); - commitRoot(root); + do { + try { + workLoopSync(); break; + } catch (thrownValue) { + handleError(root, thrownValue); } + } while (true); - case RootSuspendedWithDelay: { - markRootSuspendedAtTime(root, expirationTime); - var _lastSuspendedTime = root.lastSuspendedTime; + resetContextDependencies(); - if (expirationTime === _lastSuspendedTime) { - root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); - } + { + popInteractions(prevInteractions); + } - { - // We're suspended in a state that should be avoided. We'll try to - // avoid committing it for as long as the timeouts let us. - if (workInProgressRootHasPendingPing) { - var _lastPingedTime = root.lastPingedTime; - - if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) { - // This render was pinged but we didn't get to restart earlier - // so try restarting now instead. - root.lastPingedTime = expirationTime; - prepareFreshStack(root, expirationTime); - break; - } - } + executionContext = prevExecutionContext; + popDispatcher(prevDispatcher); - var _nextTime = getNextRootExpirationTimeToWorkOn(root); + if (workInProgress !== null) { + // This is a sync render, so we should have finished the whole tree. + { + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + } + } - if (_nextTime !== NoWork && _nextTime !== expirationTime) { - // There's additional work on this root. - break; - } + workInProgressRoot = null; + workInProgressRootRenderLanes = NoLanes; + return workInProgressRootExitStatus; +} // The work loop is an extremely hot path. Tell Closure not to inline it. - if ( - _lastSuspendedTime !== NoWork && - _lastSuspendedTime !== expirationTime - ) { - // We should prefer to render the fallback of at the last - // suspended level. Ping the last suspended level to try - // rendering it again. - root.lastPingedTime = _lastSuspendedTime; - break; - } +/** @noinline */ - var _msUntilTimeout; - - if (workInProgressRootLatestSuspenseTimeout !== Sync) { - // We have processed a suspense config whose expiration time we - // can use as the timeout. - _msUntilTimeout = - expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now(); - } else if (workInProgressRootLatestProcessedExpirationTime === Sync) { - // This should never normally happen because only new updates - // cause delayed states, so we should have processed something. - // However, this could also happen in an offscreen tree. - _msUntilTimeout = 0; - } else { - // If we don't have a suspense config, we're going to use a - // heuristic to determine how long we can suspend. - var eventTimeMs = inferTimeFromExpirationTime( - workInProgressRootLatestProcessedExpirationTime - ); - var currentTimeMs = now(); - var timeUntilExpirationMs = - expirationTimeToMs(expirationTime) - currentTimeMs; - var timeElapsed = currentTimeMs - eventTimeMs; - - if (timeElapsed < 0) { - // We get this wrong some time since we estimate the time. - timeElapsed = 0; - } +function workLoopSync() { + // Already timed out, so perform work without checking if we need to yield. + while (workInProgress !== null) { + performUnitOfWork(workInProgress); + } +} - _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the - // event time is exact instead of inferred from expiration time - // we don't need this. +function renderRootConcurrent(root, lanes) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - if (timeUntilExpirationMs < _msUntilTimeout) { - _msUntilTimeout = timeUntilExpirationMs; - } - } // Don't bother with a very short suspense time. + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + resetRenderTimer(); + prepareFreshStack(root, lanes); + startWorkOnPendingInteractions(root, lanes); + } - if (_msUntilTimeout > 10) { - // The render is suspended, it hasn't timed out, and there's no - // lower priority work to do. Instead of committing the fallback - // immediately, wait for more data to arrive. - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - _msUntilTimeout - ); - break; - } - } // The work expired. Commit immediately. + var prevInteractions = pushInteractions(root); - commitRoot(root); + do { + try { + workLoopConcurrent(); break; + } catch (thrownValue) { + handleError(root, thrownValue); } + } while (true); - case RootCompleted: { - // The work completed. Ready to commit. - if ( - // do not delay if we're inside an act() scope - workInProgressRootLatestProcessedExpirationTime !== Sync && - workInProgressRootCanSuspendUsingConfig !== null - ) { - // If we have exceeded the minimum loading delay, which probably - // means we have shown a spinner already, we might have to suspend - // a bit longer to ensure that the spinner is shown for - // enough time. - var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay( - workInProgressRootLatestProcessedExpirationTime, - expirationTime, - workInProgressRootCanSuspendUsingConfig - ); + resetContextDependencies(); - if (_msUntilTimeout2 > 10) { - markRootSuspendedAtTime(root, expirationTime); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - _msUntilTimeout2 - ); - break; - } - } + { + popInteractions(prevInteractions); + } - commitRoot(root); - break; - } + popDispatcher(prevDispatcher); + executionContext = prevExecutionContext; - default: { - { - throw Error("Unknown root exit status."); - } - } + if (workInProgress !== null) { + return RootIncomplete; + } else { + workInProgressRoot = null; + workInProgressRootRenderLanes = NoLanes; // Return the final exit status. + + return workInProgressRootExitStatus; } -} // This is the entry point for synchronous tasks that don't go -// through Scheduler +} +/** @noinline */ -function performSyncWorkOnRoot(root) { - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); +function workLoopConcurrent() { + // Perform work until Scheduler asks us to yield + while (workInProgress !== null && !shouldYield()) { + performUnitOfWork(workInProgress); } +} - flushPassiveEffects(); - var lastExpiredTime = root.lastExpiredTime; - var expirationTime; +function performUnitOfWork(unitOfWork) { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current = unitOfWork.alternate; + setCurrentFiber(unitOfWork); + var next; - if (lastExpiredTime !== NoWork) { - // There's expired work on this root. Check if we have a partial tree - // that we can reuse. - if ( - root === workInProgressRoot && - renderExpirationTime$1 >= lastExpiredTime - ) { - // There's a partial tree with equal or greater than priority than the - // expired level. Finish rendering it before rendering the rest of the - // expired work. - expirationTime = renderExpirationTime$1; - } else { - // Start a fresh tree. - expirationTime = lastExpiredTime; - } + if ((unitOfWork.mode & ProfileMode) !== NoMode) { + startProfilerTimer(unitOfWork); + next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - // There's no expired work. This must be a new, synchronous render. - expirationTime = Sync; + next = beginWork$1(current, unitOfWork, subtreeRenderLanes); } - var exitStatus = renderRootSync(root, expirationTime); + resetCurrentFiber(); + unitOfWork.memoizedProps = unitOfWork.pendingProps; - if (root.tag !== LegacyRoot && exitStatus === RootErrored) { - // If something threw an error, try rendering one more time. We'll - // render synchronously to block concurrent data mutations, and we'll - // render at Idle (or lower) so that all pending updates are included. - // If it still fails after the second attempt, we'll give up and commit - // the resulting tree. - expirationTime = expirationTime > Idle ? Idle : expirationTime; - exitStatus = renderRootSync(root, expirationTime); + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; } - if (exitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } // We now have a consistent tree. Because this is a sync render, we - // will commit it even if something suspended. + ReactCurrentOwner$2.current = null; +} - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = expirationTime; - commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next - // pending level. +function completeUnitOfWork(unitOfWork) { + // Attempt to complete the current unit of work, then move to the next + // sibling. If there are no more siblings, return to the parent fiber. + var completedWork = unitOfWork; - ensureRootIsScheduled(root); - return null; -} -function syncUpdates(fn, a, b, c) { - return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c)); -} + do { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current = completedWork.alternate; + var returnFiber = completedWork.return; // Check if the work completed or if something threw. -function batchedUpdates$1(fn, a) { - var prevExecutionContext = executionContext; - executionContext |= BatchedContext; + if ((completedWork.flags & Incomplete) === NoFlags) { + setCurrentFiber(completedWork); + var next = void 0; - try { - return fn(a); - } finally { - executionContext = prevExecutionContext; + if ((completedWork.mode & ProfileMode) === NoMode) { + next = completeWork(current, completedWork, subtreeRenderLanes); + } else { + startProfilerTimer(completedWork); + next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error. - if (executionContext === NoContext) { - // Flush the immediate callbacks that were scheduled during this batch - flushSyncCallbackQueue(); - } - } -} -function flushSync(fn, a) { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { - { - throw Error( - "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." - ); - } - } + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); + } - var prevExecutionContext = executionContext; - executionContext |= BatchedContext; + resetCurrentFiber(); - try { - return runWithPriority(ImmediatePriority, fn.bind(null, a)); - } finally { - executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. - // Note that this will happen even if batchedUpdates is higher up - // the stack. + if (next !== null) { + // Completing this fiber spawned new work. Work on that next. + workInProgress = next; + return; + } - flushSyncCallbackQueue(); - } -} + resetChildLanes(completedWork); -function prepareFreshStack(root, expirationTime) { - root.finishedWork = null; - root.finishedExpirationTime = NoWork; - var timeoutHandle = root.timeoutHandle; + if ( + returnFiber !== null && // Do not append effects to parents if a sibling failed to complete + (returnFiber.flags & Incomplete) === NoFlags + ) { + // Append all the effects of the subtree and this fiber onto the effect + // list of the parent. The completion order of the children affects the + // side-effect order. + if (returnFiber.firstEffect === null) { + returnFiber.firstEffect = completedWork.firstEffect; + } - if (timeoutHandle !== noTimeout) { - // The root previous suspended and scheduled a timeout to commit a fallback - // state. Now that we have additional work, cancel the timeout. - root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above + if (completedWork.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork.firstEffect; + } - cancelTimeout(timeoutHandle); - } + returnFiber.lastEffect = completedWork.lastEffect; + } // If this fiber had side-effects, we append it AFTER the children's + // side-effects. We can perform certain side-effects earlier if needed, + // by doing multiple passes over the effect list. We don't want to + // schedule our own side-effect on our own list because if end up + // reusing children we'll schedule this effect onto itself since we're + // at the end. - if (workInProgress !== null) { - var interruptedWork = workInProgress.return; + var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect + // list. PerformedWork effect is read by React DevTools but shouldn't be + // committed. - while (interruptedWork !== null) { - unwindInterruptedWork(interruptedWork); - interruptedWork = interruptedWork.return; + if (flags > PerformedWork) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork; + } else { + returnFiber.firstEffect = completedWork; + } + + returnFiber.lastEffect = completedWork; + } + } + } else { + // This fiber did not complete because something threw. Pop values off + // the stack without entering the complete phase. If this is a boundary, + // capture values if possible. + var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time. + + if (_next !== null) { + // If completing this work spawned new work, do that next. We'll come + // back here again. + // Since we're restarting, remove anything that is not a host effect + // from the effect tag. + _next.flags &= HostEffectMask; + workInProgress = _next; + return; + } + + if ((completedWork.mode & ProfileMode) !== NoMode) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing. + + var actualDuration = completedWork.actualDuration; + var child = completedWork.child; + + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + + completedWork.actualDuration = actualDuration; + } + + if (returnFiber !== null) { + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; + returnFiber.flags |= Incomplete; + } } - } - workInProgressRoot = root; - workInProgress = createWorkInProgress(root.current, null); - renderExpirationTime$1 = expirationTime; - workInProgressRootExitStatus = RootIncomplete; - workInProgressRootFatalError = null; - workInProgressRootLatestProcessedExpirationTime = Sync; - workInProgressRootLatestSuspenseTimeout = Sync; - workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootNextUnprocessedUpdateTime = NoWork; - workInProgressRootHasPendingPing = false; + var siblingFiber = completedWork.sibling; - { - spawnedWorkDuringRender = null; - } + if (siblingFiber !== null) { + // If there is more work to do in this returnFiber, do that next. + workInProgress = siblingFiber; + return; + } // Otherwise, return to the parent - { - ReactStrictModeWarnings.discardPendingWarnings(); + completedWork = returnFiber; // Update the next thing we're working on in case something throws. + + workInProgress = completedWork; + } while (completedWork !== null); // We've reached the root. + + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootCompleted; } } -function handleError(root, thrownValue) { - do { - try { - // Reset module-level state that was set during the render phase. - resetContextDependencies(); - resetHooksAfterThrow(); - resetCurrentFiber(); +function resetChildLanes(completedWork) { + if ( + // TODO: Move this check out of the hot path by moving `resetChildLanes` + // to switch statement in `completeWork`. + (completedWork.tag === LegacyHiddenComponent || + completedWork.tag === OffscreenComponent) && + completedWork.memoizedState !== null && + !includesSomeLane(subtreeRenderLanes, OffscreenLane) && + (completedWork.mode & ConcurrentMode) !== NoLanes + ) { + // The children of this component are hidden. Don't bubble their + // expiration times. + return; + } - if (workInProgress === null || workInProgress.return === null) { - // Expected to be working on a non-root fiber. This is a fatal error - // because there's no ancestor that can handle it; the root is - // supposed to capture all errors that weren't caught by an error - // boundary. - workInProgressRootExitStatus = RootFatalErrored; - workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next - // sibling, or the parent if there are no siblings. But since the root - // has no siblings nor a parent, we set it to null. Usually this is - // handled by `completeUnitOfWork` or `unwindWork`, but since we're - // interntionally not calling those, we need set it here. - // TODO: Consider calling `unwindWork` to pop the contexts. + var newChildLanes = NoLanes; // Bubble up the earliest expiration time. - workInProgress = null; - return null; - } + if ((completedWork.mode & ProfileMode) !== NoMode) { + // In profiling mode, resetChildExpirationTime is also used to reset + // profiler durations. + var actualDuration = completedWork.actualDuration; + var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will + // only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. If + // the fiber has not been cloned though, (meaning no work was done), then + // this value will reflect the amount of time spent working on a previous + // render. In that case it should not bubble. We determine whether it was + // cloned by comparing the child pointer. - if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // Record the time spent rendering before an error was thrown. This - // avoids inaccurate Profiler durations in the case of a - // suspended render. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); - } + var shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + var child = completedWork.child; - throwException( - root, - workInProgress.return, - workInProgress, - thrownValue, - renderExpirationTime$1 + while (child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(child.lanes, child.childLanes) ); - workInProgress = completeUnitOfWork(workInProgress); - } catch (yetAnotherThrownValue) { - // Something in the return path also threw. - thrownValue = yetAnotherThrownValue; - continue; - } // Return to the normal work loop. - return; - } while (true); -} + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } -function pushDispatcher(root) { - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + var isTimedOutSuspense = + completedWork.tag === SuspenseComponent && + completedWork.memoizedState !== null; - if (prevDispatcher === null) { - // The React isomorphic package does not include a default dispatcher. - // Instead the first renderer will lazily attach one, in order to give - // nicer error messages. - return ContextOnlyDispatcher; + if (isTimedOutSuspense) { + // Don't count time spent in a timed out Suspense subtree as part of the base duration. + var primaryChildFragment = completedWork.child; + + if (primaryChildFragment !== null) { + treeBaseDuration -= primaryChildFragment.treeBaseDuration; + } + } + + completedWork.actualDuration = actualDuration; + completedWork.treeBaseDuration = treeBaseDuration; } else { - return prevDispatcher; + var _child = completedWork.child; + + while (_child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(_child.lanes, _child.childLanes) + ); + _child = _child.sibling; + } } -} -function popDispatcher(prevDispatcher) { - ReactCurrentDispatcher$1.current = prevDispatcher; + completedWork.childLanes = newChildLanes; } -function pushInteractions(root) { - { - var prevInteractions = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - return prevInteractions; - } +function commitRoot(root) { + var renderPriorityLevel = getCurrentPriorityLevel(); + runWithPriority( + ImmediatePriority$1, + commitRootImpl.bind(null, root, renderPriorityLevel) + ); + return null; } -function popInteractions(prevInteractions) { - { - tracing.__interactionsRef.current = prevInteractions; - } -} +function commitRootImpl(root, renderPriorityLevel) { + do { + // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which + // means `flushPassiveEffects` will sometimes result in additional + // passive effects. So we need to keep flushing in a loop until there are + // no more pending effects. + // TODO: Might be better if `flushPassiveEffects` did not automatically + // flush synchronous work at the end, to avoid factoring hazards like this. + flushPassiveEffects(); + } while (rootWithPendingPassiveEffects !== null); -function markCommitTimeOfFallback() { - globalMostRecentFallbackTime = now(); -} -function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { - if ( - expirationTime < workInProgressRootLatestProcessedExpirationTime && - expirationTime > Idle - ) { - workInProgressRootLatestProcessedExpirationTime = expirationTime; + flushRenderPhaseStrictModeWarningsInDEV(); + + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); } - if (suspenseConfig !== null) { - if ( - expirationTime < workInProgressRootLatestSuspenseTimeout && - expirationTime > Idle - ) { - workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad. + var finishedWork = root.finishedWork; + var lanes = root.finishedLanes; - workInProgressRootCanSuspendUsingConfig = suspenseConfig; - } - } -} -function markUnprocessedUpdateTime(expirationTime) { - if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) { - workInProgressRootNextUnprocessedUpdateTime = expirationTime; - } -} -function renderDidSuspend() { - if (workInProgressRootExitStatus === RootIncomplete) { - workInProgressRootExitStatus = RootSuspended; + if (finishedWork === null) { + return null; } -} -function renderDidSuspendDelayIfPossible() { - if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended - ) { - workInProgressRootExitStatus = RootSuspendedWithDelay; - } // Check if there's a lower priority update somewhere else in the tree. - if ( - workInProgressRootNextUnprocessedUpdateTime !== NoWork && - workInProgressRoot !== null - ) { - // Mark the current render as suspended, and then mark that there's a - // pending update. - // TODO: This should immediately interrupt the current render, instead - // of waiting until the next time we yield. - markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1); - markRootUpdatedAtTime( - workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime + root.finishedWork = null; + root.finishedLanes = NoLanes; + + if (!(finishedWork !== root.current)) { + throw Error( + "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - } -} -function renderDidError() { - if (workInProgressRootExitStatus !== RootCompleted) { - workInProgressRootExitStatus = RootErrored; - } -} // Called during render to determine if anything has suspended. -// Returns false if we're not sure. + } // commitRoot never returns a continuation; it always finishes synchronously. + // So we can clear these now to allow a new callback to be scheduled. -function renderHasNotSuspendedYet() { - // If something errored or completed, we can't really be sure, - // so those are false. - return workInProgressRootExitStatus === RootIncomplete; -} + root.callbackNode = null; // Update the first and last pending times on this root. The new first + // pending time is whatever is left on the root fiber. -function inferTimeFromExpirationTime(expirationTime) { - // We don't know exactly when the update was scheduled, but we can infer an - // approximate start time from the expiration time. - var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); - return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; -} + var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); + markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of + // `flushDiscreteUpdates` starts a useless render pass which may cancels + // a scheduled timeout. -function inferTimeFromExpirationTimeWithSuspenseConfig( - expirationTime, - suspenseConfig -) { - // We don't know exactly when the update was scheduled, but we can infer an - // approximate start time from the expiration time by subtracting the timeout - // that was added to the event time. - var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); - return ( - earliestExpirationTimeMs - - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION) - ); -} + if (rootsWithPendingDiscreteUpdates !== null) { + if ( + !hasDiscreteLanes(remainingLanes) && + rootsWithPendingDiscreteUpdates.has(root) + ) { + rootsWithPendingDiscreteUpdates.delete(root); + } + } -function renderRootSync(root, expirationTime) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. + if (root === workInProgressRoot) { + // We can reset these now that they are finished. + workInProgressRoot = null; + workInProgress = null; + workInProgressRootRenderLanes = NoLanes; + } // Get the list of effects. - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime$1 - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); + var firstEffect; + + if (finishedWork.flags > PerformedWork) { + // A fiber's effect list consists only of its children, not itself. So if + // the root has an effect, we need to add it to the end of the list. The + // resulting list is the set that would belong to the root's parent, if it + // had one; that is, all the effects in the tree including the root. + if (finishedWork.lastEffect !== null) { + finishedWork.lastEffect.nextEffect = finishedWork; + firstEffect = finishedWork.firstEffect; + } else { + firstEffect = finishedWork; + } + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; } - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + if (firstEffect !== null) { + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles - do { - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - } while (true); + ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass + // of the effect list for each phase: all mutation effects come before all + // layout effects, and so on. + // The first phase a "before mutation" phase. We use this phase to read the + // state of the host tree right before we mutate it. This is where + // getSnapshotBeforeUpdate is called. - resetContextDependencies(); + focusedInstanceHandle = prepareForCommit(root.containerInfo); + shouldFireAfterActiveInstanceBlur = false; + nextEffect = firstEffect; - { - popInteractions(prevInteractions); - } + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); - executionContext = prevExecutionContext; - popDispatcher(prevDispatcher); + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } - if (workInProgress !== null) { - // This is a sync render, so we should have finished the whole tree. - { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - } - } + var error = clearCaughtError(); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); // We no longer need to track the active instance fiber - stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. + focusedInstanceHandle = null; - workInProgressRoot = null; - return workInProgressRootExitStatus; -} // The work loop is an extremely hot path. Tell Closure not to inline it. + { + // Mark the current commit time to be shared by all Profilers in this + // batch. This enables them to be grouped later. + recordCommitTime(); + } // The next phase is the mutation phase, where we mutate the host tree. -/** @noinline */ + nextEffect = firstEffect; -function workLoopSync() { - // Already timed out, so perform work without checking if we need to yield. - while (workInProgress !== null) { - workInProgress = performUnitOfWork(workInProgress); - } -} + do { + { + invokeGuardedCallback( + null, + commitMutationEffects, + null, + root, + renderPriorityLevel + ); -function renderRootConcurrent(root, expirationTime) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime$1 - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); - } + var _error = clearCaughtError(); - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + captureCommitPhaseError(nextEffect, _error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); - do { - try { - workLoopConcurrent(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); - } - } while (true); + resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after + // the mutation phase, so that the previous tree is still current during + // componentWillUnmount, but before the layout phase, so that the finished + // work is current during componentDidMount/Update. - resetContextDependencies(); + root.current = finishedWork; // The next phase is the layout phase, where we call effects that read + // the host tree after it's been mutated. The idiomatic use case for this is + // layout, but class component lifecycles also fire here for legacy reasons. - { - popInteractions(prevInteractions); - } + nextEffect = firstEffect; - popDispatcher(prevDispatcher); - executionContext = prevExecutionContext; // Check if the tree has completed. + do { + { + invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); + + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } - if (workInProgress !== null) { - // Still work remaining. - stopInterruptedWorkLoopTimer(); - return RootIncomplete; - } else { - // Completed the tree. - stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. + var _error2 = clearCaughtError(); - workInProgressRoot = null; // Return the final exit status. + captureCommitPhaseError(nextEffect, _error2); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); - return workInProgressRootExitStatus; - } -} -/** @noinline */ + nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an + // opportunity to paint. -function workLoopConcurrent() { - // Perform work until Scheduler asks us to yield - while (workInProgress !== null && !shouldYield()) { - workInProgress = performUnitOfWork(workInProgress); - } -} + requestPaint(); -function performUnitOfWork(unitOfWork) { - // The current, flushed, state of this fiber is the alternate. Ideally - // nothing should rely on this, but relying on it here means that we don't - // need an additional field on the work in progress. - var current = unitOfWork.alternate; - startWorkTimer(unitOfWork); - setCurrentFiber(unitOfWork); - var next; + { + popInteractions(prevInteractions); + } - if ((unitOfWork.mode & ProfileMode) !== NoMode) { - startProfilerTimer(unitOfWork); - next = beginWork$1(current, unitOfWork, renderExpirationTime$1); - stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + executionContext = prevExecutionContext; } else { - next = beginWork$1(current, unitOfWork, renderExpirationTime$1); + // No effects. + root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were + // no effects. + // TODO: Maybe there's a better way to report this. + + { + recordCommitTime(); + } } - resetCurrentFiber(); - unitOfWork.memoizedProps = unitOfWork.pendingProps; + var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; - if (next === null) { - // If this doesn't spawn new work, complete the current work. - next = completeUnitOfWork(unitOfWork); - } + if (rootDoesHavePassiveEffects) { + // This commit has passive effects. Stash a reference to them. But don't + // schedule a callback until after flushing layout work. + rootDoesHavePassiveEffects = false; + rootWithPendingPassiveEffects = root; + pendingPassiveEffectsLanes = lanes; + pendingPassiveEffectsRenderPriority = renderPriorityLevel; + } else { + // We are done with the effect chain at this point so let's clear the + // nextEffect pointers to assist with GC. If we have passive effects, we'll + // clear this in flushPassiveEffects. + nextEffect = firstEffect; - ReactCurrentOwner$2.current = null; - return next; -} + while (nextEffect !== null) { + var nextNextEffect = nextEffect.nextEffect; + nextEffect.nextEffect = null; -function completeUnitOfWork(unitOfWork) { - // Attempt to complete the current unit of work, then move to the next - // sibling. If there are no more siblings, return to the parent fiber. - workInProgress = unitOfWork; + if (nextEffect.flags & Deletion) { + detachFiberAfterEffects(nextEffect); + } - do { - // The current, flushed, state of this fiber is the alternate. Ideally - // nothing should rely on this, but relying on it here means that we don't - // need an additional field on the work in progress. - var current = workInProgress.alternate; - var returnFiber = workInProgress.return; // Check if the work completed or if something threw. + nextEffect = nextNextEffect; + } + } // Read this again, since an effect might have updated it - if ((workInProgress.effectTag & Incomplete) === NoEffect) { - setCurrentFiber(workInProgress); - var next = void 0; + remainingLanes = root.pendingLanes; // Check if there's remaining work on this root - if ((workInProgress.mode & ProfileMode) === NoMode) { - next = completeWork(current, workInProgress, renderExpirationTime$1); - } else { - startProfilerTimer(workInProgress); - next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error. + if (remainingLanes !== NoLanes) { + { + if (spawnedWorkDuringRender !== null) { + var expirationTimes = spawnedWorkDuringRender; + spawnedWorkDuringRender = null; - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + for (var i = 0; i < expirationTimes.length; i++) { + scheduleInteractions( + root, + expirationTimes[i], + root.memoizedInteractions + ); + } } - stopWorkTimer(workInProgress); - resetCurrentFiber(); - resetChildExpirationTime(workInProgress); + schedulePendingInteractions(root, remainingLanes); + } + } else { + // If there's no remaining work, we can clear the set of already failed + // error boundaries. + legacyErrorBoundariesThatAlreadyFailed = null; + } - if (next !== null) { - // Completing this fiber spawned new work. Work on that next. - return next; - } + { + if (!rootDidHavePassiveEffects) { + // If there are no passive effects, then we can complete the pending interactions. + // Otherwise, we'll wait until after the passive effects are flushed. + // Wait to do this until after remaining work has been scheduled, + // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. + finishPendingInteractions(root, lanes); + } + } - if ( - returnFiber !== null && // Do not append effects to parents if a sibling failed to complete - (returnFiber.effectTag & Incomplete) === NoEffect - ) { - // Append all the effects of the subtree and this fiber onto the effect - // list of the parent. The completion order of the children affects the - // side-effect order. - if (returnFiber.firstEffect === null) { - returnFiber.firstEffect = workInProgress.firstEffect; - } + if (remainingLanes === SyncLane) { + // Count the number of times the root synchronously re-renders without + // finishing. If there are too many, it indicates an infinite update loop. + if (root === rootWithNestedUpdates) { + nestedUpdateCount++; + } else { + nestedUpdateCount = 0; + rootWithNestedUpdates = root; + } + } else { + nestedUpdateCount = 0; + } - if (workInProgress.lastEffect !== null) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; - } + onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + // additional work on this root is scheduled. - returnFiber.lastEffect = workInProgress.lastEffect; - } // If this fiber had side-effects, we append it AFTER the children's - // side-effects. We can perform certain side-effects earlier if needed, - // by doing multiple passes over the effect list. We don't want to - // schedule our own side-effect on our own list because if end up - // reusing children we'll schedule this effect onto itself since we're - // at the end. + ensureRootIsScheduled(root, now()); - var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect - // list. PerformedWork effect is read by React DevTools but shouldn't be - // committed. + if (hasUncaughtError) { + hasUncaughtError = false; + var _error3 = firstUncaughtError; + firstUncaughtError = null; + throw _error3; + } - if (effectTag > PerformedWork) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress; - } else { - returnFiber.firstEffect = workInProgress; - } + if ((executionContext & LegacyUnbatchedContext) !== NoContext) { + // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired + // synchronously, but layout updates should be deferred until the end + // of the batch. - returnFiber.lastEffect = workInProgress; - } - } - } else { - // This fiber did not complete because something threw. Pop values off - // the stack without entering the complete phase. If this is a boundary, - // capture values if possible. - var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time. + return null; + } // If layout work was scheduled, flush it now. - if ((workInProgress.mode & ProfileMode) !== NoMode) { - // Record the render duration for the fiber that errored. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing. + flushSyncCallbackQueue(); - var actualDuration = workInProgress.actualDuration; - var child = workInProgress.child; + return null; +} - while (child !== null) { - actualDuration += child.actualDuration; - child = child.sibling; - } +function commitBeforeMutationEffects() { + while (nextEffect !== null) { + var current = nextEffect.alternate; - workInProgress.actualDuration = actualDuration; + if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { + if ((nextEffect.flags & Deletion) !== NoFlags) { + if (doesFiberContain(nextEffect, focusedInstanceHandle)) { + shouldFireAfterActiveInstanceBlur = true; + } + } else { + // TODO: Move this out of the hot path using a dedicated effect tag. + if ( + nextEffect.tag === SuspenseComponent && + isSuspenseBoundaryBeingHidden(current, nextEffect) && + doesFiberContain(nextEffect, focusedInstanceHandle) + ) { + shouldFireAfterActiveInstanceBlur = true; + } } + } - if (_next !== null) { - // If completing this work spawned new work, do that next. We'll come - // back here again. - // Since we're restarting, remove anything that is not a host effect - // from the effect tag. - // TODO: The name stopFailedWorkTimer is misleading because Suspense - // also captures and restarts. - stopFailedWorkTimer(workInProgress); - _next.effectTag &= HostEffectMask; - return _next; - } + var flags = nextEffect.flags; - stopWorkTimer(workInProgress); + if ((flags & Snapshot) !== NoFlags) { + setCurrentFiber(nextEffect); + commitBeforeMutationLifeCycles(current, nextEffect); + resetCurrentFiber(); + } - if (returnFiber !== null) { - // Mark the parent fiber as incomplete and clear its effect list. - returnFiber.firstEffect = returnFiber.lastEffect = null; - returnFiber.effectTag |= Incomplete; + if ((flags & Passive) !== NoFlags) { + // If there are passive effects, schedule a callback to flush at + // the earliest opportunity. + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); } } - var siblingFiber = workInProgress.sibling; + nextEffect = nextEffect.nextEffect; + } +} - if (siblingFiber !== null) { - // If there is more work to do in this returnFiber, do that next. - return siblingFiber; - } // Otherwise, return to the parent +function commitMutationEffects(root, renderPriorityLevel) { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; - workInProgress = returnFiber; - } while (workInProgress !== null); // We've reached the root. + if (flags & Ref) { + var current = nextEffect.alternate; - if (workInProgressRootExitStatus === RootIncomplete) { - workInProgressRootExitStatus = RootCompleted; - } + if (current !== null) { + commitDetachRef(current); + } + } // The following switch statement is only concerned about placement, + // updates, and deletions. To avoid needing to add a case for every possible + // bitmap value, we remove the secondary effects from the effect tag and + // switch on that value. - return null; -} + var primaryFlags = flags & (Placement | Update | Deletion | Hydrating); -function getRemainingExpirationTime(fiber) { - var updateExpirationTime = fiber.expirationTime; - var childExpirationTime = fiber.childExpirationTime; - return updateExpirationTime > childExpirationTime - ? updateExpirationTime - : childExpirationTime; -} + switch (primaryFlags) { + case Placement: { + // inserted, before any life-cycles like componentDidMount gets called. + // TODO: findDOMNode doesn't rely on this any more but isMounted does + // and isMounted is deprecated anyway so we should be able to kill this. -function resetChildExpirationTime(completedWork) { - if ( - renderExpirationTime$1 !== Never && - completedWork.childExpirationTime === Never - ) { - // The children of this component are hidden. Don't bubble their - // expiration times. - return; - } + nextEffect.flags &= ~Placement; + break; + } - var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time. + case PlacementAndUpdate: { + // inserted, before any life-cycles like componentDidMount gets called. - if ((completedWork.mode & ProfileMode) !== NoMode) { - // In profiling mode, resetChildExpirationTime is also used to reset - // profiler durations. - var actualDuration = completedWork.actualDuration; - var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will - // only be updated if work is done on the fiber (i.e. it doesn't bailout). - // When work is done, it should bubble to the parent's actualDuration. If - // the fiber has not been cloned though, (meaning no work was done), then - // this value will reflect the amount of time spent working on a previous - // render. In that case it should not bubble. We determine whether it was - // cloned by comparing the child pointer. + nextEffect.flags &= ~Placement; // Update - var shouldBubbleActualDurations = - completedWork.alternate === null || - completedWork.child !== completedWork.alternate.child; - var child = completedWork.child; + var _current = nextEffect.alternate; + commitWork(_current, nextEffect); + break; + } + + case Hydrating: { + nextEffect.flags &= ~Hydrating; + break; + } - while (child !== null) { - var childUpdateExpirationTime = child.expirationTime; - var childChildExpirationTime = child.childExpirationTime; + case HydratingAndUpdate: { + nextEffect.flags &= ~Hydrating; // Update - if (childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childUpdateExpirationTime; + var _current2 = nextEffect.alternate; + commitWork(_current2, nextEffect); + break; } - if (childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childChildExpirationTime; + case Update: { + var _current3 = nextEffect.alternate; + commitWork(_current3, nextEffect); + break; } - if (shouldBubbleActualDurations) { - actualDuration += child.actualDuration; + case Deletion: { + commitDeletion(root, nextEffect); + break; } - - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; } - completedWork.actualDuration = actualDuration; - completedWork.treeBaseDuration = treeBaseDuration; - } else { - var _child = completedWork.child; + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} - while (_child !== null) { - var _childUpdateExpirationTime = _child.expirationTime; - var _childChildExpirationTime = _child.childExpirationTime; +function commitLayoutEffects(root, committedLanes) { + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; - if (_childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childUpdateExpirationTime; - } + if (flags & (Update | Callback)) { + var current = nextEffect.alternate; + commitLifeCycles(root, current, nextEffect); + } - if (_childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childChildExpirationTime; + { + if (flags & Ref) { + commitAttachRef(nextEffect); } - - _child = _child.sibling; } - } - completedWork.childExpirationTime = newChildExpirationTime; + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } } -function commitRoot(root) { - var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority( - ImmediatePriority, - commitRootImpl.bind(null, root, renderPriorityLevel) - ); - return null; -} +function flushPassiveEffects() { + // Returns whether passive effects were flushed. + if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { + var priorityLevel = + pendingPassiveEffectsRenderPriority > NormalPriority$1 + ? NormalPriority$1 + : pendingPassiveEffectsRenderPriority; + pendingPassiveEffectsRenderPriority = NoPriority$1; -function commitRootImpl(root, renderPriorityLevel) { - do { - // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which - // means `flushPassiveEffects` will sometimes result in additional - // passive effects. So we need to keep flushing in a loop until there are - // no more pending effects. - // TODO: Might be better if `flushPassiveEffects` did not automatically - // flush synchronous work at the end, to avoid factoring hazards like this. - flushPassiveEffects(); - } while (rootWithPendingPassiveEffects !== null); + { + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); + } + } - flushRenderPhaseStrictModeWarningsInDEV(); + return false; +} +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); } +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); - var finishedWork = root.finishedWork; - var expirationTime = root.finishedExpirationTime; + { + fiber.flags |= PassiveUnmountPendingDev; + var alternate = fiber.alternate; - if (finishedWork === null) { - return null; + if (alternate !== null) { + alternate.flags |= PassiveUnmountPendingDev; + } } - root.finishedWork = null; - root.finishedExpirationTime = NoWork; - - if (!(finishedWork !== root.current)) { - throw Error( - "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." - ); - } // commitRoot never returns a continuation; it always finishes synchronously. - // So we can clear these now to allow a new callback to be scheduled. + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); + } +} - root.callbackNode = null; - root.callbackExpirationTime = NoWork; - root.callbackPriority = NoPriority; - root.nextKnownPendingLevel = NoWork; - startCommitTimer(); // Update the first and last pending times on this root. The new first - // pending time is whatever is left on the root fiber. +function invokePassiveEffectCreate(effect) { + var create = effect.create; + effect.destroy = create(); +} - var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( - finishedWork - ); - markRootFinishedAtTime( - root, - expirationTime, - remainingExpirationTimeBeforeCommit - ); +function flushPassiveEffectsImpl() { + if (rootWithPendingPassiveEffects === null) { + return false; + } - if (root === workInProgressRoot) { - // We can reset these now that they are finished. - workInProgressRoot = null; - workInProgress = null; - renderExpirationTime$1 = NoWork; - } // This indicates that the last root we worked on is not the same one that - // we're committing now. This most commonly happens when a suspended root - // times out. - // Get the list of effects. + var root = rootWithPendingPassiveEffects; + var lanes = pendingPassiveEffectsLanes; + rootWithPendingPassiveEffects = null; + pendingPassiveEffectsLanes = NoLanes; - var firstEffect; + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Cannot flush passive effects while already rendering."); + } - if (finishedWork.effectTag > PerformedWork) { - // A fiber's effect list consists only of its children, not itself. So if - // the root has an effect, we need to add it to the end of the list. The - // resulting list is the set that would belong to the root's parent, if it - // had one; that is, all the effects in the tree including the root. - if (finishedWork.lastEffect !== null) { - finishedWork.lastEffect.nextEffect = finishedWork; - firstEffect = finishedWork.firstEffect; - } else { - firstEffect = finishedWork; - } - } else { - // There is no effect on the root. - firstEffect = finishedWork.firstEffect; + { + isFlushingPassiveEffects = true; } - if (firstEffect !== null) { - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called + // before ANY passive effect create functions are called. + // Otherwise effects in sibling components might interfere with each other. + // e.g. a destroy function in one component may unintentionally override a ref + // value set by a create function in another component. + // Layout effects have the same constraint. + // First pass: Destroy stale passive effects. + + var unmountEffects = pendingPassiveHookEffectsUnmount; + pendingPassiveHookEffectsUnmount = []; + + for (var i = 0; i < unmountEffects.length; i += 2) { + var _effect = unmountEffects[i]; + var fiber = unmountEffects[i + 1]; + var destroy = _effect.destroy; + _effect.destroy = undefined; - ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass - // of the effect list for each phase: all mutation effects come before all - // layout effects, and so on. - // The first phase a "before mutation" phase. We use this phase to read the - // state of the host tree right before we mutate it. This is where - // getSnapshotBeforeUpdate is called. + { + fiber.flags &= ~PassiveUnmountPendingDev; + var alternate = fiber.alternate; - startCommitSnapshotEffectsTimer(); - prepareForCommit(root.containerInfo); - nextEffect = firstEffect; + if (alternate !== null) { + alternate.flags &= ~PassiveUnmountPendingDev; + } + } - do { + if (typeof destroy === "function") { { - invokeGuardedCallback(null, commitBeforeMutationEffects, null); + setCurrentFiber(fiber); + + { + invokeGuardedCallback(null, destroy, null); + } if (hasCaughtError()) { - if (!(nextEffect !== null)) { + if (!(fiber !== null)) { throw Error("Should be working on an effect."); } var error = clearCaughtError(); - captureCommitPhaseError(nextEffect, error); - nextEffect = nextEffect.nextEffect; + captureCommitPhaseError(fiber, error); } + + resetCurrentFiber(); } - } while (nextEffect !== null); + } + } // Second pass: Create new passive effects. - stopCommitSnapshotEffectsTimer(); + var mountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; - { - // Mark the current commit time to be shared by all Profilers in this - // batch. This enables them to be grouped later. - recordCommitTime(); - } // The next phase is the mutation phase, where we mutate the host tree. + for (var _i = 0; _i < mountEffects.length; _i += 2) { + var _effect2 = mountEffects[_i]; + var _fiber = mountEffects[_i + 1]; - startCommitHostEffectsTimer(); - nextEffect = firstEffect; + { + setCurrentFiber(_fiber); - do { { - invokeGuardedCallback( - null, - commitMutationEffects, - null, - root, - renderPriorityLevel - ); + invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); + } - if (hasCaughtError()) { - if (!(nextEffect !== null)) { - throw Error("Should be working on an effect."); - } + if (hasCaughtError()) { + if (!(_fiber !== null)) { + throw Error("Should be working on an effect."); + } - var _error = clearCaughtError(); + var _error4 = clearCaughtError(); - captureCommitPhaseError(nextEffect, _error); - nextEffect = nextEffect.nextEffect; - } + captureCommitPhaseError(_fiber, _error4); } - } while (nextEffect !== null); - stopCommitHostEffectsTimer(); - resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after - // the mutation phase, so that the previous tree is still current during - // componentWillUnmount, but before the layout phase, so that the finished - // work is current during componentDidMount/Update. + resetCurrentFiber(); + } + } // Note: This currently assumes there are no passive effects on the root fiber + // because the root is not part of its own effect list. + // This could change in the future. - root.current = finishedWork; // The next phase is the layout phase, where we call effects that read - // the host tree after it's been mutated. The idiomatic use case for this is - // layout, but class component lifecycles also fire here for legacy reasons. + var effect = root.current.firstEffect; - startCommitLifeCyclesTimer(); - nextEffect = firstEffect; + while (effect !== null) { + var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC - do { - { - invokeGuardedCallback( - null, - commitLayoutEffects, - null, - root, - expirationTime - ); + effect.nextEffect = null; - if (hasCaughtError()) { - if (!(nextEffect !== null)) { - throw Error("Should be working on an effect."); - } + if (effect.flags & Deletion) { + detachFiberAfterEffects(effect); + } + + effect = nextNextEffect; + } + + { + popInteractions(prevInteractions); + finishPendingInteractions(root, lanes); + } + + { + isFlushingPassiveEffects = false; + } + + executionContext = prevExecutionContext; + flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this + // exceeds the limit, we'll fire a warning. + + nestedPassiveUpdateCount = + rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; + return true; +} + +function isAlreadyFailedLegacyErrorBoundary(instance) { + return ( + legacyErrorBoundariesThatAlreadyFailed !== null && + legacyErrorBoundariesThatAlreadyFailed.has(instance) + ); +} +function markLegacyErrorBoundaryAsFailed(instance) { + if (legacyErrorBoundariesThatAlreadyFailed === null) { + legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); + } else { + legacyErrorBoundariesThatAlreadyFailed.add(instance); + } +} + +function prepareToThrowUncaughtError(error) { + if (!hasUncaughtError) { + hasUncaughtError = true; + firstUncaughtError = error; + } +} + +var onUncaughtError = prepareToThrowUncaughtError; + +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + enqueueUpdate(rootFiber, update); + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane); + + if (root !== null) { + markRootUpdated(root, SyncLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, SyncLane); + } +} + +function captureCommitPhaseError(sourceFiber, error) { + if (sourceFiber.tag === HostRoot) { + // Error was thrown at the root. There is no parent, so the root + // itself should capture it. + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + return; + } + + var fiber = sourceFiber.return; - var _error2 = clearCaughtError(); + while (fiber !== null) { + if (fiber.tag === HostRoot) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + return; + } else if (fiber.tag === ClassComponent) { + var ctor = fiber.type; + var instance = fiber.stateNode; - captureCommitPhaseError(nextEffect, _error2); - nextEffect = nextEffect.nextEffect; + if ( + typeof ctor.getDerivedStateFromError === "function" || + (typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance)) + ) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + enqueueUpdate(fiber, update); + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane); + + if (root !== null) { + markRootUpdated(root, SyncLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, SyncLane); + } else { + // This component has already been unmounted. + // We can't schedule any follow up work for the root because the fiber is already unmounted, + // but we can still call the log-only boundary so the error isn't swallowed. + // + // TODO This is only a temporary bandaid for the old reconciler fork. + // We can delete this special case once the new fork is merged. + if ( + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance) + ) { + try { + instance.componentDidCatch(error, errorInfo); + } catch (errorToIgnore) { + // TODO Ignore this error? Rethrow it? + // This is kind of an edge case. + } + } } + + return; } - } while (nextEffect !== null); + } - stopCommitLifeCyclesTimer(); - nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an - // opportunity to paint. + fiber = fiber.return; + } +} +function pingSuspendedRoot(root, wakeable, pingedLanes) { + var pingCache = root.pingCache; - requestPaint(); + if (pingCache !== null) { + // The wakeable resolved, so we no longer need to memoize, because it will + // never be thrown again. + pingCache.delete(wakeable); + } - { - popInteractions(prevInteractions); + var eventTime = requestEventTime(); + markRootPinged(root, pingedLanes); + + if ( + workInProgressRoot === root && + isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes) + ) { + // Received a ping at the same priority level at which we're currently + // rendering. We might want to restart this render. This should mirror + // the logic of whether or not a root suspends once it completes. + // TODO: If we're rendering sync either due to Sync, Batched or expired, + // we should probably never restart. + // If we're suspended with delay, or if it's a retry, we'll always suspend + // so we can always restart. + if ( + workInProgressRootExitStatus === RootSuspendedWithDelay || + (workInProgressRootExitStatus === RootSuspended && + includesOnlyRetries(workInProgressRootRenderLanes) && + now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) + ) { + // Restart from the root. + prepareFreshStack(root, NoLanes); + } else { + // Even though we can't restart right now, we might get an + // opportunity later. So we mark this render as having a ping. + workInProgressRootPingedLanes = mergeLanes( + workInProgressRootPingedLanes, + pingedLanes + ); } + } - executionContext = prevExecutionContext; - } else { - // No effects. - root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were - // no effects. - // TODO: Maybe there's a better way to report this. + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, pingedLanes); +} - startCommitSnapshotEffectsTimer(); - stopCommitSnapshotEffectsTimer(); +function retryTimedOutBoundary(boundaryFiber, retryLane) { + // The boundary fiber (a Suspense component or SuspenseList component) + // previously was rendered in its fallback state. One of the promises that + // suspended it has resolved, which means at least part of the tree was + // likely unblocked. Try rendering again, at a new expiration time. + if (retryLane === NoLane) { + retryLane = requestRetryLane(boundaryFiber); + } // TODO: Special case idle priority? - { - recordCommitTime(); - } + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane); - startCommitHostEffectsTimer(); - stopCommitHostEffectsTimer(); - startCommitLifeCyclesTimer(); - stopCommitLifeCyclesTimer(); + if (root !== null) { + markRootUpdated(root, retryLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, retryLane); } +} +function resolveRetryWakeable(boundaryFiber, wakeable) { + var retryLane = NoLane; // Default - stopCommitTimer(); - var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; + var retryCache; - if (rootDoesHavePassiveEffects) { - // This commit has passive effects. Stash a reference to them. But don't - // schedule a callback until after flushing layout work. - rootDoesHavePassiveEffects = false; - rootWithPendingPassiveEffects = root; - pendingPassiveEffectsExpirationTime = expirationTime; - pendingPassiveEffectsRenderPriority = renderPriorityLevel; - } else { - // We are done with the effect chain at this point so let's clear the - // nextEffect pointers to assist with GC. If we have passive effects, we'll - // clear this in flushPassiveEffects. - nextEffect = firstEffect; + { + retryCache = boundaryFiber.stateNode; + } - while (nextEffect !== null) { - var nextNextEffect = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = nextNextEffect; - } - } // Check if there's remaining work on this root + if (retryCache !== null) { + // The wakeable resolved, so we no longer need to memoize, because it will + // never be thrown again. + retryCache.delete(wakeable); + } - var remainingExpirationTime = root.firstPendingTime; + retryTimedOutBoundary(boundaryFiber, retryLane); +} // Computes the next Just Noticeable Difference (JND) boundary. +// The theory is that a person can't tell the difference between small differences in time. +// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable +// difference in the experience. However, waiting for longer might mean that we can avoid +// showing an intermediate loading state. The longer we have already waited, the harder it +// is to tell small differences in time. Therefore, the longer we've already waited, +// the longer we can wait additionally. At some point we have to give up though. +// We pick a train model where the next boundary commits at a consistent schedule. +// These particular numbers are vague estimates. We expect to adjust them based on research. - if (remainingExpirationTime !== NoWork) { - { - if (spawnedWorkDuringRender !== null) { - var expirationTimes = spawnedWorkDuringRender; - spawnedWorkDuringRender = null; +function jnd(timeElapsed) { + return timeElapsed < 120 + ? 120 + : timeElapsed < 480 + ? 480 + : timeElapsed < 1080 + ? 1080 + : timeElapsed < 1920 + ? 1920 + : timeElapsed < 3000 + ? 3000 + : timeElapsed < 4320 + ? 4320 + : ceil(timeElapsed / 1960) * 1960; +} - for (var i = 0; i < expirationTimes.length; i++) { - scheduleInteractions( - root, - expirationTimes[i], - root.memoizedInteractions - ); - } - } +function checkForNestedUpdates() { + if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { + nestedUpdateCount = 0; + rootWithNestedUpdates = null; - schedulePendingInteractions(root, remainingExpirationTime); + { + throw Error( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + ); } - } else { - // If there's no remaining work, we can clear the set of already failed - // error boundaries. - legacyErrorBoundariesThatAlreadyFailed = null; } { - if (!rootDidHavePassiveEffects) { - // If there are no passive effects, then we can complete the pending interactions. - // Otherwise, we'll wait until after the passive effects are flushed. - // Wait to do this until after remaining work has been scheduled, - // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. - finishPendingInteractions(root, expirationTime); + if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { + nestedPassiveUpdateCount = 0; + + error( + "Maximum update depth exceeded. This can happen when a component " + + "calls setState inside useEffect, but useEffect either doesn't " + + "have a dependency array, or one of the dependencies changes on " + + "every render." + ); } } +} - if (remainingExpirationTime === Sync) { - // Count the number of times the root synchronously re-renders without - // finishing. If there are too many, it indicates an infinite update loop. - if (root === rootWithNestedUpdates) { - nestedUpdateCount++; - } else { - nestedUpdateCount = 0; - rootWithNestedUpdates = root; +function flushRenderPhaseStrictModeWarningsInDEV() { + { + ReactStrictModeWarnings.flushLegacyContextWarning(); + + { + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); } - } else { - nestedUpdateCount = 0; } +} - onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any - // additional work on this root is scheduled. +var didWarnStateUpdateForNotYetMountedComponent = null; - ensureRootIsScheduled(root); +function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { + { + if ((executionContext & RenderContext) !== NoContext) { + // We let the other warning about render phase updates deal with this one. + return; + } - if (hasUncaughtError) { - hasUncaughtError = false; - var _error3 = firstUncaughtError; - firstUncaughtError = null; - throw _error3; - } + if (!(fiber.mode & (BlockingMode | ConcurrentMode))) { + return; + } - if ((executionContext & LegacyUnbatchedContext) !== NoContext) { - // This is a legacy edge case. We just committed the initial mount of - // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired - // synchronously, but layout updates should be deferred until the end - // of the batch. - return null; - } // If layout work was scheduled, flush it now. + var tag = fiber.tag; - flushSyncCallbackQueue(); - return null; -} + if ( + tag !== IndeterminateComponent && + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent && + tag !== Block + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. -function commitBeforeMutationEffects() { - while (nextEffect !== null) { - var effectTag = nextEffect.effectTag; + var componentName = getComponentName(fiber.type) || "ReactComponent"; - if ((effectTag & Snapshot) !== NoEffect) { - setCurrentFiber(nextEffect); - recordEffect(); - var current = nextEffect.alternate; - commitBeforeMutationLifeCycles(current, nextEffect); - resetCurrentFiber(); + if (didWarnStateUpdateForNotYetMountedComponent !== null) { + if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) { + return; + } + + didWarnStateUpdateForNotYetMountedComponent.add(componentName); + } else { + didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - if ((effectTag & Passive) !== NoEffect) { - // If there are passive effects, schedule a callback to flush at - // the earliest opportunity. - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority, function() { - flushPassiveEffects(); - return null; - }); + var previousFiber = current; + + try { + setCurrentFiber(fiber); + + error( + "Can't perform a React state update on a component that hasn't mounted yet. " + + "This indicates that you have a side-effect in your render function that " + + "asynchronously later calls tries to update the component. Move this work to " + + "useEffect instead." + ); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); } } - - nextEffect = nextEffect.nextEffect; } } -function commitMutationEffects(root, renderPriorityLevel) { - // TODO: Should probably move the bulk of this function to commitWork. - while (nextEffect !== null) { - setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; +var didWarnStateUpdateForUnmountedComponent = null; + +function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { + { + var tag = fiber.tag; + + if ( + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent && + tag !== Block + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } // If there are pending passive effects unmounts for this Fiber, + // we can assume that they would have prevented this update. + + if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) { + return; + } // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. - if (effectTag & Ref) { - var current = nextEffect.alternate; + var componentName = getComponentName(fiber.type) || "ReactComponent"; - if (current !== null) { - commitDetachRef(current); + if (didWarnStateUpdateForUnmountedComponent !== null) { + if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { + return; } - } // The following switch statement is only concerned about placement, - // updates, and deletions. To avoid needing to add a case for every possible - // bitmap value, we remove the secondary effects from the effect tag and - // switch on that value. - var primaryEffectTag = - effectTag & (Placement | Update | Deletion | Hydrating); + didWarnStateUpdateForUnmountedComponent.add(componentName); + } else { + didWarnStateUpdateForUnmountedComponent = new Set([componentName]); + } - switch (primaryEffectTag) { - case Placement: { - // inserted, before any life-cycles like componentDidMount gets called. - // TODO: findDOMNode doesn't rely on this any more but isMounted does - // and isMounted is deprecated anyway so we should be able to kill this. + if (isFlushingPassiveEffects); + else { + var previousFiber = current; - nextEffect.effectTag &= ~Placement; - break; - } + try { + setCurrentFiber(fiber); - case PlacementAndUpdate: { - // inserted, before any life-cycles like componentDidMount gets called. + error( + "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.", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function" + ); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); + } + } + } + } +} - nextEffect.effectTag &= ~Placement; // Update +var beginWork$1; - var _current = nextEffect.alternate; - commitWork(_current, nextEffect); - break; - } +{ + var dummyFiber = null; - case Hydrating: { - nextEffect.effectTag &= ~Hydrating; - break; - } + beginWork$1 = function(current, unitOfWork, lanes) { + // If a component throws an error, we replay it again in a synchronously + // dispatched event, so that the debugger will treat it as an uncaught + // error See ReactErrorUtils for more information. + // Before entering the begin phase, copy the work-in-progress onto a dummy + // fiber. If beginWork throws, we'll use this to reset the state. + var originalWorkInProgressCopy = assignFiberPropertiesInDEV( + dummyFiber, + unitOfWork + ); - case HydratingAndUpdate: { - nextEffect.effectTag &= ~Hydrating; // Update + try { + return beginWork(current, unitOfWork, lanes); + } catch (originalError) { + if ( + originalError !== null && + typeof originalError === "object" && + typeof originalError.then === "function" + ) { + // Don't replay promises. Treat everything else like an error. + throw originalError; + } // Keep this code in sync with handleError; any changes here must have + // corresponding changes there. - var _current2 = nextEffect.alternate; - commitWork(_current2, nextEffect); - break; - } + resetContextDependencies(); + resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the + // same fiber again. + // Unwind the failed stack frame - case Update: { - var _current3 = nextEffect.alternate; - commitWork(_current3, nextEffect); - break; - } + unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. - case Deletion: { - commitDeletion(root, nextEffect, renderPriorityLevel); - break; - } - } // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); - recordEffect(); - resetCurrentFiber(); - nextEffect = nextEffect.nextEffect; - } -} + if (unitOfWork.mode & ProfileMode) { + // Reset the profiler timer. + startProfilerTimer(unitOfWork); + } // Run beginWork again. -function commitLayoutEffects(root, committedExpirationTime) { - // TODO: Should probably move the bulk of this function to commitWork. - while (nextEffect !== null) { - setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; + invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); - if (effectTag & (Update | Callback)) { - recordEffect(); - var current = nextEffect.alternate; - commitLifeCycles(root, current, nextEffect); - } + if (hasCaughtError()) { + var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. - if (effectTag & Ref) { - recordEffect(); - commitAttachRef(nextEffect); + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } } - - resetCurrentFiber(); - nextEffect = nextEffect.nextEffect; - } + }; } -function flushPassiveEffects() { - if (pendingPassiveEffectsRenderPriority !== NoPriority) { - var priorityLevel = - pendingPassiveEffectsRenderPriority > NormalPriority - ? NormalPriority - : pendingPassiveEffectsRenderPriority; - pendingPassiveEffectsRenderPriority = NoPriority; - return runWithPriority(priorityLevel, flushPassiveEffectsImpl); - } +var didWarnAboutUpdateInRender = false; +var didWarnAboutUpdateInRenderForAnotherComponent; + +{ + didWarnAboutUpdateInRenderForAnotherComponent = new Set(); } -function flushPassiveEffectsImpl() { - if (rootWithPendingPassiveEffects === null) { - return false; - } +function warnAboutRenderPhaseUpdatesInDEV(fiber) { + { + if ( + isRendering && + (executionContext & RenderContext) !== NoContext && + !getIsUpdatingOpaqueValueInRenderPhaseInDEV() + ) { + switch (fiber.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + var renderingComponentName = + (workInProgress && getComponentName(workInProgress.type)) || + "Unknown"; // Dedupe by the rendering component because it's the one that needs to be fixed. - var root = rootWithPendingPassiveEffects; - var expirationTime = pendingPassiveEffectsExpirationTime; - rootWithPendingPassiveEffects = null; - pendingPassiveEffectsExpirationTime = NoWork; + var dedupeKey = renderingComponentName; - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Cannot flush passive effects while already rendering."); - } + if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { + didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); + var setStateComponentName = + getComponentName(fiber.type) || "Unknown"; - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); + error( + "Cannot update a component (`%s`) while rendering a " + + "different component (`%s`). To locate the bad setState() call inside `%s`, " + + "follow the stack trace as described in https://reactjs.org/link/setstate-in-render", + setStateComponentName, + renderingComponentName, + renderingComponentName + ); + } - { - // Note: This currently assumes there are no passive effects on the root fiber - // because the root is not part of its own effect list. - // This could change in the future. - var _effect2 = root.current.firstEffect; + break; + } - while (_effect2 !== null) { - { - setCurrentFiber(_effect2); - invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2); + case ClassComponent: { + if (!didWarnAboutUpdateInRender) { + error( + "Cannot update during an existing state transition (such as " + + "within `render`). Render methods should be a pure " + + "function of props and state." + ); - if (hasCaughtError()) { - if (!(_effect2 !== null)) { - throw Error("Should be working on an effect."); + didWarnAboutUpdateInRender = true; } - var _error5 = clearCaughtError(); - - captureCommitPhaseError(_effect2, _error5); + break; } - - resetCurrentFiber(); } - - var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC - - _effect2.nextEffect = null; - _effect2 = nextNextEffect; } } +} // a 'shared' variable that changes when act() opens/closes in tests. - { - popInteractions(prevInteractions); - finishPendingInteractions(root, expirationTime); - } +var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked +// scheduler is the actual recommendation. The alternative could be a testing build, +// a new lib, or whatever; we dunno just yet. This message is for early adopters +// to get their tests right. - executionContext = prevExecutionContext; - flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this - // exceeds the limit, we'll fire a warning. +function warnIfUnmockedScheduler(fiber) { + { + if ( + didWarnAboutUnmockedScheduler === false && + Scheduler.unstable_flushAllWithoutAsserting === undefined + ) { + if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { + didWarnAboutUnmockedScheduler = true; - nestedPassiveUpdateCount = - rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; - return true; + error( + 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + + "to guarantee consistent behaviour across tests and browsers. " + + "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. + "jest.mock('scheduler', () => require" + + "('scheduler/unstable_mock'));\n\n" + + "For more info, visit https://reactjs.org/link/mock-scheduler" + ); + } + } + } } -function isAlreadyFailedLegacyErrorBoundary(instance) { - return ( - legacyErrorBoundariesThatAlreadyFailed !== null && - legacyErrorBoundariesThatAlreadyFailed.has(instance) - ); +function computeThreadID(root, lane) { + // Interaction threads are unique per root and expiration time. + // NOTE: Intentionally unsound cast. All that matters is that it's a number + // and it represents a batch of work. Could make a helper function instead, + // but meh this is fine for now. + return lane * 1000 + root.interactionThreadID; } -function markLegacyErrorBoundaryAsFailed(instance) { - if (legacyErrorBoundariesThatAlreadyFailed === null) { - legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); + +function markSpawnedWork(lane) { + if (spawnedWorkDuringRender === null) { + spawnedWorkDuringRender = [lane]; } else { - legacyErrorBoundariesThatAlreadyFailed.add(instance); + spawnedWorkDuringRender.push(lane); } } -function prepareToThrowUncaughtError(error) { - if (!hasUncaughtError) { - hasUncaughtError = true; - firstUncaughtError = error; - } -} +function scheduleInteractions(root, lane, interactions) { + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(lane); -var onUncaughtError = prepareToThrowUncaughtError; + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } -function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { - var errorInfo = createCapturedValue(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); - enqueueUpdate(rootFiber, update); - var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); + pendingInteractions.add(interaction); + }); + } else { + pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions. - if (root !== null) { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, Sync); + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + + var subscriber = tracing.__subscriberRef.current; + + if (subscriber !== null) { + var threadID = computeThreadID(root, lane); + subscriber.onWorkScheduled(interactions, threadID); + } } } -function captureCommitPhaseError(sourceFiber, error) { - if (sourceFiber.tag === HostRoot) { - // Error was thrown at the root. There is no parent, so the root - // itself should capture it. - captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); - return; - } +function schedulePendingInteractions(root, lane) { + scheduleInteractions(root, lane, tracing.__interactionsRef.current); +} + +function startWorkOnPendingInteractions(root, lanes) { + // we can accurately attribute time spent working on it, And so that cascading + // work triggered during the render phase will be associated with it. - var fiber = sourceFiber.return; + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledLane + ) { + if (includesSomeLane(lanes, scheduledLane)) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + } + }); // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like performConcurrentWorkOnRoot() + // without having to recalculate it. We will also use it in commitWork() to + // pass to any Profiler onRender() hooks. This also provides DevTools with a + // way to access it when the onCommitRoot() hook is called. - while (fiber !== null) { - if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); - return; - } else if (fiber.tag === ClassComponent) { - var ctor = fiber.type; - var instance = fiber.stateNode; + root.memoizedInteractions = interactions; - if ( - typeof ctor.getDerivedStateFromError === "function" || - (typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance)) - ) { - var errorInfo = createCapturedValue(error, sourceFiber); - var update = createClassErrorUpdate( - fiber, - errorInfo, // TODO: This is always sync - Sync - ); - enqueueUpdate(fiber, update); - var root = markUpdateTimeFromFiberToRoot(fiber, Sync); + if (interactions.size > 0) { + var subscriber = tracing.__subscriberRef.current; - if (root !== null) { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, Sync); - } + if (subscriber !== null) { + var threadID = computeThreadID(root, lanes); - return; + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function() { + throw error; + }); } } - - fiber = fiber.return; } } -function pingSuspendedRoot(root, thenable, suspendedTime) { - var pingCache = root.pingCache; - if (pingCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - pingCache.delete(thenable); - } +function finishPendingInteractions(root, committedLanes) { + var remainingLanesAfterCommit = root.pendingLanes; + var subscriber; - if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { - // Received a ping at the same priority level at which we're currently - // rendering. We might want to restart this render. This should mirror - // the logic of whether or not a root suspends once it completes. - // TODO: If we're rendering sync either due to Sync, Batched or expired, - // we should probably never restart. - // If we're suspended with delay, we'll always suspend so we can always - // restart. If we're suspended without any updates, it might be a retry. - // If it's early in the retry we can restart. We can't know for sure - // whether we'll eventually process an update during this render pass, - // but it's somewhat unlikely that we get to a ping before that, since - // getting to the root most update is usually very fast. - if ( - workInProgressRootExitStatus === RootSuspendedWithDelay || - (workInProgressRootExitStatus === RootSuspended && - workInProgressRootLatestProcessedExpirationTime === Sync && - now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) - ) { - // Restart from the root. Don't need to schedule a ping because - // we're already working on this tree. - prepareFreshStack(root, renderExpirationTime$1); - } else { - // Even though we can't restart right now, we might get an - // opportunity later. So we mark this render as having a ping. - workInProgressRootHasPendingPing = true; - } + try { + subscriber = tracing.__subscriberRef.current; - return; - } + if (subscriber !== null && root.memoizedInteractions.size > 0) { + // FIXME: More than one lane can finish in a single commit. + var threadID = computeThreadID(root, committedLanes); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); + } + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function() { + throw error; + }); + } finally { + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function(scheduledInteractions, lane) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if (!includesSomeLane(remainingLanesAfterCommit, lane)) { + pendingInteractionMap.delete(lane); + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; - if (!isRootSuspendedAtTime(root, suspendedTime)) { - // The root is no longer suspended at this time. - return; + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function() { + throw error; + }); + } + } + }); + } + }); } +} // `act` testing API - var lastPingedTime = root.lastPingedTime; +function shouldForceFlushFallbacksInDEV() { + // Never force flush in production. This function should get stripped out. + return actingUpdatesScopeDepth > 0; +} +// so we can tell if any async act() calls try to run in parallel. - if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) { - // There's already a lower priority ping scheduled. - return; - } // Mark the time at which this ping was scheduled. +var actingUpdatesScopeDepth = 0; - root.lastPingedTime = suspendedTime; - ensureRootIsScheduled(root); - schedulePendingInteractions(root, suspendedTime); +function detachFiberAfterEffects(fiber) { + fiber.sibling = null; + fiber.stateNode = null; } -function retryTimedOutBoundary(boundaryFiber, retryTime) { - // The boundary fiber (a Suspense component or SuspenseList component) - // previously was rendered in its fallback state. One of the promises that - // suspended it has resolved, which means at least part of the tree was - // likely unblocked. Try rendering again, at a new expiration time. - if (retryTime === NoWork) { - var suspenseConfig = null; // Retries don't carry over the already committed update. - - var currentTime = requestCurrentTimeForUpdate(); - retryTime = computeExpirationForFiber( - currentTime, - boundaryFiber, - suspenseConfig - ); - } // TODO: Special case idle priority? +var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. + +var failedBoundaries = null; +var setRefreshHandler = function(handler) { + { + resolveFamily = handler; + } +}; +function resolveFunctionForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } + + var family = resolveFamily(type); - var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); + if (family === undefined) { + return type; + } // Use the latest known implementation. - if (root !== null) { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, retryTime); + return family.current; } } -function resolveRetryThenable(boundaryFiber, thenable) { - var retryTime = NoWork; // Default +function resolveClassForHotReloading(type) { + // No implementation differences. + return resolveFunctionForHotReloading(type); +} +function resolveForwardRefForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } - var retryCache; + var family = resolveFamily(type); - { - retryCache = boundaryFiber.stateNode; - } + if (family === undefined) { + // Check if we're dealing with a real forwardRef. Don't want to crash early. + if ( + type !== null && + type !== undefined && + typeof type.render === "function" + ) { + // ForwardRef is special because its resolved .type is an object, + // but it's possible that we only have its inner render function in the map. + // If that inner render function is different, we'll build a new forwardRef type. + var currentRender = resolveFunctionForHotReloading(type.render); - if (retryCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - retryCache.delete(thenable); - } + if (type.render !== currentRender) { + var syntheticType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: currentRender + }; - retryTimedOutBoundary(boundaryFiber, retryTime); -} // Computes the next Just Noticeable Difference (JND) boundary. -// The theory is that a person can't tell the difference between small differences in time. -// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable -// difference in the experience. However, waiting for longer might mean that we can avoid -// showing an intermediate loading state. The longer we have already waited, the harder it -// is to tell small differences in time. Therefore, the longer we've already waited, -// the longer we can wait additionally. At some point we have to give up though. -// We pick a train model where the next boundary commits at a consistent schedule. -// These particular numbers are vague estimates. We expect to adjust them based on research. + if (type.displayName !== undefined) { + syntheticType.displayName = type.displayName; + } -function jnd(timeElapsed) { - return timeElapsed < 120 - ? 120 - : timeElapsed < 480 - ? 480 - : timeElapsed < 1080 - ? 1080 - : timeElapsed < 1920 - ? 1920 - : timeElapsed < 3000 - ? 3000 - : timeElapsed < 4320 - ? 4320 - : ceil(timeElapsed / 1960) * 1960; -} + return syntheticType; + } + } -function computeMsUntilSuspenseLoadingDelay( - mostRecentEventTime, - committedExpirationTime, - suspenseConfig -) { - var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; + return type; + } // Use the latest known implementation. - if (busyMinDurationMs <= 0) { - return 0; + return family.current; } +} +function isCompatibleFamilyForHotReloading(fiber, element) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return false; + } - var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. + var prevType = fiber.elementType; + var nextType = element.type; // If we got here, we know types aren't === equal. - var currentTimeMs = now(); - var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig( - mostRecentEventTime, - suspenseConfig - ); - var timeElapsed = currentTimeMs - eventTimeMs; + var needsCompareFamilies = false; + var $$typeofNextType = + typeof nextType === "object" && nextType !== null + ? nextType.$$typeof + : null; - if (timeElapsed <= busyDelayMs) { - // If we haven't yet waited longer than the initial delay, we don't - // have to wait any additional time. - return 0; - } + switch (fiber.tag) { + case ClassComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } - var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`. + break; + } - return msUntilTimeout; -} + case FunctionComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + // We don't know the inner type yet. + // We're going to assume that the lazy inner type is stable, + // and so it is sufficient to avoid reconciling it away. + // We're not going to unwrap or actually use the new lazy type. + needsCompareFamilies = true; + } -function checkForNestedUpdates() { - if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { - nestedUpdateCount = 0; - rootWithNestedUpdates = null; + break; + } + + case ForwardRef: { + if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } + + break; + } + + case MemoComponent: + case SimpleMemoComponent: { + if ($$typeofNextType === REACT_MEMO_TYPE) { + // TODO: if it was but can no longer be simple, + // we shouldn't set this. + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } - { - throw Error( - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ); - } - } + break; + } - { - if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { - nestedPassiveUpdateCount = 0; + default: + return false; + } // Check if both types have a family and it's the same one. - error( - "Maximum update depth exceeded. This can happen when a component " + - "calls setState inside useEffect, but useEffect either doesn't " + - "have a dependency array, or one of the dependencies changes on " + - "every render." - ); + if (needsCompareFamilies) { + // Note: memo() and forwardRef() we'll compare outer rather than inner type. + // This means both of them need to be registered to preserve state. + // If we unwrapped and compared the inner types for wrappers instead, + // then we would risk falsely saying two separate memo(Foo) + // calls are equivalent because they wrap the same Foo function. + var prevFamily = resolveFamily(prevType); + + if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { + return true; + } } + + return false; } } - -function flushRenderPhaseStrictModeWarningsInDEV() { +function markFailedErrorBoundaryForHotReloading(fiber) { { - ReactStrictModeWarnings.flushLegacyContextWarning(); - - { - ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + if (resolveFamily === null) { + // Hot reloading is disabled. + return; } - } -} -function stopFinishedWorkLoopTimer() { - var didCompleteRoot = true; - stopWorkLoopTimer(interruptedBy, didCompleteRoot); - interruptedBy = null; -} + if (typeof WeakSet !== "function") { + return; + } -function stopInterruptedWorkLoopTimer() { - // TODO: Track which fiber caused the interruption. - var didCompleteRoot = false; - stopWorkLoopTimer(interruptedBy, didCompleteRoot); - interruptedBy = null; -} + if (failedBoundaries === null) { + failedBoundaries = new WeakSet(); + } -function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { - if ( - workInProgressRoot !== null && - updateExpirationTime > renderExpirationTime$1 - ) { - interruptedBy = fiberThatReceivedUpdate; + failedBoundaries.add(fiber); } } - -var didWarnStateUpdateForUnmountedComponent = null; - -function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { +var scheduleRefresh = function(root, update) { { - var tag = fiber.tag; - - if ( - tag !== HostRoot && - tag !== ClassComponent && - tag !== FunctionComponent && - tag !== ForwardRef && - tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block - ) { - // Only warn for user-defined components, not internal ones like Suspense. + if (resolveFamily === null) { + // Hot reloading is disabled. return; } - // the problematic code almost always lies inside that component. - - var componentName = getComponentName(fiber.type) || "ReactComponent"; - - if (didWarnStateUpdateForUnmountedComponent !== null) { - if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { - return; - } - didWarnStateUpdateForUnmountedComponent.add(componentName); - } else { - didWarnStateUpdateForUnmountedComponent = new Set([componentName]); + var staleFamilies = update.staleFamilies, + updatedFamilies = update.updatedFamilies; + flushPassiveEffects(); + flushSync(function() { + scheduleFibersWithFamiliesRecursively( + root.current, + updatedFamilies, + staleFamilies + ); + }); + } +}; +var scheduleRoot = function(root, element) { + { + if (root.context !== emptyContextObject) { + // Super edge case: root has a legacy _renderSubtree context + // but we don't know the parentComponent so we can't pass it. + // Just ignore. We'll delete this with _renderSubtree code path later. + return; } - error( - "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) - ); + flushPassiveEffects(); + flushSync(function() { + updateContainer(element, root, null, null); + }); } -} - -var beginWork$1; - -{ - var dummyFiber = null; - - beginWork$1 = function(current, unitOfWork, expirationTime) { - // If a component throws an error, we replay it again in a synchronously - // dispatched event, so that the debugger will treat it as an uncaught - // error See ReactErrorUtils for more information. - // Before entering the begin phase, copy the work-in-progress onto a dummy - // fiber. If beginWork throws, we'll use this to reset the state. - var originalWorkInProgressCopy = assignFiberPropertiesInDEV( - dummyFiber, - unitOfWork - ); - - try { - return beginWork(current, unitOfWork, expirationTime); - } catch (originalError) { - if ( - originalError !== null && - typeof originalError === "object" && - typeof originalError.then === "function" - ) { - // Don't replay promises. Treat everything else like an error. - throw originalError; - } // Keep this code in sync with handleError; any changes here must have - // corresponding changes there. - - resetContextDependencies(); - resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the - // same fiber again. - // Unwind the failed stack frame - - unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. - - assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); - - if (unitOfWork.mode & ProfileMode) { - // Reset the profiler timer. - startProfilerTimer(unitOfWork); - } // Run beginWork again. +}; - invokeGuardedCallback( - null, - beginWork, - null, - current, - unitOfWork, - expirationTime - ); +function scheduleFibersWithFamiliesRecursively( + fiber, + updatedFamilies, + staleFamilies +) { + { + var alternate = fiber.alternate, + child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; - if (hasCaughtError()) { - var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. - // Rethrow this error instead of the original one. + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; - throw replayError; - } else { - // This branch is reachable if the render phase is impure. - throw originalError; - } + case ForwardRef: + candidateType = type.render; + break; } - }; -} - -var didWarnAboutUpdateInRender = false; -function warnAboutRenderPhaseUpdatesInDEV(fiber) { - { - if ((executionContext & RenderContext) !== NoContext) { - switch (fiber.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - error( - "Cannot update a component from inside the function body of a " + - "different component." - ); + if (resolveFamily === null) { + throw new Error("Expected resolveFamily to be set during hot reload."); + } - break; - } + var needsRender = false; + var needsRemount = false; - case ClassComponent: { - if (isRendering && !didWarnAboutUpdateInRender) { - error( - "Cannot update during an existing state transition (such as " + - "within `render`). Render methods should be a pure " + - "function of props and state." - ); + if (candidateType !== null) { + var family = resolveFamily(candidateType); - didWarnAboutUpdateInRender = true; - break; + if (family !== undefined) { + if (staleFamilies.has(family)) { + needsRemount = true; + } else if (updatedFamilies.has(family)) { + if (tag === ClassComponent) { + needsRemount = true; + } else { + needsRender = true; } } } } - } -} // a 'shared' variable that changes when act() opens/closes in tests. - -var IsThisRendererActing = { - current: false -}; - -var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked -// scheduler is the actual recommendation. The alternative could be a testing build, -// a new lib, or whatever; we dunno just yet. This message is for early adopters -// to get their tests right. - -function warnIfUnmockedScheduler(fiber) { - { - if ( - didWarnAboutUnmockedScheduler === false && - Scheduler.unstable_flushAllWithoutAsserting === undefined - ) { - if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { - didWarnAboutUnmockedScheduler = true; - error( - 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + - "to guarantee consistent behaviour across tests and browsers. " + - "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. - "jest.mock('scheduler', () => require" + - "('scheduler/unstable_mock'));\n\n" + - "For more info, visit https://fb.me/react-mock-scheduler" - ); + if (failedBoundaries !== null) { + if ( + failedBoundaries.has(fiber) || + (alternate !== null && failedBoundaries.has(alternate)) + ) { + needsRemount = true; } } - } -} - -function computeThreadID(root, expirationTime) { - // Interaction threads are unique per root and expiration time. - return expirationTime * 1000 + root.interactionThreadID; -} - -function markSpawnedWork(expirationTime) { - if (spawnedWorkDuringRender === null) { - spawnedWorkDuringRender = [expirationTime]; - } else { - spawnedWorkDuringRender.push(expirationTime); - } -} - -function scheduleInteractions(root, expirationTime, interactions) { - if (interactions.size > 0) { - var pendingInteractionMap = root.pendingInteractionMap; - var pendingInteractions = pendingInteractionMap.get(expirationTime); - - if (pendingInteractions != null) { - interactions.forEach(function(interaction) { - if (!pendingInteractions.has(interaction)) { - // Update the pending async work count for previously unscheduled interaction. - interaction.__count++; - } - pendingInteractions.add(interaction); - }); - } else { - pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions. + if (needsRemount) { + fiber._debugNeedsRemount = true; + } - interactions.forEach(function(interaction) { - interaction.__count++; - }); + if (needsRemount || needsRender) { + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); } - var subscriber = tracing.__subscriberRef.current; + if (child !== null && !needsRemount) { + scheduleFibersWithFamiliesRecursively( + child, + updatedFamilies, + staleFamilies + ); + } - if (subscriber !== null) { - var threadID = computeThreadID(root, expirationTime); - subscriber.onWorkScheduled(interactions, threadID); + if (sibling !== null) { + scheduleFibersWithFamiliesRecursively( + sibling, + updatedFamilies, + staleFamilies + ); } } } -function schedulePendingInteractions(root, expirationTime) { - scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); -} - -function startWorkOnPendingInteractions(root, expirationTime) { - // we can accurately attribute time spent working on it, And so that cascading - // work triggered during the render phase will be associated with it. +var findHostInstancesForRefresh = function(root, families) { + { + var hostInstances = new Set(); + var types = new Set( + families.map(function(family) { + return family.current; + }) + ); + findHostInstancesForMatchingFibersRecursively( + root.current, + types, + hostInstances + ); + return hostInstances; + } +}; - var interactions = new Set(); - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - if (scheduledExpirationTime >= expirationTime) { - scheduledInteractions.forEach(function(interaction) { - return interactions.add(interaction); - }); - } - }); // Store the current set of interactions on the FiberRoot for a few reasons: - // We can re-use it in hot functions like performConcurrentWorkOnRoot() - // without having to recalculate it. We will also use it in commitWork() to - // pass to any Profiler onRender() hooks. This also provides DevTools with a - // way to access it when the onCommitRoot() hook is called. +function findHostInstancesForMatchingFibersRecursively( + fiber, + types, + hostInstances +) { + { + var child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; - root.memoizedInteractions = interactions; + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; - if (interactions.size > 0) { - var subscriber = tracing.__subscriberRef.current; + case ForwardRef: + candidateType = type.render; + break; + } - if (subscriber !== null) { - var threadID = computeThreadID(root, expirationTime); + var didMatch = false; - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { - throw error; - }); + if (candidateType !== null) { + if (types.has(candidateType)) { + didMatch = true; } } - } -} - -function finishPendingInteractions(root, committedExpirationTime) { - var earliestRemainingTimeAfterCommit = root.firstPendingTime; - var subscriber; - - try { - subscriber = tracing.__subscriberRef.current; - if (subscriber !== null && root.memoizedInteractions.size > 0) { - var threadID = computeThreadID(root, committedExpirationTime); - subscriber.onWorkStopped(root.memoizedInteractions, threadID); + if (didMatch) { + // We have a match. This only drills down to the closest host components. + // There's no need to search deeper because for the purpose of giving + // visual feedback, "flashing" outermost parent rectangles is sufficient. + findHostInstancesForFiberShallowly(fiber, hostInstances); + } else { + // If there's no match, maybe there will be one further down in the child tree. + if (child !== null) { + findHostInstancesForMatchingFibersRecursively( + child, + types, + hostInstances + ); + } } - } catch (error) { - // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { - throw error; - }); - } finally { - // Clear completed interactions from the pending Map. - // Unless the render was suspended or cascading work was scheduled, - // In which case– leave pending interactions until the subsequent render. - var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - // Only decrement the pending interaction count if we're done. - // If there's still work at the current priority, - // That indicates that we are waiting for suspense data. - if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { - pendingInteractionMap.delete(scheduledExpirationTime); - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - if (subscriber !== null && interaction.__count === 0) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { - throw error; - }); - } - } - }); - } - }); + if (sibling !== null) { + findHostInstancesForMatchingFibersRecursively( + sibling, + types, + hostInstances + ); + } } } -var onScheduleFiberRoot = null; -var onCommitFiberRoot = null; -var onCommitFiberUnmount = null; -var hasLoggedError = false; -var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; -function injectInternals(internals) { - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { - // No DevTools - return false; - } +function findHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var foundHostInstances = findChildHostInstancesForFiberShallowly( + fiber, + hostInstances + ); - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if (foundHostInstances) { + return; + } // If we didn't find any host children, fallback to closest host parent. - if (hook.isDisabled) { - // This isn't a real property on the hook, but it can be set to opt out - // of DevTools integration and associated warnings and logs. - // https://github.com/facebook/react/issues/3877 - return true; - } + var node = fiber; - if (!hook.supportsFiber) { - { - error( - "The installed version of React DevTools is too old and will not work " + - "with the current version of React. Please update React DevTools. " + - "https://fb.me/react-devtools" - ); - } // DevTools exists, even though it doesn't support Fiber. + while (true) { + switch (node.tag) { + case HostComponent: + hostInstances.add(node.stateNode); + return; - return true; - } + case HostPortal: + hostInstances.add(node.stateNode.containerInfo); + return; - try { - var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + case HostRoot: + hostInstances.add(node.stateNode.containerInfo); + return; + } - if (true) { - // Only used by Fast Refresh - if (typeof hook.onScheduleFiberRoot === "function") { - onScheduleFiberRoot = function(root, children) { - try { - hook.onScheduleFiberRoot(rendererID, root, children); - } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - }; + if (node.return === null) { + throw new Error("Expected to reach root first."); } - } - onCommitFiberRoot = function(root, expirationTime) { - try { - var didError = (root.current.effectTag & DidCapture) === DidCapture; + node = node.return; + } + } +} - if (enableProfilerTimer) { - var currentTime = getCurrentTime(); - var priorityLevel = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); - hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); - } else { - hook.onCommitFiberRoot(rendererID, root, undefined, didError); - } - } catch (err) { - if (true) { - if (!hasLoggedError) { - hasLoggedError = true; +function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var node = fiber; + var foundHostInstances = false; - error("React instrumentation encountered an error: %s", err); - } - } + while (true) { + if (node.tag === HostComponent) { + // We got a match. + foundHostInstances = true; + hostInstances.add(node.stateNode); // There may still be more, so keep searching. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; } - }; - onCommitFiberUnmount = function(fiber) { - try { - hook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) { - if (true) { - if (!hasLoggedError) { - hasLoggedError = true; + if (node === fiber) { + return foundHostInstances; + } - error("React instrumentation encountered an error: %s", err); - } + while (node.sibling === null) { + if (node.return === null || node.return === fiber) { + return foundHostInstances; } + + node = node.return; } - }; - } catch (err) { - // Catch all errors because it is unsafe to throw during initialization. - { - error("React instrumentation encountered an error: %s.", err); - } - } // DevTools exists - return true; -} -function onScheduleRoot(root, children) { - if (typeof onScheduleFiberRoot === "function") { - onScheduleFiberRoot(root, children); - } -} -function onCommitRoot(root, expirationTime) { - if (typeof onCommitFiberRoot === "function") { - onCommitFiberRoot(root, expirationTime); - } -} -function onCommitUnmount(fiber) { - if (typeof onCommitFiberUnmount === "function") { - onCommitFiberUnmount(fiber); + node.sibling.return = node.return; + node = node.sibling; + } } + + return false; } var hasBadMapPolyfill; @@ -19031,13 +19979,11 @@ var hasBadMapPolyfill; try { var nonExtensibleObject = Object.preventExtensions({}); - var testMap = new Map([[nonExtensibleObject, null]]); - var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused. - // https://github.com/rollup/rollup/issues/1771 - // TODO: we can remove these if Rollup fixes the bug. + /* eslint-disable no-new */ - testMap.set(0, 0); - testSet.add(0); + new Map([[nonExtensibleObject, null]]); + new Set([nonExtensibleObject]); + /* eslint-enable no-new */ } catch (e) { // TODO: Consider warning about bad polyfills hasBadMapPolyfill = true; @@ -19066,12 +20012,12 @@ function FiberNode(tag, pendingProps, key, mode) { this.dependencies = null; this.mode = mode; // Effects - this.effectTag = NoEffect; + this.flags = NoFlags; this.nextEffect = null; this.firstEffect = null; this.lastEffect = null; - this.expirationTime = NoWork; - this.childExpirationTime = NoWork; + this.lanes = NoLanes; + this.childLanes = NoLanes; this.alternate = null; { @@ -19098,15 +20044,11 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.selfBaseDuration = 0; this.treeBaseDuration = 0; - } // This is normally DEV-only except www when it adds listeners. - // TODO: remove the User Timing integration in favor of Root Events. - - { - this._debugID = debugCounter++; - this._debugIsCurrentlyTiming = false; } { + // This isn't directly used but is handy for debugging internals: + this._debugID = debugCounter++; this._debugSource = null; this._debugOwner = null; this._debugNeedsRemount = false; @@ -19186,10 +20128,7 @@ function createWorkInProgress(current, pendingProps) { { // DEV-only fields - { - workInProgress._debugID = current._debugID; - } - + workInProgress._debugID = current._debugID; workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; workInProgress._debugHookTypes = current._debugHookTypes; @@ -19198,10 +20137,12 @@ function createWorkInProgress(current, pendingProps) { workInProgress.alternate = current; current.alternate = workInProgress; } else { - workInProgress.pendingProps = pendingProps; // We already have an alternate. + workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type. + + workInProgress.type = current.type; // We already have an alternate. // Reset the effect tag. - workInProgress.effectTag = NoEffect; // The effect list is no longer valid. + workInProgress.flags = NoFlags; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -19217,8 +20158,8 @@ function createWorkInProgress(current, pendingProps) { } } - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -19230,9 +20171,8 @@ function createWorkInProgress(current, pendingProps) { currentDependencies === null ? null : { - expirationTime: currentDependencies.expirationTime, - firstContext: currentDependencies.firstContext, - responders: currentDependencies.responders + lanes: currentDependencies.lanes, + firstContext: currentDependencies.firstContext }; // These will be overridden during the parent's reconciliation workInProgress.sibling = current.sibling; @@ -19267,7 +20207,7 @@ function createWorkInProgress(current, pendingProps) { return workInProgress; } // Used to reuse a Fiber for a second pass. -function resetWorkInProgress(workInProgress, renderExpirationTime) { +function resetWorkInProgress(workInProgress, renderLanes) { // This resets the Fiber to what createFiber or createWorkInProgress would // have set the values to before during the first pass. Ideally this wouldn't // be necessary but unfortunately many code paths reads from the workInProgress @@ -19276,7 +20216,7 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { // avoid doing another reconciliation. // Reset the effect tag but keep any Placement tags, since that's something // that child fiber is setting, not the reconciliation. - workInProgress.effectTag &= Placement; // The effect list is no longer valid. + workInProgress.flags &= Placement; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -19285,13 +20225,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { if (current === null) { // Reset to createFiber's initial values. - workInProgress.childExpirationTime = NoWork; - workInProgress.expirationTime = renderExpirationTime; + workInProgress.childLanes = NoLanes; + workInProgress.lanes = renderLanes; workInProgress.child = null; workInProgress.memoizedProps = null; workInProgress.memoizedState = null; workInProgress.updateQueue = null; workInProgress.dependencies = null; + workInProgress.stateNode = null; { // Note: We don't reset the actualTime counts. It's useful to accumulate @@ -19301,12 +20242,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { } } else { // Reset to the cloned values that createWorkInProgress would've. - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; - workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so + workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. + + workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so // it cannot be shared with the current fiber. var currentDependencies = current.dependencies; @@ -19314,9 +20257,8 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { currentDependencies === null ? null : { - expirationTime: currentDependencies.expirationTime, - firstContext: currentDependencies.firstContext, - responders: currentDependencies.responders + lanes: currentDependencies.lanes, + firstContext: currentDependencies.firstContext }; { @@ -19355,9 +20297,8 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - expirationTime + lanes ) { - var fiber; var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy. var resolvedType = type; @@ -19379,16 +20320,11 @@ function createFiberFromTypeAndProps( } else { getTag: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment( - pendingProps.children, - mode, - expirationTime, - key - ); + return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_CONCURRENT_MODE_TYPE: + case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = Mode; - mode |= ConcurrentMode | BlockingMode | StrictMode; + mode |= DebugTracingMode; break; case REACT_STRICT_MODE_TYPE: @@ -19397,18 +20333,23 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: - return createFiberFromProfiler(pendingProps, mode, expirationTime, key); + return createFiberFromProfiler(pendingProps, mode, lanes, key); case REACT_SUSPENSE_TYPE: - return createFiberFromSuspense(pendingProps, mode, expirationTime, key); + return createFiberFromSuspense(pendingProps, mode, lanes, key); case REACT_SUSPENSE_LIST_TYPE: - return createFiberFromSuspenseList( - pendingProps, - mode, - expirationTime, - key - ); + return createFiberFromSuspenseList(pendingProps, mode, lanes, key); + + case REACT_OFFSCREEN_TYPE: + return createFiberFromOffscreen(pendingProps, mode, lanes, key); + + case REACT_LEGACY_HIDDEN_TYPE: + return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); + + case REACT_SCOPE_TYPE: + + // eslint-disable-next-line no-fallthrough default: { if (typeof type === "object" && type !== null) { @@ -19480,13 +20421,18 @@ function createFiberFromTypeAndProps( } } - fiber = createFiber(fiberTag, pendingProps, key, mode); + var fiber = createFiber(fiberTag, pendingProps, key, mode); fiber.elementType = type; fiber.type = resolvedType; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; + + { + fiber._debugOwner = owner; + } + return fiber; } -function createFiberFromElement(element, mode, expirationTime) { +function createFiberFromElement(element, mode, lanes) { var owner = null; { @@ -19502,7 +20448,7 @@ function createFiberFromElement(element, mode, expirationTime) { pendingProps, owner, mode, - expirationTime + lanes ); { @@ -19512,13 +20458,13 @@ function createFiberFromElement(element, mode, expirationTime) { return fiber; } -function createFiberFromFragment(elements, mode, expirationTime, key) { +function createFiberFromFragment(elements, mode, lanes, key) { var fiber = createFiber(Fragment, elements, key, mode); - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; return fiber; } -function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { +function createFiberFromProfiler(pendingProps, mode, lanes, key) { { if (typeof pendingProps.id !== "string") { error('Profiler must specify an "id" as a prop'); @@ -19529,7 +20475,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; { fiber.stateNode = { @@ -19541,17 +20487,17 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { return fiber; } -function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { +function createFiberFromSuspense(pendingProps, mode, lanes, key) { var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. // This needs to be fixed in getComponentName so that it relies on the tag // instead. fiber.type = REACT_SUSPENSE_TYPE; fiber.elementType = REACT_SUSPENSE_TYPE; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; return fiber; } -function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { +function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); { @@ -19562,18 +20508,44 @@ function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { } fiber.elementType = REACT_SUSPENSE_LIST_TYPE; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; + return fiber; +} +function createFiberFromOffscreen(pendingProps, mode, lanes, key) { + var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + + { + fiber.type = REACT_OFFSCREEN_TYPE; + } + + fiber.elementType = REACT_OFFSCREEN_TYPE; + fiber.lanes = lanes; + return fiber; +} +function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) { + var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + + { + fiber.type = REACT_LEGACY_HIDDEN_TYPE; + } + + fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; + fiber.lanes = lanes; return fiber; } -function createFiberFromText(content, mode, expirationTime) { +function createFiberFromText(content, mode, lanes) { var fiber = createFiber(HostText, content, null, mode); - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; return fiber; } -function createFiberFromPortal(portal, mode, expirationTime) { +function createFiberFromPortal(portal, mode, lanes) { var pendingProps = portal.children !== null ? portal.children : []; var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; fiber.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -19610,12 +20582,12 @@ function assignFiberPropertiesInDEV(target, source) { target.memoizedState = source.memoizedState; target.dependencies = source.dependencies; target.mode = source.mode; - target.effectTag = source.effectTag; + target.flags = source.flags; target.nextEffect = source.nextEffect; target.firstEffect = source.firstEffect; target.lastEffect = source.lastEffect; - target.expirationTime = source.expirationTime; - target.childExpirationTime = source.childExpirationTime; + target.lanes = source.lanes; + target.childLanes = source.childLanes; target.alternate = source.alternate; { @@ -19625,11 +20597,7 @@ function assignFiberPropertiesInDEV(target, source) { target.treeBaseDuration = source.treeBaseDuration; } - { - target._debugID = source._debugID; - target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; - } - + target._debugID = source._debugID; target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugNeedsRemount = source._debugNeedsRemount; @@ -19639,30 +20607,49 @@ function assignFiberPropertiesInDEV(target, source) { function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; - this.current = null; this.containerInfo = containerInfo; this.pendingChildren = null; + this.current = null; this.pingCache = null; - this.finishedExpirationTime = NoWork; this.finishedWork = null; this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = NoPriority; - this.firstPendingTime = NoWork; - this.firstSuspendedTime = NoWork; - this.lastSuspendedTime = NoWork; - this.nextKnownPendingLevel = NoWork; - this.lastPingedTime = NoWork; - this.lastExpiredTime = NoWork; + this.callbackPriority = NoLanePriority; + this.eventTimes = createLaneMap(NoLanes); + this.expirationTimes = createLaneMap(NoTimestamp); + this.pendingLanes = NoLanes; + this.suspendedLanes = NoLanes; + this.pingedLanes = NoLanes; + this.expiredLanes = NoLanes; + this.mutableReadLanes = NoLanes; + this.finishedLanes = NoLanes; + this.entangledLanes = NoLanes; + this.entanglements = createLaneMap(NoLanes); { this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } + + { + switch (tag) { + case BlockingRoot: + this._debugRootType = "createBlockingRoot()"; + break; + + case ConcurrentRoot: + this._debugRootType = "createRoot()"; + break; + + case LegacyRoot: + this._debugRootType = "createLegacyRoot()"; + break; + } + } } function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { @@ -19675,95 +20662,22 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { initializeUpdateQueue(uninitializedFiber); return root; } -function isRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - var lastSuspendedTime = root.lastSuspendedTime; - return ( - firstSuspendedTime !== NoWork && - firstSuspendedTime >= expirationTime && - lastSuspendedTime <= expirationTime - ); -} -function markRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - var lastSuspendedTime = root.lastSuspendedTime; - - if (firstSuspendedTime < expirationTime) { - root.firstSuspendedTime = expirationTime; - } - - if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) { - root.lastSuspendedTime = expirationTime; - } - - if (expirationTime <= root.lastPingedTime) { - root.lastPingedTime = NoWork; - } - - if (expirationTime <= root.lastExpiredTime) { - root.lastExpiredTime = NoWork; - } -} -function markRootUpdatedAtTime(root, expirationTime) { - // Update the range of pending times - var firstPendingTime = root.firstPendingTime; - - if (expirationTime > firstPendingTime) { - root.firstPendingTime = expirationTime; - } // Update the range of suspended times. Treat everything lower priority or - // equal to this update as unsuspended. - var firstSuspendedTime = root.firstSuspendedTime; - - if (firstSuspendedTime !== NoWork) { - if (expirationTime >= firstSuspendedTime) { - // The entire suspended range is now unsuspended. - root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; - } else if (expirationTime >= root.lastSuspendedTime) { - root.lastSuspendedTime = expirationTime + 1; - } // This is a pending level. Check if it's higher priority than the next - // known pending level. - - if (expirationTime > root.nextKnownPendingLevel) { - root.nextKnownPendingLevel = expirationTime; - } - } -} -function markRootFinishedAtTime( - root, - finishedExpirationTime, - remainingExpirationTime +function createPortal( + children, + containerInfo, // TODO: figure out the API for cross-renderer implementation. + implementation ) { - // Update the range of pending times - root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or - // equal to this update as unsuspended. - - if (finishedExpirationTime <= root.lastSuspendedTime) { - // The entire suspended range is now unsuspended. - root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; - } else if (finishedExpirationTime <= root.firstSuspendedTime) { - // Part of the suspended range is now unsuspended. Narrow the range to - // include everything between the unsuspended time (non-inclusive) and the - // last suspended time. - root.firstSuspendedTime = finishedExpirationTime - 1; - } - - if (finishedExpirationTime <= root.lastPingedTime) { - // Clear the pinged time - root.lastPingedTime = NoWork; - } - - if (finishedExpirationTime <= root.lastExpiredTime) { - // Clear the expired time - root.lastExpiredTime = NoWork; - } -} -function markRootExpiredAtTime(root, expirationTime) { - var lastExpiredTime = root.lastExpiredTime; - - if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) { - root.lastExpiredTime = expirationTime; - } + var key = + arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + return { + // This tag allow us to uniquely identify this as a React Portal + $$typeof: REACT_PORTAL_TYPE, + key: key == null ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } var didWarnAboutNestedUpdates; @@ -19823,31 +20737,42 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; + var previousFiber = current; - if (fiber.mode & StrictMode) { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which is inside StrictMode. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node%s", - methodName, - methodName, - componentName, - getStackByFiberInDevAndProd(hostFiber) - ); - } else { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which renders StrictMode children. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node%s", - methodName, - methodName, - componentName, - getStackByFiberInDevAndProd(hostFiber) - ); + try { + setCurrentFiber(hostFiber); + + if (fiber.mode & StrictMode) { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which is inside StrictMode. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-find-node", + methodName, + methodName, + componentName + ); + } else { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which renders StrictMode children. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-find-node", + methodName, + methodName, + componentName + ); + } + } finally { + // Ideally this should reset to previous but this shouldn't be called in + // render and there's another warning for that anyway. + if (previousFiber) { + setCurrentFiber(previousFiber); + } else { + resetCurrentFiber(); + } } } } @@ -19865,7 +20790,7 @@ function updateContainer(element, container, parentComponent, callback) { } var current$1 = container.current; - var currentTime = requestCurrentTimeForUpdate(); + var eventTime = requestEventTime(); { // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests @@ -19874,12 +20799,8 @@ function updateContainer(element, container, parentComponent, callback) { } } - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - current$1, - suspenseConfig - ); + var lane = requestUpdateLane(current$1); + var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -19902,7 +20823,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property + var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property // being called "element". update.payload = { @@ -19925,8 +20846,8 @@ function updateContainer(element, container, parentComponent, callback) { } enqueueUpdate(current$1, update); - scheduleWork(current$1, expirationTime); - return expirationTime; + scheduleUpdateOnFiber(current$1, lane, eventTime); + return lane; } function getPublicRootInstance(container) { var containerFiber = container.current; @@ -19952,28 +20873,102 @@ function shouldSuspend(fiber) { return shouldSuspendImpl(fiber); } var overrideHookState = null; +var overrideHookStateDeletePath = null; +var overrideHookStateRenamePath = null; var overrideProps = null; +var overridePropsDeletePath = null; +var overridePropsRenamePath = null; var scheduleUpdate = null; var setSuspenseHandler = null; { - var copyWithSetImpl = function(obj, path, idx, value) { - if (idx >= path.length) { + var copyWithDeleteImpl = function(obj, path, index) { + var key = path[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === path.length) { + if (Array.isArray(updated)) { + updated.splice(key, 1); + } else { + delete updated[key]; + } + + return updated; + } // $FlowFixMe number or string is fine here + + updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); + return updated; + }; + + var copyWithDelete = function(obj, path) { + return copyWithDeleteImpl(obj, path, 0); + }; + + var copyWithRenameImpl = function(obj, oldPath, newPath, index) { + var oldKey = oldPath[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === oldPath.length) { + var newKey = newPath[index]; // $FlowFixMe number or string is fine here + + updated[newKey] = updated[oldKey]; + + if (Array.isArray(updated)) { + updated.splice(oldKey, 1); + } else { + delete updated[oldKey]; + } + } else { + // $FlowFixMe number or string is fine here + updated[oldKey] = copyWithRenameImpl( + // $FlowFixMe number or string is fine here + obj[oldKey], + oldPath, + newPath, + index + 1 + ); + } + + return updated; + }; + + var copyWithRename = function(obj, oldPath, newPath) { + if (oldPath.length !== newPath.length) { + warn("copyWithRename() expects paths of the same length"); + + return; + } else { + for (var i = 0; i < newPath.length - 1; i++) { + if (oldPath[i] !== newPath[i]) { + warn( + "copyWithRename() expects paths to be the same except for the deepest key" + ); + + return; + } + } + } + + return copyWithRenameImpl(obj, oldPath, newPath, 0); + }; + + var copyWithSetImpl = function(obj, path, index, value) { + if (index >= path.length) { return value; } - var key = path[idx]; + var key = path[index]; var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); // $FlowFixMe number or string is fine here - updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value); + updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); return updated; }; var copyWithSet = function(obj, path, value) { return copyWithSetImpl(obj, path, 0, value); - }; // Support DevTools editable values for useState and useReducer. + }; - overrideHookState = function(fiber, id, path, value) { + var findHook = function(fiber, id) { // For now, the "id" of stateful hooks is just the stateful hook index. // This may change in the future with e.g. nested hooks. var currentHook = fiber.memoizedState; @@ -19983,17 +20978,57 @@ var setSuspenseHandler = null; id--; } - if (currentHook !== null) { - var newState = copyWithSet(currentHook.memoizedState, path, value); - currentHook.memoizedState = newState; - currentHook.baseState = newState; // We aren't actually adding an update to the queue, + return currentHook; + }; // Support DevTools editable values for useState and useReducer. + + overrideHookState = function(fiber, id, path, value) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithSet(hook.memoizedState, path, value); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateDeletePath = function(fiber, id, path) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithDelete(hook.memoizedState, path); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithRename(hook.memoizedState, oldPath, newPath); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, // because there is no update we can add for useReducer hooks that won't trigger an error. // (There's no appropriate action type for DevTools overrides.) // As a result though, React will see the scheduled update as a noop and bailout. // Shallow cloning props works as a workaround for now to bypass the bailout check. fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); - scheduleWork(fiber, Sync); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); } }; // Support DevTools props for function components, forwardRef, memo, host components, etc. @@ -20004,11 +21039,31 @@ var setSuspenseHandler = null; fiber.alternate.pendingProps = fiber.pendingProps; } - scheduleWork(fiber, Sync); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsDeletePath = function(fiber, path) { + fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsRenamePath = function(fiber, oldPath, newPath) { + fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; scheduleUpdate = function(fiber) { - scheduleWork(fiber, Sync); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; setSuspenseHandler = function(newShouldSuspendImpl) { @@ -20016,6 +21071,24 @@ var setSuspenseHandler = null; }; } +function findHostInstanceByFiber(fiber) { + var hostFiber = findCurrentHostFiber(fiber); + + if (hostFiber === null) { + return null; + } + + return hostFiber.stateNode; +} + +function emptyFindFiberByHostInstance(instance) { + return null; +} + +function getCurrentFiberForDevTools() { + return current; +} + function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; @@ -20025,59 +21098,26 @@ function injectIntoDevTools(devToolsConfig) { rendererPackageName: devToolsConfig.rendererPackageName, rendererConfig: devToolsConfig.rendererConfig, overrideHookState: overrideHookState, + overrideHookStateDeletePath: overrideHookStateDeletePath, + overrideHookStateRenamePath: overrideHookStateRenamePath, overrideProps: overrideProps, + overridePropsDeletePath: overridePropsDeletePath, + overridePropsRenamePath: overridePropsRenamePath, setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - var hostFiber = findCurrentHostFiber(fiber); - - if (hostFiber === null) { - return null; - } - - return hostFiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - if (!findFiberByHostInstance) { - // Might not be implemented by the renderer. - return null; - } - - return findFiberByHostInstance(instance); - }, + findHostInstanceByFiber: findHostInstanceByFiber, + findFiberByHostInstance: + findFiberByHostInstance || emptyFindFiberByHostInstance, // React Refresh findHostInstancesForRefresh: findHostInstancesForRefresh, scheduleRefresh: scheduleRefresh, scheduleRoot: scheduleRoot, setRefreshHandler: setRefreshHandler, // Enables DevTools to append owner stacks to error messages in DEV mode. - getCurrentFiber: function() { - return current; - } + getCurrentFiber: getCurrentFiberForDevTools }); } -var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing; - -function createPortal( - children, - containerInfo, // TODO: figure out the API for cross-renderer implementation. - implementation -) { - var key = - arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - return { - // This tag allow us to uniquely identify this as a React Portal - $$typeof: REACT_PORTAL_TYPE, - key: key == null ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; -} - -// TODO: this is special because it gets imported during build. -var ReactVersion = "16.13.0"; var instanceCache = new Map(); @@ -20314,7 +21354,7 @@ var getInspectorDataForViewAtPoint; ); } else { error( - "getInspectorDataForViewAtPoint expects to receieve a host component" + "getInspectorDataForViewAtPoint expects to receive a host component" ); return; diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 7eb73d4fd06fcb..f6394cfd93c547 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -919,7 +919,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_225 = { +var injectedNamesToPlugins$jscomp$inline_219 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -954,34 +954,34 @@ var injectedNamesToPlugins$jscomp$inline_225 = { } } }, - isOrderingDirty$jscomp$inline_226 = !1, - pluginName$jscomp$inline_227; -for (pluginName$jscomp$inline_227 in injectedNamesToPlugins$jscomp$inline_225) + isOrderingDirty$jscomp$inline_220 = !1, + pluginName$jscomp$inline_221; +for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219) if ( - injectedNamesToPlugins$jscomp$inline_225.hasOwnProperty( - pluginName$jscomp$inline_227 + injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( + pluginName$jscomp$inline_221 ) ) { - var pluginModule$jscomp$inline_228 = - injectedNamesToPlugins$jscomp$inline_225[pluginName$jscomp$inline_227]; + var pluginModule$jscomp$inline_222 = + injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_227) || - namesToPlugins[pluginName$jscomp$inline_227] !== - pluginModule$jscomp$inline_228 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || + namesToPlugins[pluginName$jscomp$inline_221] !== + pluginModule$jscomp$inline_222 ) { - if (namesToPlugins[pluginName$jscomp$inline_227]) + if (namesToPlugins[pluginName$jscomp$inline_221]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_227 + + pluginName$jscomp$inline_221 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_227 - ] = pluginModule$jscomp$inline_228; - isOrderingDirty$jscomp$inline_226 = !0; + pluginName$jscomp$inline_221 + ] = pluginModule$jscomp$inline_222; + isOrderingDirty$jscomp$inline_220 = !0; } } -isOrderingDirty$jscomp$inline_226 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1102,7 +1102,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1712,7 +1712,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1747,28 +1747,24 @@ var rendererID = null, injectedHook = null, Scheduler_now = Scheduler.unstable_now; Scheduler_now(); -var return_highestLanePriority = 10; +var return_highestLanePriority = 8; function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 6), inputDiscreteLanes; inputDiscreteLanes = 62914560 & lanes; @@ -1782,18 +1778,18 @@ function getHighestPriorityLanes(lanes) { return (return_highestLanePriority = 2), inputDiscreteLanes; if (0 !== (1073741824 & lanes)) return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; + return_highestLanePriority = 8; return lanes; } function schedulerPriorityToLanePriority(schedulerPriorityLevel) { switch (schedulerPriorityLevel) { case 99: - return 17; + return 15; case 98: - return 12; + return 10; case 97: case 96: - return 10; + return 8; case 95: return 2; default: @@ -1802,16 +1798,14 @@ function schedulerPriorityToLanePriority(schedulerPriorityLevel) { } function lanePriorityToSchedulerPriority(lanePriority) { switch (lanePriority) { - case 17: - case 16: - return 99; case 15: case 14: + return 99; case 13: case 12: - return 98; case 11: case 10: + return 98; case 9: case 8: case 7: @@ -1841,7 +1835,7 @@ function getNextLanes(root, wipLanes) { pingedLanes = root.pingedLanes; if (0 !== expiredLanes) (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); + (nextLanePriority = return_highestLanePriority = 15); else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; 0 !== nonIdleUnblockedLanes @@ -1880,42 +1874,31 @@ function getNextLanes(root, wipLanes) { (wipLanes &= ~nextLanePriority); return nextLanes; } -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$4 = 31 - clz32(lanes), - lane = 1 << index$4; - index$4 = root[index$4]; - index$4 > mostRecentEventTime && (mostRecentEventTime = index$4); - lanes &= ~lane; - } - return mostRecentEventTime; -} function getLanesToRetrySynchronouslyOnError(root) { root = root.pendingLanes & -1073741825; return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; } function findUpdateLane(lanePriority, wipLanes) { switch (lanePriority) { - case 17: + case 15: return 1; - case 16: - return 2; case 14: + return 2; + case 12: return ( (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority ); - case 12: + case 10: return ( (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority ); - case 10: + case 8: return ( (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), 0 === lanePriority && (lanePriority = 512)), lanePriority ); @@ -1933,8 +1916,9 @@ function findUpdateLane(lanePriority, wipLanes) { function getHighestPriorityLane(lanes) { return lanes & -lanes; } -function pickArbitraryLane(lanes) { - return lanes & -lanes; +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; } function markRootUpdated(root, updateLane, eventTime) { root.pendingLanes |= updateLane; @@ -2051,30 +2035,7 @@ function flushSyncCallbackQueueImpl() { } } } -function describeFiber(fiber) { - switch (fiber.tag) { - case 5: - return describeComponentFrame(fiber.type, null, null); - case 16: - return describeComponentFrame("Lazy", null, null); - case 13: - return describeComponentFrame("Suspense", null, null); - case 19: - return describeComponentFrame("SuspenseList", null, null); - case 0: - case 2: - case 15: - return describeFunctionComponentFrame(fiber.type, null); - case 11: - return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); - case 1: - return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; - default: - return ""; - } -} +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -2100,6 +2061,30 @@ function shallowEqual(objA, objB) { return !1; return !0; } +function describeFiber(fiber) { + switch (fiber.tag) { + case 5: + return describeComponentFrame(fiber.type, null, null); + case 16: + return describeComponentFrame("Lazy", null, null); + case 13: + return describeComponentFrame("Suspense", null, null); + case 19: + return describeComponentFrame("SuspenseList", null, null); + case 0: + case 2: + case 15: + return describeFunctionComponentFrame(fiber.type, null); + case 11: + return describeFunctionComponentFrame(fiber.type.render, null); + case 22: + return describeFunctionComponentFrame(fiber.type._render, null); + case 1: + return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; + default: + return ""; + } +} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2193,11 +2178,10 @@ function cloneUpdateQueue(current, workInProgress) { effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(eventTime, lane) { return { eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, @@ -2230,7 +2214,6 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { var clone = { eventTime: queue.eventTime, lane: queue.lane, - suspenseConfig: queue.suspenseConfig, tag: queue.tag, payload: queue.payload, callback: queue.callback, @@ -2304,16 +2287,11 @@ function processUpdateQueue( (current = current.next = { eventTime: updateEventTime, lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, next: null }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); a: { var workInProgress = workInProgress$jscomp$0, update = firstBaseUpdate; @@ -2333,8 +2311,7 @@ function processUpdateQueue( currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; pendingQueue = @@ -2357,7 +2334,7 @@ function processUpdateQueue( } } null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), + ((workInProgress$jscomp$0.flags |= 32), (pendingQueue = queue.effects), null === pendingQueue ? (queue.effects = [firstBaseUpdate]) @@ -2366,7 +2343,6 @@ function processUpdateQueue( (updateEventTime = { eventTime: updateEventTime, lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, @@ -2418,8 +2394,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2445,41 +2420,32 @@ var classComponentUpdater = { enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); } }; @@ -2572,7 +2538,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2587,7 +2553,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2621,7 +2587,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2645,7 +2611,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2677,16 +2643,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -3220,12 +3186,14 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3285,7 +3253,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim$1() || shim$1())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3317,7 +3285,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3442,40 +3410,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3560,10 +3522,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), + (maybeNewVersion = requestUpdateLane(fiber)), (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); maybeNewVersion = root.mutableReadLanes; root.entangledLanes |= maybeNewVersion; @@ -3572,9 +3531,9 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { 0 < lanes; ) { - var index$12 = 31 - clz32(lanes), - lane = 1 << index$12; - entanglements[index$12] |= maybeNewVersion; + var index$11 = 31 - clz32(lanes), + lane = 1 << index$11; + entanglements[index$11] |= maybeNewVersion; lanes &= ~lane; } } @@ -3588,7 +3547,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { latestSetSnapshot = refs.setSnapshot; try { latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); + var lane = requestUpdateLane(fiber); root.mutableReadLanes |= lane & root.pendingLanes; } catch (error) { latestSetSnapshot(function() { @@ -3659,17 +3618,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3677,12 +3636,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3721,13 +3680,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3755,39 +3707,36 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); - suspenseConfig = { - eventTime: eventTime, - lane: lane, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3803,8 +3752,8 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { @@ -3832,7 +3781,13 @@ var ContextOnlyDispatcher = { }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3878,36 +3833,30 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; }, useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); @@ -3937,36 +3886,27 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -3988,36 +3928,27 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -4059,11 +3990,11 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } @@ -4100,7 +4031,7 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, renderLanes ); @@ -4117,7 +4048,7 @@ function updateMemoComponent( Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4137,7 +4068,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -4192,7 +4123,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4217,11 +4148,11 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } @@ -4241,7 +4172,7 @@ function updateClassComponent( null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); @@ -4307,9 +4238,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -4317,7 +4248,7 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); } else { instance = workInProgress.stateNode; @@ -4390,17 +4321,17 @@ function updateClassComponent( oldContext )), "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4410,11 +4341,11 @@ function updateClassComponent( : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4435,7 +4366,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4447,7 +4378,7 @@ function finishClassComponent( didCaptureError && "function" !== typeof Component.getDerivedStateFromError ? null : shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((workInProgress.child = reconcileChildFibers( workInProgress, @@ -4484,50 +4415,48 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { + current = nextProps.children; + suspenseContext = nextProps.fallback; if (showFallback) return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps)) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( + (current = mountSuspenseFallbackChildren( + workInProgress, current, suspenseContext, - renderLanes, - null + renderLanes )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), current ); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), + current + ); renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, + { mode: "visible", children: current }, workInProgress.mode, renderLanes, null @@ -4545,13 +4474,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4573,13 +4502,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4592,6 +4521,36 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { workInProgress.memoizedState = null; return renderLanes; } +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren)) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; +} function updateSuspensePrimaryChildren( current, workInProgress, @@ -4609,7 +4568,7 @@ function updateSuspensePrimaryChildren( primaryChildren.sibling = null; null !== current && ((current.nextEffect = null), - (current.effectTag = 8), + (current.flags = 8), (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } @@ -4646,7 +4605,7 @@ function updateSuspenseFallbackChildren( renderLanes, null )), - (fallbackChildren.effectTag |= 2)); + (fallbackChildren.flags |= 2)); fallbackChildren.return = workInProgress; primaryChildren.return = workInProgress; primaryChildren.sibling = fallbackChildren; @@ -4675,7 +4634,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4684,7 +4642,6 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } @@ -4695,9 +4652,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4831,7 +4788,7 @@ appendAllChildren = function( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4884,7 +4841,7 @@ function appendAllChildrenToContainer( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4928,7 +4885,7 @@ updateHostContainer = function(workInProgress) { newChildSet = createChildNodeSet(container); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; - workInProgress.effectTag |= 4; + workInProgress.flags |= 4; completeRoot(container, newChildSet); } }; @@ -4966,7 +4923,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { }), (workInProgress.stateNode = type), current - ? (workInProgress.effectTag |= 4) + ? (workInProgress.flags |= 4) : appendAllChildren(type, workInProgress, !1, !1)); } }; @@ -4980,7 +4937,7 @@ updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText, workInProgress )), - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { @@ -5035,7 +4992,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -5053,8 +5010,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -5089,7 +5045,7 @@ function completeWork(current, workInProgress, renderLanes) { current = { node: rootContainerInstance, canonical: current }; appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -5118,7 +5074,7 @@ function completeWork(current, workInProgress, renderLanes) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) + if (0 !== (workInProgress.flags & 64)) return (workInProgress.lanes = renderLanes), workInProgress; newProps = null !== newProps; rootContainerInstance = !1; @@ -5146,7 +5102,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - newProps && (workInProgress.effectTag |= 4); + newProps && (workInProgress.flags |= 4); return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -5158,24 +5114,24 @@ function completeWork(current, workInProgress, renderLanes) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.effectTag & 64)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; @@ -5183,7 +5139,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (renderLanes = current), - (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), @@ -5225,6 +5181,12 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); } else { if (!rootContainerInstance) @@ -5232,12 +5194,12 @@ function completeWork(current, workInProgress, renderLanes) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -5250,12 +5212,13 @@ function completeWork(current, workInProgress, renderLanes) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes)); + (workInProgress.lanes = 33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5266,9 +5229,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -5291,7 +5252,7 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), null ); } @@ -5305,32 +5266,30 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); resetWorkInProgressVersions(); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null ); case 19: @@ -5383,7 +5342,7 @@ function logCapturedError(boundary, errorInfo) { } var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; lane.payload = { element: null }; var error = errorInfo.value; @@ -5394,7 +5353,7 @@ function createRootErrorUpdate(fiber, errorInfo, lane) { return lane; } function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { @@ -5440,7 +5399,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -5501,7 +5460,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && + finishedWork.flags & 4 && (null === current ? finishedRoot.componentDidMount() : ((create$81 = @@ -5536,7 +5495,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { } return; case 5: - null === current && finishedWork.effectTag & 4 && shim(); + null === current && finishedWork.flags & 4 && shim(); return; case 6: return; @@ -5654,14 +5613,13 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, - workInProgressRootCanSuspendUsingConfig = null, workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5686,46 +5644,33 @@ function requestEventTime() { ? currentEventTime : (currentEventTime = now()); } -function requestUpdateLane(fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; if (0 === (fiber & 2)) return 1; if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; 0 === currentEventWipLanes && (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; + if (0 !== ReactCurrentBatchConfig.transition) { 0 !== currentEventPendingLanes && (currentEventPendingLanes = null !== mostRecentlyUpdatedRoot ? mostRecentlyUpdatedRoot.pendingLanes : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (50 < nestedUpdateCount) @@ -5746,7 +5691,9 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) ? performSyncWorkOnRoot(fiber) : (ensureRootIsScheduled(fiber, eventTime), - 0 === executionContext && flushSyncCallbackQueue()) + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) : (0 === (executionContext & 4) || (98 !== priorityLevel && 99 !== priorityLevel) || (null === rootsWithPendingDiscreteUpdates @@ -5787,8 +5734,8 @@ function ensureRootIsScheduled(root, currentTime) { getHighestPriorityLanes(lane); var priority = return_highestLanePriority; expirationTimes[index$5] = - 12 <= priority - ? expirationTime + 1e3 + 10 <= priority + ? expirationTime + 250 : 6 <= priority ? expirationTime + 5e3 : -1; @@ -5813,7 +5760,7 @@ function ensureRootIsScheduled(root, currentTime) { existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode); } - 17 === currentTime + 15 === currentTime ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), null === syncQueue ? ((syncQueue = [existingCallbackNode]), @@ -5823,7 +5770,7 @@ function ensureRootIsScheduled(root, currentTime) { ))) : syncQueue.push(existingCallbackNode), (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime + : 14 === currentTime ? (existingCallbackNode = scheduleCallback( 99, performSyncWorkOnRoot.bind(null, root) @@ -5837,7 +5784,7 @@ function ensureRootIsScheduled(root, currentTime) { root.callbackNode = existingCallbackNode; } } -function performConcurrentWorkOnRoot(root, didTimeout) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) @@ -5850,19 +5797,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); - didTimeout = lanes; + var exitStatus = lanes; var prevExecutionContext = executionContext; executionContext |= 16; var prevDispatcher = pushDispatcher(); - (workInProgressRoot === root && - workInProgressRootRenderLanes === didTimeout) || - prepareFreshStack(root, didTimeout); + if ( + workInProgressRoot !== root || + workInProgressRootRenderLanes !== exitStatus + ) + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, exitStatus); do try { workLoopConcurrent(); @@ -5875,19 +5819,19 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ReactCurrentDispatcher$2.current = prevDispatcher; executionContext = prevExecutionContext; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = 0) : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); + (exitStatus = workInProgressRootExitStatus)); if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && + else if (0 !== exitStatus) { + 2 === exitStatus && ((executionContext |= 64), root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended$1(root, lanes), @@ -5895,7 +5839,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { originalCallbackNode); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; - switch (didTimeout) { + switch (exitStatus) { case 0: case 1: throw Error("Root did not complete. This is a bug in React."); @@ -5906,8 +5850,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes); if ( (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevExecutionContext = root.suspendedLanes; @@ -5918,7 +5862,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -5926,33 +5870,31 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) { + var index$4 = 31 - clz32(lanes); + prevDispatcher = 1 << index$4; + index$4 = exitStatus[index$4]; + index$4 > prevExecutionContext && (prevExecutionContext = index$4); + lanes &= ~prevDispatcher; } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), @@ -5963,30 +5905,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { commitRoot(root); break; case 5: - prevDispatcher = getMostRecentEventTime(root, lanes); - if ( - -1 !== prevDispatcher && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevExecutionContext = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (prevDispatcher = now() - prevDispatcher), - (didTimeout = - prevDispatcher <= prevExecutionContext - ? 0 - : prevExecutionContext + didTimeout - prevDispatcher)), - 10 < didTimeout) - ) { - markRootSuspended$1(root, lanes); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - didTimeout - ); - break; - } commitRoot(root); break; default: @@ -6004,9 +5922,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$10 = 31 - clz32(suspendedLanes), - lane = 1 << index$10; - root[index$10] = -1; + var index$9 = 31 - clz32(suspendedLanes), + lane = 1 << index$9; + root[index$9] = -1; suspendedLanes &= ~lane; } } @@ -6100,8 +6018,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; - workInProgressRootCanSuspendUsingConfig = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; } function handleError(root$jscomp$0, thrownValue) { @@ -6138,7 +6054,7 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.effectTag |= 2048; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -6184,13 +6100,13 @@ function handleError(root$jscomp$0, thrownValue) { workInProgress$76.updateQueue = updateQueue; } else wakeables.add(wakeable); if (0 === (workInProgress$76.mode & 2)) { - workInProgress$76.effectTag |= 64; - sourceFiber.effectTag |= 16384; - sourceFiber.effectTag &= -2981; + workInProgress$76.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } @@ -6217,7 +6133,7 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$76.effectTag |= 4096; + workInProgress$76.flags |= 8192; workInProgress$76.lanes = thrownValue; break a; } @@ -6236,7 +6152,7 @@ function handleError(root$jscomp$0, thrownValue) { switch (workInProgress$76.tag) { case 3: root = value; - workInProgress$76.effectTag |= 4096; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; workInProgress$76.lanes |= thrownValue; var update$77 = createRootErrorUpdate( @@ -6251,14 +6167,14 @@ function handleError(root$jscomp$0, thrownValue) { var ctor = workInProgress$76.type, instance = workInProgress$76.stateNode; if ( - 0 === (workInProgress$76.effectTag & 64) && + 0 === (workInProgress$76.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$76.effectTag |= 4096; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; workInProgress$76.lanes |= thrownValue; var update$80 = createClassErrorUpdate( @@ -6289,13 +6205,6 @@ function pushDispatcher() { ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); -} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 16; @@ -6339,7 +6248,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { + if (0 === (completedWork.flags & 4096)) { current = completeWork(current, completedWork, subtreeRenderLanes); if (null !== current) { workInProgress = current; @@ -6358,14 +6267,14 @@ function completeUnitOfWork(unitOfWork) { current.childLanes = newChildLanes; } null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && (unitOfWork.firstEffect = completedWork.firstEffect), null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + 1 < completedWork.flags && (null !== unitOfWork.lastEffect ? (unitOfWork.lastEffect.nextEffect = completedWork) : (unitOfWork.firstEffect = completedWork), @@ -6373,13 +6282,13 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.effectTag &= 2047; + current.flags &= 4095; workInProgress = current; return; } null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -6424,11 +6333,11 @@ function commitRootImpl(root, renderPriorityLevel) { 0 < noLongerPendingLanes; ) { - var index$11 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$11; - remainingLanes$jscomp$0[index$11] = 0; - eventTimes[index$11] = -1; - expirationTimes[index$11] = -1; + var index$10 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$10; + remainingLanes$jscomp$0[index$10] = 0; + eventTimes[index$10] = -1; + expirationTimes[index$10] = -1; noLongerPendingLanes &= ~lane; } null !== rootsWithPendingDiscreteUpdates && @@ -6438,7 +6347,7 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - 1 < finishedWork.effectTag + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), (remainingLanes = finishedWork.firstEffect)) @@ -6464,8 +6373,8 @@ function commitRootImpl(root, renderPriorityLevel) { do try { for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6475,19 +6384,19 @@ function commitRootImpl(root, renderPriorityLevel) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: @@ -6496,21 +6405,21 @@ function commitRootImpl(root, renderPriorityLevel) { case 8: eventTimes = nextEffect; a: for (noLongerPendingLanes = expirationTimes = eventTimes; ; ) { - index$11 = noLongerPendingLanes; + index$10 = noLongerPendingLanes; if ( injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount ) try { - injectedHook.onCommitFiberUnmount(rendererID, index$11); + injectedHook.onCommitFiberUnmount(rendererID, index$10); } catch (err) {} - switch (index$11.tag) { + switch (index$10.tag) { case 0: case 11: case 14: case 15: case 22: - var updateQueue = index$11.updateQueue; + var updateQueue = index$10.updateQueue; if (null !== updateQueue) { var lastEffect = updateQueue.lastEffect; if (null !== lastEffect) { @@ -6523,11 +6432,11 @@ function commitRootImpl(root, renderPriorityLevel) { if (void 0 !== destroy) if (0 !== (tag & 4)) enqueuePendingPassiveHookEffectUnmount( - index$11, + index$10, lane ); else { - _effect2 = index$11; + _effect2 = index$10; try { destroy(); } catch (error) { @@ -6540,24 +6449,24 @@ function commitRootImpl(root, renderPriorityLevel) { } break; case 1: - safelyDetachRef(index$11); - var instance = index$11.stateNode; + safelyDetachRef(index$10); + var instance = index$10.stateNode; if ("function" === typeof instance.componentWillUnmount) try { - (lane = index$11), + (lane = index$10), (_effect2 = instance), (_effect2.props = lane.memoizedProps), (_effect2.state = lane.memoizedState), _effect2.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(index$11, unmountError); + captureCommitPhaseError(index$10, unmountError); } break; case 5: - safelyDetachRef(index$11); + safelyDetachRef(index$10); break; case 4: - createChildNodeSet(index$11.stateNode.containerInfo); + createChildNodeSet(index$10.stateNode.containerInfo); } if (null !== noLongerPendingLanes.child) (noLongerPendingLanes.child.return = noLongerPendingLanes), @@ -6583,9 +6492,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$92) { + } catch (error$87) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$92); + captureCommitPhaseError(nextEffect, error$87); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6593,11 +6502,11 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = remainingLanes; do try { - for (effectTag = root; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { @@ -6616,9 +6525,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$93) { + } catch (error$88) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$93); + captureCommitPhaseError(nextEffect, error$88); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6634,10 +6543,10 @@ function commitRootImpl(root, renderPriorityLevel) { for (nextEffect = remainingLanes; null !== nextEffect; ) (renderPriorityLevel = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && - ((effectTag$jscomp$0 = nextEffect), - (effectTag$jscomp$0.sibling = null), - (effectTag$jscomp$0.stateNode = null)), + nextEffect.flags & 8 && + ((flags$jscomp$0 = nextEffect), + (flags$jscomp$0.sibling = null), + (flags$jscomp$0.stateNode = null)), (nextEffect = renderPriorityLevel); remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); @@ -6653,7 +6562,7 @@ function commitRootImpl(root, renderPriorityLevel) { rendererID, finishedWork, void 0, - 64 === (finishedWork.current.effectTag & 64) + 64 === (finishedWork.current.flags & 64) ); } catch (err) {} ensureRootIsScheduled(root, now()); @@ -6671,17 +6580,16 @@ function commitBeforeMutationEffects() { var current = nextEffect.alternate; shouldFireAfterActiveInstanceBlur || null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) + (0 !== (nextEffect.flags & 8) ? doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0) : 13 === nextEffect.tag && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0)); - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); - 0 === (effectTag & 512) || + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -6698,7 +6606,6 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } return !1; @@ -6732,10 +6639,10 @@ function flushPassiveEffectsImpl() { var unmountEffects = pendingPassiveHookEffectsUnmount; pendingPassiveHookEffectsUnmount = []; for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$98 = unmountEffects[i], + var effect$93 = unmountEffects[i], fiber = unmountEffects[i + 1], - destroy = effect$98.destroy; - effect$98.destroy = void 0; + destroy = effect$93.destroy; + effect$93.destroy = void 0; if ("function" === typeof destroy) try { destroy(); @@ -6747,22 +6654,22 @@ function flushPassiveEffectsImpl() { unmountEffects = pendingPassiveHookEffectsMount; pendingPassiveHookEffectsMount = []; for (i = 0; i < unmountEffects.length; i += 2) { - effect$98 = unmountEffects[i]; + effect$93 = unmountEffects[i]; fiber = unmountEffects[i + 1]; try { - var create$102 = effect$98.create; - effect$98.destroy = create$102(); - } catch (error$103) { + var create$97 = effect$93.create; + effect$93.destroy = create$97(); + } catch (error$98) { if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$103); + captureCommitPhaseError(fiber, error$98); } } - for (create$102 = root.current.firstEffect; null !== create$102; ) - (root = create$102.nextEffect), - (create$102.nextEffect = null), - create$102.effectTag & 8 && - ((create$102.sibling = null), (create$102.stateNode = null)), - (create$102 = root); + for (create$97 = root.current.firstEffect; null !== create$97; ) + (root = create$97.nextEffect), + (create$97.nextEffect = null), + create$97.flags & 8 && + ((create$97.sibling = null), (create$97.stateNode = null)), + (create$97 = root); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; @@ -6794,13 +6701,21 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); - enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); fiber = markUpdateLaneFromFiberToRoot(fiber, 1); - null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber)); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } @@ -6853,7 +6768,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) didReceiveUpdate = !0; else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { didReceiveUpdate = !1; switch (workInProgress.tag) { @@ -6899,14 +6814,14 @@ beginWork$1 = function(current, workInProgress, renderLanes) { break; case 19: updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { + if (0 !== (current.flags & 64)) { if (updateLanes) return updateSuspenseListComponent( current, workInProgress, renderLanes ); - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; } context = workInProgress.memoizedState; null !== context && @@ -6933,7 +6848,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); @@ -6945,7 +6860,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { context, renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -6995,7 +6910,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; hasContext = context._init; context = hasContext(context._payload); @@ -7238,8 +7153,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 1 === context$jscomp$0.tag && ((dependency = createUpdate( -1, - renderLanes & -renderLanes, - null + renderLanes & -renderLanes )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); @@ -7301,7 +7215,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), (updateLanes = updateLanes(context)), - (workInProgress.effectTag |= 1), + (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); @@ -7342,7 +7256,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) @@ -7381,7 +7295,7 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; @@ -7419,7 +7333,7 @@ function createWorkInProgress(current, pendingProps) { (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), - (workInProgress.effectTag = 0), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); @@ -7570,10 +7484,10 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.hydrate = hydrate; this.callbackNode = null; this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.entanglements = createLaneMap(0); } function createPortal(children, containerInfo, implementation) { var key = @@ -7602,8 +7516,7 @@ function findHostInstance(component) { function updateContainer(element, container, parentComponent, callback) { var current = container.current, eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + lane = requestUpdateLane(current); a: if (parentComponent) { parentComponent = parentComponent._reactInternals; b: { @@ -7651,7 +7564,7 @@ function updateContainer(element, container, parentComponent, callback) { null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); @@ -7682,14 +7595,16 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_891 = { + devToolsConfig$jscomp$inline_865 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.0-alpha.0", + version: "17.0.1-4e5d7faf5", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7704,13 +7619,17 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1074 = { - bundleType: devToolsConfig$jscomp$inline_891.bundleType, - version: devToolsConfig$jscomp$inline_891.version, - rendererPackageName: devToolsConfig$jscomp$inline_891.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_891.rendererConfig, +var internals$jscomp$inline_1054 = { + bundleType: devToolsConfig$jscomp$inline_865.bundleType, + version: devToolsConfig$jscomp$inline_865.version, + rendererPackageName: devToolsConfig$jscomp$inline_865.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_865.rendererConfig, overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, setSuspenseHandler: null, scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, @@ -7719,7 +7638,7 @@ var internals$jscomp$inline_1074 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_891.findFiberByHostInstance || + devToolsConfig$jscomp$inline_865.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -7728,16 +7647,16 @@ var internals$jscomp$inline_1074 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1075 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1055 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1075.isDisabled && - hook$jscomp$inline_1075.supportsFiber + !hook$jscomp$inline_1055.isDisabled && + hook$jscomp$inline_1055.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1075.inject( - internals$jscomp$inline_1074 + (rendererID = hook$jscomp$inline_1055.inject( + internals$jscomp$inline_1054 )), - (injectedHook = hook$jscomp$inline_1075); + (injectedHook = hook$jscomp$inline_1055); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.js b/Libraries/Renderer/implementations/ReactFabric-prod.js index 7df0e13f1f7fe1..a5f870980f11a8 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.js @@ -16,16 +16,6 @@ require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), React = require("react"), Scheduler = require("scheduler"); -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -96,109 +86,6 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } -function getListener(inst, registrationName) { - var listener = inst.stateNode; - if (!listener) return null; - var props = getFiberCurrentPropsFromNode(listener); - if (!props) return null; - listener = props[registrationName]; - a: switch (registrationName) { - case "onClick": - case "onClickCapture": - case "onDoubleClick": - case "onDoubleClickCapture": - case "onMouseDown": - case "onMouseDownCapture": - case "onMouseMove": - case "onMouseMoveCapture": - case "onMouseUp": - case "onMouseUpCapture": - case "onMouseEnter": - (props = !props.disabled) || - ((inst = inst.type), - (props = !( - "button" === inst || - "input" === inst || - "select" === inst || - "textarea" === inst - ))); - inst = !props; - break a; - default: - inst = !1; - } - if (inst) return null; - if (listener && "function" !== typeof listener) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - return listener; -} -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} function functionThatReturnsTrue() { return !0; } @@ -214,6 +101,7 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; + this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -293,7 +181,12 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { +function createOrGetPooledEvent( + dispatchConfig, + targetInst, + nativeEvent, + nativeInst +) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -310,8 +203,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { + EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; - EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -439,6 +332,22 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -452,65 +361,132 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" - }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" - }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" - }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" - }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies - }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies + dependencies: startDependencies + }, + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] + dependencies: ["topScroll"] + }, + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { - registrationName: "onResponderReject", - dependencies: [] + dependencies: ["topSelectionChange"] + }, + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } + dependencies: moveDependencies + }, + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies }, - ResponderEventPlugin = { + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { registrationName: "onResponderReject", dependencies: [] }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } +}; +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} +function getListener(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +var ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -571,68 +547,70 @@ var eventTypes = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp === responderInst; - JSCompiler_temp = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp; + JSCompiler_temp = targetInst === responderInst; + shouldSetEventType = ResponderSyntheticEvent.getPooled( shouldSetEventType, - JSCompiler_temp, + targetInst, nativeEvent, nativeEventTarget ); - JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; - targetInst + shouldSetEventType.touchHistory = + ResponderTouchHistoryStore.touchHistory; + JSCompiler_temp ? forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingle ); b: { - shouldSetEventType = JSCompiler_temp._dispatchListeners; - targetInst = JSCompiler_temp._dispatchInstances; - if (Array.isArray(shouldSetEventType)) + JSCompiler_temp = shouldSetEventType._dispatchListeners; + targetInst = shouldSetEventType._dispatchInstances; + if (Array.isArray(JSCompiler_temp)) for ( depthA = 0; - depthA < shouldSetEventType.length && - !JSCompiler_temp.isPropagationStopped(); + depthA < JSCompiler_temp.length && + !shouldSetEventType.isPropagationStopped(); depthA++ ) { if ( - shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) + JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) ) { - shouldSetEventType = targetInst[depthA]; + JSCompiler_temp = targetInst[depthA]; break b; } } else if ( - shouldSetEventType && - shouldSetEventType(JSCompiler_temp, targetInst) + JSCompiler_temp && + JSCompiler_temp(shouldSetEventType, targetInst) ) { - shouldSetEventType = targetInst; + JSCompiler_temp = targetInst; break b; } - shouldSetEventType = null; + JSCompiler_temp = null; } - JSCompiler_temp._dispatchInstances = null; - JSCompiler_temp._dispatchListeners = null; - JSCompiler_temp.isPersistent() || - JSCompiler_temp.constructor.release(JSCompiler_temp); - if (shouldSetEventType && shouldSetEventType !== responderInst) + shouldSetEventType._dispatchInstances = null; + shouldSetEventType._dispatchListeners = null; + shouldSetEventType.isPersistent() || + shouldSetEventType.constructor.release(shouldSetEventType); + if (JSCompiler_temp && JSCompiler_temp !== responderInst) if ( - ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( + ((shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), - (JSCompiler_temp.touchHistory = + (shouldSetEventType.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), + (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), responderInst) ) if ( @@ -659,13 +637,13 @@ var eventTypes = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [JSCompiler_temp, depthA] + [shouldSetEventType, depthA] ); - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), @@ -682,9 +660,9 @@ var eventTypes = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - JSCompiler_temp + shouldSetEventType )), - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -812,7 +790,6 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -829,7 +806,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -837,7 +814,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -865,13 +842,75 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - customBubblingEventTypes = + registrationNameModules = {}; +function getListener$1(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; +function accumulateDirectionalDispatches$1(inst, phase, event) { + if ( + (phase = getListener$1( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle$1(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + for (var inst = event._targetInst, path = []; inst; ) { + path.push(inst); + do inst = inst.return; + while (inst && 5 !== inst.tag); + inst = inst ? inst : null; + } + for (inst = path.length; 0 < inst--; ) + accumulateDirectionalDispatches$1(path[inst], "captured", event); + for (inst = 0; inst < path.length; inst++) + accumulateDirectionalDispatches$1(path[inst], "bubbled", event); + } +} +function accumulateDirectDispatchesSingle$1(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener$1(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -881,7 +920,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_92 = { +var injectedNamesToPlugins$jscomp$inline_219 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -905,42 +944,45 @@ var injectedNamesToPlugins$jscomp$inline_92 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); + forEachAccumulated( + topLevelType, + accumulateTwoPhaseDispatchesSingle$1 + ); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_93 = !1, - pluginName$jscomp$inline_94; -for (pluginName$jscomp$inline_94 in injectedNamesToPlugins$jscomp$inline_92) + isOrderingDirty$jscomp$inline_220 = !1, + pluginName$jscomp$inline_221; +for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219) if ( - injectedNamesToPlugins$jscomp$inline_92.hasOwnProperty( - pluginName$jscomp$inline_94 + injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( + pluginName$jscomp$inline_221 ) ) { - var pluginModule$jscomp$inline_95 = - injectedNamesToPlugins$jscomp$inline_92[pluginName$jscomp$inline_94]; + var pluginModule$jscomp$inline_222 = + injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_94) || - namesToPlugins[pluginName$jscomp$inline_94] !== - pluginModule$jscomp$inline_95 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || + namesToPlugins[pluginName$jscomp$inline_221] !== + pluginModule$jscomp$inline_222 ) { - if (namesToPlugins[pluginName$jscomp$inline_94]) + if (namesToPlugins[pluginName$jscomp$inline_221]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_94 + + pluginName$jscomp$inline_221 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_94 - ] = pluginModule$jscomp$inline_95; - isOrderingDirty$jscomp$inline_93 = !0; + pluginName$jscomp$inline_221 + ] = pluginModule$jscomp$inline_222; + isOrderingDirty$jscomp$inline_220 = !0; } } -isOrderingDirty$jscomp$inline_93 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -964,31 +1006,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; -ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || - (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); -ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || - (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); -var hasSymbol = "function" === typeof Symbol && Symbol.for, - REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, - REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, - REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, - REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, - REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, - REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, - REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_CONCURRENT_MODE_TYPE = hasSymbol - ? Symbol.for("react.concurrent_mode") - : 60111, - REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, - REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_SUSPENSE_LIST_TYPE = hasSymbol - ? Symbol.for("react.suspense_list") - : 60120, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, + REACT_ELEMENT_TYPE = 60103, + REACT_PORTAL_TYPE = 60106, + REACT_FRAGMENT_TYPE = 60107, + REACT_STRICT_MODE_TYPE = 60108, + REACT_PROFILER_TYPE = 60114, + REACT_PROVIDER_TYPE = 60109, + REACT_CONTEXT_TYPE = 60110, + REACT_FORWARD_REF_TYPE = 60112, + REACT_SUSPENSE_TYPE = 60113, + REACT_SUSPENSE_LIST_TYPE = 60120, + REACT_MEMO_TYPE = 60115, + REACT_LAZY_TYPE = 60116, + REACT_BLOCK_TYPE = 60121, + REACT_DEBUG_TRACING_MODE_TYPE = 60129, + REACT_OFFSCREEN_TYPE = 60130, + REACT_LEGACY_HIDDEN_TYPE = 60131; +if ("function" === typeof Symbol && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor("react.element"); + REACT_PORTAL_TYPE = symbolFor("react.portal"); + REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); + REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); + REACT_PROFILER_TYPE = symbolFor("react.profiler"); + REACT_PROVIDER_TYPE = symbolFor("react.provider"); + REACT_CONTEXT_TYPE = symbolFor("react.context"); + REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); + REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); + REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); + REACT_MEMO_TYPE = symbolFor("react.memo"); + REACT_LAZY_TYPE = symbolFor("react.lazy"); + REACT_BLOCK_TYPE = symbolFor("react.block"); + symbolFor("react.scope"); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); + REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); + REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); +} +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -996,27 +1051,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function initializeLazyComponentType(lazyComponent) { - if (-1 === lazyComponent._status) { - var ctor = lazyComponent._result; - ctor || (ctor = lazyComponent._ctor); - ctor = ctor(); - lazyComponent._status = 0; - lazyComponent._result = ctor; - ctor.then( - function(moduleObject) { - 0 === lazyComponent._status && - ((moduleObject = moduleObject.default), - (lazyComponent._status = 1), - (lazyComponent._result = moduleObject)); - }, - function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); - } - ); - } -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1051,10 +1085,13 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type.render); + return getComponentName(type._render); case REACT_LAZY_TYPE: - if ((type = 1 === type._status ? type._result : null)) - return getComponentName(type); + innerType = type._payload; + type = type._init; + try { + return getComponentName(type(innerType)); + } catch (x) {} } return null; } @@ -1066,7 +1103,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1106,36 +1143,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, _child = parentA.child; _child; ) { - if (_child === a) { + for (var didFindChild = !1, child$0 = parentA.child; child$0; ) { + if (child$0 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (_child === b) { + if (child$0 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - _child = _child.sibling; + child$0 = child$0.sibling; } if (!didFindChild) { - for (_child = parentB.child; _child; ) { - if (_child === a) { + for (child$0 = parentB.child; child$0; ) { + if (child$0 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (_child === b) { + if (child$0 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - _child = _child.sibling; + child$0 = child$0.sibling; } if (!didFindChild) throw Error( @@ -1170,6 +1207,18 @@ function findCurrentHostFiber(parent) { } return null; } +function doesFiberContain(parentFiber, childFiber) { + for ( + var parentFiberAlternate = parentFiber.alternate; + null !== childFiber; + + ) { + if (childFiber === parentFiber || childFiber === parentFiberAlternate) + return !0; + childFiber = childFiber.return; + } + return !1; +} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -1383,19 +1432,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var _propKey in prevProps) - void 0 === nextProps[_propKey] && - (!(attributeConfig = validAttributes[_propKey]) || - (updatePayload && void 0 !== updatePayload[_propKey]) || - ((prevProp = prevProps[_propKey]), + for (var propKey$2 in prevProps) + void 0 === nextProps[propKey$2] && + (!(attributeConfig = validAttributes[propKey$2]) || + (updatePayload && void 0 !== updatePayload[propKey$2]) || + ((prevProp = prevProps[propKey$2]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[_propKey] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$2] = null), removedKeys || (removedKeys = {}), - removedKeys[_propKey] || - ((removedKeys[_propKey] = !0), removedKeyCount++)) + removedKeys[propKey$2] || + ((removedKeys[propKey$2] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1443,37 +1492,49 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null != stateNode && (eventTarget = stateNode.canonical); } batchedUpdates(function() { - var events = eventTarget; - for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { - var possiblePlugin = plugins[i]; + var JSCompiler_inline_result = eventTarget; + for ( + var events = null, legacyPlugins = plugins, i = 0; + i < legacyPlugins.length; + i++ + ) { + var possiblePlugin = legacyPlugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, target, nativeEvent, - events, - 1 + JSCompiler_inline_result )) && - (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); + (events = accumulateInto(events, possiblePlugin)); } - events = events$jscomp$0; - null !== events && (eventQueue = accumulateInto(eventQueue, events)); - events = eventQueue; + JSCompiler_inline_result = events; + null !== JSCompiler_inline_result && + (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); + JSCompiler_inline_result = eventQueue; eventQueue = null; - if (events) { - forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (JSCompiler_inline_result) { + forEachAccumulated( + JSCompiler_inline_result, + executeDispatchesAndReleaseTopLevel + ); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((events = rethrowError), + throw ((JSCompiler_inline_result = rethrowError), (hasRethrowError = !1), (rethrowError = null), - events); + JSCompiler_inline_result); } }); } +function shim() { + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); +} function shim$1() { throw Error( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." @@ -1566,19 +1627,32 @@ var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node; - var updatePayload = diffProperties( + var JSCompiler_inline_result = diffProperties( null, emptyObject, { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); return { - node: cloneNodeWithNewProps(node, updatePayload), + node: cloneNodeWithNewProps(node, JSCompiler_inline_result), canonical: instance.canonical }; } -var valueStack = [], +function describeComponentFrame(name, source, ownerName) { + source = ""; + ownerName && (source = " (created by " + ownerName + ")"); + return "\n in " + (name || "Unknown") + source; +} +function describeFunctionComponentFrame(fn, source) { + return fn + ? describeComponentFrame(fn.displayName || fn.name || null, source, null) + : ""; +} +var valueStack = [], index = -1; +function createCursor(defaultValue) { + return { current: defaultValue }; +} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1589,8 +1663,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = { current: emptyContextObject }, - didPerformWorkStackCursor = { current: !1 }, + contextStackCursor = createCursor(emptyContextObject), + didPerformWorkStackCursor = createCursor(!1), previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1639,7 +1713,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1670,11 +1744,204 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } +var rendererID = null, + injectedHook = null, + Scheduler_now = Scheduler.unstable_now; +Scheduler_now(); +var return_highestLanePriority = 8; +function getHighestPriorityLanes(lanes) { + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; + var inputDiscreteLanes = 24 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 12), inputDiscreteLanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 10), inputDiscreteLanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 8), inputDiscreteLanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 6), inputDiscreteLanes; + inputDiscreteLanes = 62914560 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 5), inputDiscreteLanes; + if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; + if (0 !== (lanes & 134217728)) + return (return_highestLanePriority = 3), 134217728; + inputDiscreteLanes = 805306368 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 2), inputDiscreteLanes; + if (0 !== (1073741824 & lanes)) + return (return_highestLanePriority = 1), 1073741824; + return_highestLanePriority = 8; + return lanes; +} +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case 99: + return 15; + case 98: + return 10; + case 97: + case 96: + return 8; + case 95: + return 2; + default: + return 0; + } +} +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case 15: + case 14: + return 99; + case 13: + case 12: + case 11: + case 10: + return 98; + case 9: + case 8: + case 7: + case 6: + case 4: + case 5: + return 97; + case 3: + case 2: + case 1: + return 95; + case 0: + return 90; + default: + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); + } +} +function getNextLanes(root, wipLanes) { + var pendingLanes = root.pendingLanes; + if (0 === pendingLanes) return (return_highestLanePriority = 0); + var nextLanes = 0, + nextLanePriority = 0, + expiredLanes = root.expiredLanes, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes; + if (0 !== expiredLanes) + (nextLanes = expiredLanes), + (nextLanePriority = return_highestLanePriority = 15); + else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { + var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; + 0 !== nonIdleUnblockedLanes + ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), + (nextLanePriority = return_highestLanePriority)) + : ((pingedLanes &= expiredLanes), + 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority))); + } else + (expiredLanes = pendingLanes & ~suspendedLanes), + 0 !== expiredLanes + ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), + (nextLanePriority = return_highestLanePriority)) + : 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority)); + if (0 === nextLanes) return 0; + nextLanes = 31 - clz32(nextLanes); + nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); + if ( + 0 !== wipLanes && + wipLanes !== nextLanes && + 0 === (wipLanes & suspendedLanes) + ) { + getHighestPriorityLanes(wipLanes); + if (nextLanePriority <= return_highestLanePriority) return wipLanes; + return_highestLanePriority = nextLanePriority; + } + wipLanes = root.entangledLanes; + if (0 !== wipLanes) + for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) + (pendingLanes = 31 - clz32(wipLanes)), + (nextLanePriority = 1 << pendingLanes), + (nextLanes |= root[pendingLanes]), + (wipLanes &= ~nextLanePriority); + return nextLanes; +} +function getLanesToRetrySynchronouslyOnError(root) { + root = root.pendingLanes & -1073741825; + return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; +} +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case 15: + return 1; + case 14: + return 2; + case 12: + return ( + (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + ); + case 10: + return ( + (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority + ); + case 8: + return ( + (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), + 0 === lanePriority && + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), + 0 === lanePriority && (lanePriority = 512)), + lanePriority + ); + case 2: + return ( + (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), + 0 === wipLanes && (wipLanes = 268435456), + wipLanes + ); + } + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); +} +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; +} +function markRootUpdated(root, updateLane, eventTime) { + root.pendingLanes |= updateLane; + var higherPriorityLanes = updateLane - 1; + root.suspendedLanes &= higherPriorityLanes; + root.pingedLanes &= higherPriorityLanes; + root = root.eventTimes; + updateLane = 31 - clz32(updateLane); + root[updateLane] = eventTime; +} +var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, + log = Math.log, + LN2 = Math.LN2; +function clz32Fallback(lanes) { + return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; +} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now = Scheduler.unstable_now, + Scheduler_now$1 = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -1683,18 +1950,17 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_LowPriority = Scheduler.unstable_LowPriority, Scheduler_IdlePriority = Scheduler.unstable_IdlePriority, fakeCallbackNode = {}, - shouldYield = Scheduler.unstable_shouldYield, requestPaint = void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), + initialTimeMs$1 = Scheduler_now$1(), now = - 1e4 > initialTimeMs - ? Scheduler_now + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 : function() { - return Scheduler_now() - initialTimeMs; + return Scheduler_now$1() - initialTimeMs$1; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -1736,16 +2002,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } -function scheduleSyncCallback(callback) { - null === syncQueue - ? ((syncQueue = [callback]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(callback); - return fakeCallbackNode; -} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -1780,6 +2036,7 @@ function flushSyncCallbackQueueImpl() { } } } +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -1805,42 +2062,29 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; -function getStackByFiberInDevAndProd(workInProgress) { - var info = ""; - do { - a: switch (workInProgress.tag) { - case 3: - case 4: - case 6: - case 7: - case 10: - case 9: - var JSCompiler_inline_result = ""; - break a; - default: - var owner = workInProgress._debugOwner, - source = workInProgress._debugSource, - name = getComponentName(workInProgress.type); - JSCompiler_inline_result = null; - owner && (JSCompiler_inline_result = getComponentName(owner.type)); - owner = name; - name = ""; - source - ? (name = - " (at " + - source.fileName.replace(BEFORE_SLASH_RE, "") + - ":" + - source.lineNumber + - ")") - : JSCompiler_inline_result && - (name = " (created by " + JSCompiler_inline_result + ")"); - JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - } - info += JSCompiler_inline_result; - workInProgress = workInProgress.return; - } while (workInProgress); - return info; +function describeFiber(fiber) { + switch (fiber.tag) { + case 5: + return describeComponentFrame(fiber.type, null, null); + case 16: + return describeComponentFrame("Lazy", null, null); + case 13: + return describeComponentFrame("Suspense", null, null); + case 19: + return describeComponentFrame("SuspenseList", null, null); + case 0: + case 2: + case 15: + return describeFunctionComponentFrame(fiber.type, null); + case 11: + return describeFunctionComponentFrame(fiber.type.render, null); + case 22: + return describeFunctionComponentFrame(fiber.type._render, null); + case 1: + return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; + default: + return ""; + } } function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { @@ -1849,10 +2093,11 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); + return baseProps; } return baseProps; } -var valueCursor = { current: null }, +var valueCursor = createCursor(null), currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -1864,31 +2109,29 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue2 = currentValue; } -function scheduleWorkOnParentPath(parent, renderExpirationTime) { +function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { var alternate = parent.alternate; - if (parent.childExpirationTime < renderExpirationTime) - (parent.childExpirationTime = renderExpirationTime), - null !== alternate && - alternate.childExpirationTime < renderExpirationTime && - (alternate.childExpirationTime = renderExpirationTime); - else if ( - null !== alternate && - alternate.childExpirationTime < renderExpirationTime - ) - alternate.childExpirationTime = renderExpirationTime; - else break; + if ((parent.childLanes & renderLanes) === renderLanes) + if ( + null === alternate || + (alternate.childLanes & renderLanes) === renderLanes + ) + break; + else alternate.childLanes |= renderLanes; + else + (parent.childLanes |= renderLanes), + null !== alternate && (alternate.childLanes |= renderLanes); parent = parent.return; } } -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress, renderLanes) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (workInProgress.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0), + (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -1907,7 +2150,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - expirationTime: 0, + lanes: 0, firstContext: observedBits, responders: null }; @@ -1919,7 +2162,8 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - baseQueue: null, + firstBaseUpdate: null, + lastBaseUpdate: null, shared: { pending: null }, effects: null }; @@ -1929,21 +2173,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - baseQueue: current.baseQueue, + firstBaseUpdate: current.firstBaseUpdate, + lastBaseUpdate: current.lastBaseUpdate, shared: current.shared, effects: current.effects }); } -function createUpdate(expirationTime, suspenseConfig) { - expirationTime = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, +function createUpdate(eventTime, lane) { + return { + eventTime: eventTime, + lane: lane, tag: 0, payload: null, callback: null, next: null }; - return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -1956,132 +2200,177 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, update) { - var current = workInProgress.alternate; - null !== current && cloneUpdateQueue(current, workInProgress); - workInProgress = workInProgress.updateQueue; - current = workInProgress.baseQueue; - null === current - ? ((workInProgress.baseQueue = update.next = update), - (update.next = update)) - : ((update.next = current.next), (current.next = update)); +function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + var queue = workInProgress.updateQueue, + current = workInProgress.alternate; + if ( + null !== current && + ((current = current.updateQueue), queue === current) + ) { + var newFirst = null, + newLast = null; + queue = queue.firstBaseUpdate; + if (null !== queue) { + do { + var clone = { + eventTime: queue.eventTime, + lane: queue.lane, + tag: queue.tag, + payload: queue.payload, + callback: queue.callback, + next: null + }; + null === newLast + ? (newFirst = newLast = clone) + : (newLast = newLast.next = clone); + queue = queue.next; + } while (null !== queue); + null === newLast + ? (newFirst = newLast = capturedUpdate) + : (newLast = newLast.next = capturedUpdate); + } else newFirst = newLast = capturedUpdate; + queue = { + baseState: current.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: current.shared, + effects: current.effects + }; + workInProgress.updateQueue = queue; + return; + } + workInProgress = queue.lastBaseUpdate; + null === workInProgress + ? (queue.firstBaseUpdate = capturedUpdate) + : (workInProgress.next = capturedUpdate); + queue.lastBaseUpdate = capturedUpdate; } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderExpirationTime + renderLanes ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var baseQueue = queue.baseQueue, + var firstBaseUpdate = queue.firstBaseUpdate, + lastBaseUpdate = queue.lastBaseUpdate, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - if (null !== baseQueue) { - var baseFirst = baseQueue.next; - baseQueue.next = pendingQueue.next; - pendingQueue.next = baseFirst; - } - baseQueue = pendingQueue; queue.shared.pending = null; - baseFirst = workInProgress$jscomp$0.alternate; - null !== baseFirst && - ((baseFirst = baseFirst.updateQueue), - null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); + var lastPendingUpdate = pendingQueue, + firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; + null === lastBaseUpdate + ? (firstBaseUpdate = firstPendingUpdate) + : (lastBaseUpdate.next = firstPendingUpdate); + lastBaseUpdate = lastPendingUpdate; + var current = workInProgress$jscomp$0.alternate; + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate + ? (current.firstBaseUpdate = firstPendingUpdate) + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } - if (null !== baseQueue) { - baseFirst = baseQueue.next; - var newState = queue.baseState, - newExpirationTime = 0, - newBaseState = null, - newBaseQueueFirst = null, - newBaseQueueLast = null; - if (null !== baseFirst) { - var update = baseFirst; - do { - pendingQueue = update.expirationTime; - if (pendingQueue < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, + if (null !== firstBaseUpdate) { + currentLastBaseUpdate = queue.baseState; + lastBaseUpdate = 0; + current = firstPendingUpdate = lastPendingUpdate = null; + do { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { + null !== current && + (current = current.next = { + eventTime: updateEventTime, + lane: 0, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (newBaseState = newState)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - pendingQueue > newExpirationTime && - (newExpirationTime = pendingQueue); - } else { - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }); - markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); - a: { - var workInProgress = workInProgress$jscomp$0, - update$jscomp$0 = update; - pendingQueue = props; - clone = instance; - switch (update$jscomp$0.tag) { - case 1: - workInProgress = update$jscomp$0.payload; - if ("function" === typeof workInProgress) { - newState = workInProgress.call(clone, newState, pendingQueue); - break a; - } - newState = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update$jscomp$0.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call(clone, newState, pendingQueue) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - newState = Object.assign({}, newState, pendingQueue); + }); + a: { + var workInProgress = workInProgress$jscomp$0, + update = firstBaseUpdate; + pendingQueue = props; + updateEventTime = instance; + switch (update.tag) { + case 1: + workInProgress = update.payload; + if ("function" === typeof workInProgress) { + currentLastBaseUpdate = workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ); break a; - case 2: - hasForceUpdate = !0; - } + } + currentLastBaseUpdate = workInProgress; + break a; + case 3: + workInProgress.flags = (workInProgress.flags & -8193) | 64; + case 0: + workInProgress = update.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); + break a; + case 2: + hasForceUpdate = !0; } - null !== update.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [update]) - : pendingQueue.push(update)); } - update = update.next; - if (null === update || update === baseFirst) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (update = baseQueue.next = pendingQueue.next), - (pendingQueue.next = baseFirst), - (queue.baseQueue = baseQueue = pendingQueue), - (queue.shared.pending = null); - } while (1); - } - null === newBaseQueueLast - ? (newBaseState = newState) - : (newBaseQueueLast.next = newBaseQueueFirst); - queue.baseState = newBaseState; - queue.baseQueue = newBaseQueueLast; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress$jscomp$0.expirationTime = newExpirationTime; - workInProgress$jscomp$0.memoizedState = newState; + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); + } else + (updateEventTime = { + eventTime: updateEventTime, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, + next: null + }), + null === current + ? ((firstPendingUpdate = current = updateEventTime), + (lastPendingUpdate = currentLastBaseUpdate)) + : (current = current.next = updateEventTime), + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), + (queue.shared.pending = null); + } while (1); + null === current && (lastPendingUpdate = currentLastBaseUpdate); + queue.baseState = lastPendingUpdate; + queue.firstBaseUpdate = firstPendingUpdate; + queue.lastBaseUpdate = current; + workInProgressRootSkippedLanes |= lastBaseUpdate; + workInProgress$jscomp$0.lanes = lastBaseUpdate; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2106,8 +2395,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2121,54 +2409,45 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.expirationTime && + 0 === workInProgress.lanes && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternalFiber) + return (component = component._reactInternals) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2206,7 +2485,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternalFiber = workInProgress; + ctor._reactInternals = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2227,12 +2506,7 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { +function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2245,7 +2519,7 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2262,15 +2536,10 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue( - workInProgress, - newProps, - instance, - renderExpirationTime - ), + processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2285,7 +2554,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2319,7 +2588,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2331,7 +2600,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - ")." + "). If you meant to render a collection of children, use an array instead." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2343,7 +2612,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2375,26 +2644,22 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, expirationTime) { + function updateTextNode(returnFiber, current, textContent, lanes) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromText(textContent, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2402,27 +2667,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, expirationTime) { + function updateElement(returnFiber, current, element, lanes) { if (null !== current && current.elementType === element.type) return ( - (expirationTime = useFiber(current, element.props)), - (expirationTime.ref = coerceRef(returnFiber, current, element)), - (expirationTime.return = returnFiber), - expirationTime + (lanes = useFiber(current, element.props)), + (lanes.ref = coerceRef(returnFiber, current, element)), + (lanes.return = returnFiber), + lanes ); - expirationTime = createFiberFromTypeAndProps( + lanes = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - expirationTime + lanes ); - expirationTime.ref = coerceRef(returnFiber, current, element); - expirationTime.return = returnFiber; - return expirationTime; + lanes.ref = coerceRef(returnFiber, current, element); + lanes.return = returnFiber; + return lanes; } - function updatePortal(returnFiber, current, portal, expirationTime) { + function updatePortal(returnFiber, current, portal, lanes) { if ( null === current || 4 !== current.tag || @@ -2430,11 +2695,7 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2442,13 +2703,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, expirationTime, key) { + function updateFragment(returnFiber, current, fragment, lanes, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - expirationTime, + lanes, key )), (current.return = returnFiber), @@ -2458,13 +2719,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, expirationTime) { + function createChild(returnFiber, newChild, lanes) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2473,24 +2734,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( + (lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef(returnFiber, null, newChild)), - (expirationTime.return = returnFiber), - expirationTime + (lanes.ref = coerceRef(returnFiber, null, newChild)), + (lanes.return = returnFiber), + lanes ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2501,7 +2762,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - expirationTime, + lanes, null )), (newChild.return = returnFiber), @@ -2511,12 +2772,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { + function updateSlot(returnFiber, oldFiber, newChild, lanes) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); + : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2526,26 +2787,20 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - expirationTime, + lanes, key ) - : updateElement(returnFiber, oldFiber, newChild, expirationTime) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) + ? updatePortal(returnFiber, oldFiber, newChild, lanes) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment( - returnFiber, - oldFiber, - newChild, - expirationTime, - null - ); + : updateFragment(returnFiber, oldFiber, newChild, lanes, null); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2555,17 +2810,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - expirationTime + lanes ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode( - returnFiber, - existingChildren, - "" + newChild, - expirationTime - ) + updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2580,15 +2830,10 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - expirationTime, + lanes, newChild.key ) - : updateElement( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -2596,24 +2841,13 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + updatePortal(returnFiber, existingChildren, newChild, lanes) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment( - returnFiber, - existingChildren, - newChild, - expirationTime, - null - ) + updateFragment(returnFiber, existingChildren, newChild, lanes, null) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2623,7 +2857,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - expirationTime + lanes ) { for ( var resultingFirstChild = null, @@ -2641,7 +2875,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - expirationTime + lanes ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2664,11 +2898,7 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )), + (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -2691,7 +2921,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - expirationTime + lanes )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -2718,7 +2948,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - expirationTime + lanes ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -2740,12 +2970,7 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot( - returnFiber, - oldFiber, - step.value, - expirationTime - ); + var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -2765,7 +2990,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, expirationTime)), + (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -2779,13 +3004,7 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap( - oldFiber, - returnFiber, - newIdx, - step.value, - expirationTime - )), + (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -2801,7 +3020,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, expirationTime) { + return function(returnFiber, currentFirstChild, newChild, lanes) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -2867,26 +3086,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - expirationTime, + lanes, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( + : ((lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef( + (lanes.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (expirationTime.return = returnFiber), - (returnFiber = expirationTime)); + (lanes.return = returnFiber), + (returnFiber = lanes)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -2925,7 +3144,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -2944,7 +3163,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - expirationTime + lanes )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -2955,25 +3174,27 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -2981,9 +3202,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = { current: NO_CONTEXT }, - contextFiberStackCursor = { current: NO_CONTEXT }, - rootInstanceStackCursor = { current: NO_CONTEXT }; + contextStackCursor$1 = createCursor(NO_CONTEXT), + contextFiberStackCursor = createCursor(NO_CONTEXT), + rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3006,26 +3227,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var nextContext = fiber.type; - nextContext = - "AndroidTextInput" === nextContext || - "RCTMultilineTextInputView" === nextContext || - "RCTSinglelineTextInputView" === nextContext || - "RCTText" === nextContext || - "RCTVirtualText" === nextContext; - nextContext = - context.isInAParentText !== nextContext - ? { isInAParentText: nextContext } + var JSCompiler_inline_result = fiber.type; + JSCompiler_inline_result = + "AndroidTextInput" === JSCompiler_inline_result || + "RCTMultilineTextInputView" === JSCompiler_inline_result || + "RCTSinglelineTextInputView" === JSCompiler_inline_result || + "RCTText" === JSCompiler_inline_result || + "RCTVirtualText" === JSCompiler_inline_result; + JSCompiler_inline_result = + context.isInAParentText !== JSCompiler_inline_result + ? { isInAParentText: JSCompiler_inline_result } : context; - context !== nextContext && + context !== JSCompiler_inline_result && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, nextContext)); + push(contextStackCursor$1, JSCompiler_inline_result)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = { current: 0 }; +var suspenseStackCursor = createCursor(0); function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3033,7 +3254,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim$1() || shim$1())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3049,19 +3270,23 @@ function findFirstSuspended(row) { } return null; } -function createDeprecatedResponderListener(responder, props) { - return { responder: responder, props: props }; +var workInProgressSources = []; +function resetWorkInProgressVersions() { + for (var i = 0; i < workInProgressSources.length; i++) + workInProgressSources[i]._workInProgressVersionSecondary = null; + workInProgressSources.length = 0; } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderExpirationTime = 0, + renderLanes = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1; + didScheduleRenderPhaseUpdate = !1, + didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3076,36 +3301,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderExpirationTime + nextRenderLanes ) { - renderExpirationTime = nextRenderExpirationTime; + renderLanes = nextRenderLanes; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.expirationTime = 0; - ReactCurrentDispatcher.current = + workInProgress.lanes = 0; + ReactCurrentDispatcher$1.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (workInProgress.expirationTime === renderExpirationTime) { - nextRenderExpirationTime = 0; + if (didScheduleRenderPhaseUpdateDuringThisPass) { + nextRenderLanes = 0; do { - workInProgress.expirationTime = 0; - if (!(25 > nextRenderExpirationTime)) + didScheduleRenderPhaseUpdateDuringThisPass = !1; + if (!(25 > nextRenderLanes)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderExpirationTime += 1; + nextRenderLanes += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (workInProgress.expirationTime === renderExpirationTime); + } while (didScheduleRenderPhaseUpdateDuringThisPass); } - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3186,40 +3411,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var updateExpirationTime = update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }; - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - updateExpirationTime > currentlyRenderingFiber$1.expirationTime && - ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), - markUnprocessedUpdateTime(updateExpirationTime)); - } else + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) null !== newBaseQueueLast && (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), (current = update.eagerReducer === reducer ? update.eagerState : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3256,6 +3475,114 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } +function readFromUnsubcribedMutableSource(root, source, getSnapshot) { + var getVersion = source._getVersion; + getVersion = getVersion(source._source); + var JSCompiler_inline_result = source._workInProgressVersionSecondary; + if (null !== JSCompiler_inline_result) + root = JSCompiler_inline_result === getVersion; + else if ( + ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) + ) + (source._workInProgressVersionSecondary = getVersion), + workInProgressSources.push(source); + if (root) return getSnapshot(source._source); + workInProgressSources.push(source); + throw Error( + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." + ); +} +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = workInProgressRoot; + if (null === root) + throw Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + var getVersion = source._getVersion, + version = getVersion(source._source), + dispatcher = ReactCurrentDispatcher$1.current, + _dispatcher$useState = dispatcher.useState(function() { + return readFromUnsubcribedMutableSource(root, source, getSnapshot); + }), + setSnapshot = _dispatcher$useState[1], + snapshot = _dispatcher$useState[0]; + _dispatcher$useState = workInProgressHook; + var memoizedState = hook.memoizedState, + refs = memoizedState.refs, + prevGetSnapshot = refs.getSnapshot, + prevSource = memoizedState.source; + memoizedState = memoizedState.subscribe; + var fiber = currentlyRenderingFiber$1; + hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; + dispatcher.useEffect( + function() { + refs.getSnapshot = getSnapshot; + refs.setSnapshot = setSnapshot; + var maybeNewVersion = getVersion(source._source); + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); + maybeNewVersion = root.mutableReadLanes; + root.entangledLanes |= maybeNewVersion; + for ( + var entanglements = root.entanglements, lanes = maybeNewVersion; + 0 < lanes; + + ) { + var index$11 = 31 - clz32(lanes), + lane = 1 << index$11; + entanglements[index$11] |= maybeNewVersion; + lanes &= ~lane; + } + } + }, + [getSnapshot, source, subscribe] + ); + dispatcher.useEffect( + function() { + return subscribe(source._source, function() { + var latestGetSnapshot = refs.getSnapshot, + latestSetSnapshot = refs.setSnapshot; + try { + latestSetSnapshot(latestGetSnapshot(source._source)); + var lane = requestUpdateLane(fiber); + root.mutableReadLanes |= lane & root.pendingLanes; + } catch (error) { + latestSetSnapshot(function() { + throw error; + }); + } + }); + }, + [source, subscribe] + ); + (objectIs(prevGetSnapshot, getSnapshot) && + objectIs(prevSource, source) && + objectIs(memoizedState, subscribe)) || + ((hook = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), + (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); + return snapshot; +} +function updateMutableSource(source, getSnapshot, subscribe) { + var hook = updateWorkInProgressHook(); + return useMutableSource(hook, source, getSnapshot, subscribe); +} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3292,17 +3619,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3310,12 +3637,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3354,13 +3681,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3388,65 +3708,60 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); - suspenseConfig = { - expirationTime: currentTime, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + var eventTime = requestEventTime(), + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdate = !0), - (suspenseConfig.expirationTime = renderExpirationTime), - (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { if ( - 0 === fiber.expirationTime && - (null === pending || 0 === pending.expirationTime) && + 0 === fiber.lanes && + (null === pending || 0 === pending.lanes) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } -function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3459,14 +3774,21 @@ var ContextOnlyDispatcher = { useRef: throwInvalidHookError, useState: throwInvalidHookError, useDebugValue: throwInvalidHookError, - useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useEvent: throwInvalidHookError + useMutableSource: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, + unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3512,39 +3834,44 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; + }, + useMutableSource: function(source, getSnapshot, subscribe) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); }, - useEvent: function() {} + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); + }, + unstable_isNewReconciler: !1 }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -3560,39 +3887,33 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, - useEvent: updateEventListener + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; + }, + unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { readContext: readContext, @@ -3608,61 +3929,45 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, - useEvent: updateEventListener + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; + }, + unstable_isNewReconciler: !1 }, ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime -) { +function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress.child = null === current - ? mountChildFibers( - workInProgress, - null, - nextChildren, - renderExpirationTime - ) + ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderExpirationTime + renderLanes ); } function updateForwardRef( @@ -3670,33 +3975,28 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } function updateMemoComponent( @@ -3704,8 +4004,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (null === current) { var type = Component.type; @@ -3724,17 +4024,17 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); current = createFiberFromTypeAndProps( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, - renderExpirationTime + renderLanes ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3742,19 +4042,14 @@ function updateMemoComponent( } type = current.child; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), + 0 === (updateLanes & renderLanes) && + ((updateLanes = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current.ref === workInProgress.ref) + Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3765,26 +4060,63 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { - return null !== current && + if ( + null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref && - ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) - ? ((workInProgress.expirationTime = current.expirationTime), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - )) - : updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderExpirationTime + current.ref === workInProgress.ref + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else + return ( + (workInProgress.lanes = current.lanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + ); + return updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderLanes + ); +} +function updateOffscreenComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, + nextChildren = nextProps.children, + prevState = null !== current ? current.memoizedState : null; + if ( + "hidden" === nextProps.mode || + "unstable-defer-without-hiding" === nextProps.mode + ) + if (0 === (workInProgress.mode & 4)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes(workInProgress, renderLanes); + else if (0 !== (renderLanes & 1073741824)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes( + workInProgress, + null !== prevState ? prevState.baseLanes : renderLanes + ); + else + return ( + (current = + null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), + (workInProgress.lanes = workInProgress.childLanes = 1073741824), + (workInProgress.memoizedState = { baseLanes: current }), + pushRenderLanes(workInProgress, current), + null ); + else + null !== prevState + ? ((nextProps = prevState.baseLanes | renderLanes), + (workInProgress.memoizedState = null)) + : (nextProps = renderLanes), + pushRenderLanes(workInProgress, nextProps); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -3792,42 +4124,37 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } function updateClassComponent( @@ -3835,25 +4162,20 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ), + mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -3884,12 +4206,7 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ); + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -3922,9 +4239,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -3932,119 +4249,113 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); - } else - (instance = workInProgress.stateNode), - cloneUpdateQueue(current, workInProgress), - (oldProps = workInProgress.memoizedProps), - (instance.props = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps)), - (oldContext = instance.context), - (contextType = Component.contextType), - "object" === typeof contextType && null !== contextType - ? (contextType = readContext(contextType)) - : ((contextType = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = - "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( + } else { + instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); + oldProps = workInProgress.memoizedProps; + contextType = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); + instance.props = contextType; + hasNewLifecycles = workInProgress.pendingProps; + oldState = instance.context; + oldContext = Component.contextType; + "object" === typeof oldContext && null !== oldContext + ? (oldContext = readContext(oldContext)) + : ((oldContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (oldContext = getMaskedContext(workInProgress, oldContext))); + var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; + (getDerivedStateFromProps = + "function" === typeof getDerivedStateFromProps$jscomp$0 || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== hasNewLifecycles || oldState !== oldContext) && + callComponentWillReceiveProps( + workInProgress, + instance, + nextProps, + oldContext + )); + hasForceUpdate = !1; + oldState = workInProgress.memoizedState; + instance.state = oldState; + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + var newState = workInProgress.memoizedState; + oldProps !== hasNewLifecycles || + oldState !== newState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && + (applyDerivedStateFromProps( workInProgress, - instance, + Component, + getDerivedStateFromProps$jscomp$0, + nextProps + ), + (newState = workInProgress.memoizedState)), + (contextType = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextType, nextProps, - contextType - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (instance.state = oldContext), - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState), - oldProps !== nextProps || - oldContext !== oldState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldState = workInProgress.memoizedState)), - (getDerivedStateFromProps = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - oldProps, - nextProps, - oldContext, - oldState, - contextType - )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( - nextProps, - oldState, - contextType - ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - oldState, - contextType - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), - (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); + oldState, + newState, + oldContext + )) + ? (getDerivedStateFromProps || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate(nextProps, newState, oldContext), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + newState, + oldContext + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.flags |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.flags |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = newState)), + (instance.props = nextProps), + (instance.state = newState), + (instance.context = oldContext), + (nextProps = contextType)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (nextProps = !1)); + } return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderExpirationTime + renderLanes ); } function finishClassComponent( @@ -4053,18 +4364,14 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4072,26 +4379,21 @@ function finishClassComponent( didCaptureError && "function" !== typeof Component.getDerivedStateFromError ? null : shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((workInProgress.child = reconcileChildFibers( workInProgress, current.child, null, - renderExpirationTime + renderLanes )), (workInProgress.child = reconcileChildFibers( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ))) - : reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + : reconcileChildren(current, workInProgress, nextChildren, renderLanes); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4108,155 +4410,214 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; -function updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime -) { - var mode = workInProgress.mode, - nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; +function updateSuspenseComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - nextDidTimeout = !1, + showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = - 0 !== (suspenseContext & 2) && - (null === current || null !== current.memoizedState)); + null !== current && null === current.memoizedState + ? !1 + : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + current = nextProps.children; + suspenseContext = nextProps.fallback; + if (showFallback) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + current ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - mode = nextProps.children; - workInProgress.memoizedState = null; - return (workInProgress.child = mountChildFibers( - workInProgress, - null, - mode, - renderExpirationTime - )); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), + current + ); + renderLanes = createFiberFromOffscreen( + { mode: "visible", children: current }, + workInProgress.mode, + renderLanes, + null + ); + renderLanes.return = workInProgress; + return (workInProgress.child = renderLanes); } if (null !== current.memoizedState) { - current = current.child; - mode = current.sibling; - if (nextDidTimeout) { - nextProps = nextProps.fallback; - renderExpirationTime = createWorkInProgress( - current, - current.pendingProps + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - if ( - 0 === (workInProgress.mode & 2) && - ((nextDidTimeout = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child), - nextDidTimeout !== current.child) - ) - for ( - renderExpirationTime.child = nextDidTimeout; - null !== nextDidTimeout; - - ) - (nextDidTimeout.return = renderExpirationTime), - (nextDidTimeout = nextDidTimeout.sibling); - mode = createWorkInProgress(mode, nextProps); - mode.return = workInProgress; - renderExpirationTime.sibling = mode; - renderExpirationTime.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = renderExpirationTime; - return mode; - } - renderExpirationTime = reconcileChildFibers( + renderLanes = updateSuspensePrimaryChildren( + current, workInProgress, - current.child, nextProps.children, - renderExpirationTime + renderLanes ); workInProgress.memoizedState = null; - return (workInProgress.child = renderExpirationTime); + return renderLanes; } - current = current.child; - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - nextProps.child = current; - null !== current && (current.return = nextProps); - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - renderExpirationTime.effectTag |= 2; - nextProps.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - workInProgress.memoizedState = null; - return (workInProgress.child = reconcileChildFibers( - workInProgress, + renderLanes = updateSuspensePrimaryChildren( current, + workInProgress, nextProps.children, - renderExpirationTime - )); + renderLanes + ); + workInProgress.memoizedState = null; + return renderLanes; +} +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren)) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; } -function scheduleWorkOnFiber(fiber, renderExpirationTime) { - fiber.expirationTime < renderExpirationTime && - (fiber.expirationTime = renderExpirationTime); +function updateSuspensePrimaryChildren( + current, + workInProgress, + primaryChildren, + renderLanes +) { + var currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { + mode: "visible", + children: primaryChildren + }); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); + primaryChildren.return = workInProgress; + primaryChildren.sibling = null; + null !== current && + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); + return (workInProgress.child = primaryChildren); +} +function updateSuspenseFallbackChildren( + current, + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + var primaryChildProps = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment + ? ((primaryChildren = workInProgress.child), + (primaryChildren.childLanes = 0), + (primaryChildren.pendingProps = primaryChildProps), + (currentPrimaryChildFragment = primaryChildren.lastEffect), + null !== currentPrimaryChildFragment + ? ((workInProgress.firstEffect = primaryChildren.firstEffect), + (workInProgress.lastEffect = currentPrimaryChildFragment), + (currentPrimaryChildFragment.nextEffect = null)) + : (workInProgress.firstEffect = workInProgress.lastEffect = null)) + : (primaryChildren = createWorkInProgress( + currentPrimaryChildFragment, + primaryChildProps + )); + null !== current + ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) + : ((fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + )), + (fallbackChildren.flags |= 2)); + fallbackChildren.return = workInProgress; + primaryChildren.return = workInProgress; + primaryChildren.sibling = fallbackChildren; + workInProgress.child = primaryChildren; + return fallbackChildren; +} +function scheduleWorkOnFiber(fiber, renderLanes) { + fiber.lanes |= renderLanes; var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < renderExpirationTime && - (alternate.expirationTime = renderExpirationTime); - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + null !== alternate && (alternate.lanes |= renderLanes); + scheduleWorkOnParentPath(fiber.return, renderLanes); } function initSuspenseListRenderState( workInProgress, @@ -4274,7 +4635,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4283,35 +4643,24 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime -) { +function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren( - current, - workInProgress, - nextProps.children, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderExpirationTime); - else if (19 === current.tag) - scheduleWorkOnFiber(current, renderExpirationTime); + scheduleWorkOnFiber(current, renderLanes); + else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4333,30 +4682,29 @@ function updateSuspenseListComponent( else switch (revealOrder) { case "forwards": - renderExpirationTime = workInProgress.child; - for (revealOrder = null; null !== renderExpirationTime; ) - (current = renderExpirationTime.alternate), + renderLanes = workInProgress.child; + for (revealOrder = null; null !== renderLanes; ) + (current = renderLanes.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderExpirationTime), - (renderExpirationTime = renderExpirationTime.sibling); - renderExpirationTime = revealOrder; - null === renderExpirationTime + (revealOrder = renderLanes), + (renderLanes = renderLanes.sibling); + renderLanes = revealOrder; + null === renderLanes ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderExpirationTime.sibling), - (renderExpirationTime.sibling = null)); + : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderExpirationTime, + renderLanes, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderExpirationTime = null; + renderLanes = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4365,14 +4713,14 @@ function updateSuspenseListComponent( break; } current = revealOrder.sibling; - revealOrder.sibling = renderExpirationTime; - renderExpirationTime = revealOrder; + revealOrder.sibling = renderLanes; + renderLanes = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderExpirationTime, + renderLanes, null, tailMode, workInProgress.lastEffect @@ -4393,35 +4741,28 @@ function updateSuspenseListComponent( } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime -) { +function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); - var updateExpirationTime = workInProgress.expirationTime; - 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); - if (workInProgress.childExpirationTime < renderExpirationTime) return null; - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderExpirationTime = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderExpirationTime; - for ( - renderExpirationTime.return = workInProgress; - null !== current.sibling; - - ) - (current = current.sibling), - (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderExpirationTime.return = workInProgress); - renderExpirationTime.sibling = null; + workInProgressRootSkippedLanes |= workInProgress.lanes; + if (0 !== (renderLanes & workInProgress.childLanes)) { + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderLanes = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderLanes; + for (renderLanes.return = workInProgress; null !== current.sibling; ) + (current = current.sibling), + (renderLanes = renderLanes.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderLanes.return = workInProgress); + renderLanes.sibling = null; + } + return workInProgress.child; } - return workInProgress.child; + return null; } var appendAllChildren, updateHostContainer, @@ -4448,7 +4789,7 @@ appendAllChildren = function( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4501,7 +4842,7 @@ function appendAllChildrenToContainer( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4545,7 +4886,7 @@ updateHostContainer = function(workInProgress) { newChildSet = createChildNodeSet(container); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; - workInProgress.effectTag |= 4; + workInProgress.flags |= 4; completeRoot(container, newChildSet); } }; @@ -4583,7 +4924,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { }), (workInProgress.stateNode = type), current - ? (workInProgress.effectTag |= 4) + ? (workInProgress.flags |= 4) : appendAllChildren(type, workInProgress, !1, !1)); } }; @@ -4597,7 +4938,7 @@ updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText, workInProgress )), - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { @@ -4614,17 +4955,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var _lastTailNode = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), + for (var lastTailNode$64 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === _lastTailNode + null === lastTailNode$64 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (_lastTailNode.sibling = null); + : (lastTailNode$64.sibling = null); } } -function completeWork(current, workInProgress, renderExpirationTime) { +function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -4645,10 +4986,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - (current = workInProgress.stateNode), - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)), + resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)), + (null !== current && null !== current.child) || + newProps.hydrate || + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -4657,17 +5002,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderExpirationTime = workInProgress.type; + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderExpirationTime, + renderLanes, newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4679,30 +5023,30 @@ function completeWork(current, workInProgress, renderExpirationTime) { requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; - renderExpirationTime = getViewConfigForType(renderExpirationTime); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - renderExpirationTime.validAttributes + renderLanes.validAttributes ); rootContainerInstance = createNode( current, - renderExpirationTime.uiViewClassName, + renderLanes.uiViewClassName, rootContainerInstance, updatePayload, workInProgress ); current = new ReactFabricHostComponent( current, - renderExpirationTime, + renderLanes, newProps, workInProgress ); current = { node: rootContainerInstance, canonical: current }; appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -4731,52 +5075,35 @@ function completeWork(current, workInProgress, renderExpirationTime) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) - return ( - (workInProgress.expirationTime = renderExpirationTime), workInProgress - ); + if (0 !== (workInProgress.flags & 64)) + return (workInProgress.lanes = renderLanes), workInProgress; newProps = null !== newProps; rootContainerInstance = !1; null !== current && - ((renderExpirationTime = current.memoizedState), - (rootContainerInstance = null !== renderExpirationTime), - newProps || - null === renderExpirationTime || - ((renderExpirationTime = current.child.sibling), - null !== renderExpirationTime && - ((updatePayload = workInProgress.firstEffect), - null !== updatePayload - ? ((workInProgress.firstEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = updatePayload)) - : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = null)), - (renderExpirationTime.effectTag = 8)))); + (rootContainerInstance = null !== current.memoizedState); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); + 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3); else { if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( - workInProgressRoot, - renderExpirationTime$1 - ), - markRootUpdatedAtTime( + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || + markRootSuspended$1( workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); + workInProgressRootRenderLanes + ); } - newProps && (workInProgress.effectTag |= 4); + newProps && (workInProgress.flags |= 4); return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -4788,48 +5115,48 @@ function completeWork(current, workInProgress, renderExpirationTime) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== current && 0 !== (current.effectTag & 64)) + 0 !== workInProgressRootExitStatus || + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderExpirationTime; + current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), - (renderExpirationTime = current), - (rootContainerInstance.effectTag &= 2), + (renderLanes = current), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), (updatePayload = rootContainerInstance.alternate), null === updatePayload - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = renderExpirationTime), + ? ((rootContainerInstance.childLanes = 0), + (rootContainerInstance.lanes = renderLanes), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null)) - : ((rootContainerInstance.childExpirationTime = - updatePayload.childExpirationTime), - (rootContainerInstance.expirationTime = - updatePayload.expirationTime), + (rootContainerInstance.dependencies = null), + (rootContainerInstance.stateNode = null)) + : ((rootContainerInstance.childLanes = + updatePayload.childLanes), + (rootContainerInstance.lanes = updatePayload.lanes), (rootContainerInstance.child = updatePayload.child), (rootContainerInstance.memoizedProps = updatePayload.memoizedProps), @@ -4837,15 +5164,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { updatePayload.memoizedState), (rootContainerInstance.updateQueue = updatePayload.updateQueue), - (renderExpirationTime = updatePayload.dependencies), + (rootContainerInstance.type = updatePayload.type), + (renderLanes = updatePayload.dependencies), (rootContainerInstance.dependencies = - null === renderExpirationTime + null === renderLanes ? null : { - expirationTime: - renderExpirationTime.expirationTime, - firstContext: renderExpirationTime.firstContext, - responders: renderExpirationTime.responders + lanes: renderLanes.lanes, + firstContext: renderLanes.firstContext })), (newProps = newProps.sibling); push( @@ -4856,6 +5182,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); } else { if (!rootContainerInstance) @@ -4863,12 +5195,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -4881,13 +5213,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1 < renderExpirationTime && - ((workInProgress.effectTag |= 64), + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && + 1073741824 !== renderLanes && + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.expirationTime = workInProgress.childExpirationTime = - renderExpirationTime - 1)); + (workInProgress.lanes = 33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -4898,9 +5230,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -4915,6 +5245,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { ), current) : null; + case 23: + case 24: + return ( + popRenderLanes(), + null !== current && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && + "unstable-defer-without-hiding" !== newProps.mode && + (workInProgress.flags |= 4), + null + ); } throw Error( "Unknown unit of work tag (" + @@ -4926,31 +5267,30 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + resetWorkInProgressVersions(); + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null ); case 19: @@ -4959,16 +5299,25 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 23: + case 24: + return popRenderLanes(), null; default: return null; } } function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; + try { + var info = "", + node = source; + do (info += describeFiber(node)), (node = node.return); + while (node); + var JSCompiler_inline_result = info; + } catch (x) { + JSCompiler_inline_result = + "\nError generating stack: " + x.message + "\n" + x.stack; + } + return { value: value, source: source, stack: JSCompiler_inline_result }; } if ( "function" !== @@ -4977,51 +5326,61 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(capturedError) { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( - capturedError - ) && console.error(capturedError.error); -} -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; -function logError(boundary, errorInfo) { - var source = errorInfo.source, - stack = errorInfo.stack; - null === stack && - null !== source && - (stack = getStackByFiberInDevAndProd(source)); - errorInfo = { - componentName: null !== source ? getComponentName(source.type) : null, - componentStack: null !== stack ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: !1, - willRetry: !1 - }; - null !== boundary && - 1 === boundary.tag && - ((errorInfo.errorBoundary = boundary.stateNode), - (errorInfo.errorBoundaryName = getComponentName(boundary.type)), - (errorInfo.errorBoundaryFound = !0), - (errorInfo.willRetry = !0)); +function logCapturedError(boundary, errorInfo) { try { - logCapturedError(errorInfo); + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + componentStack: null !== errorInfo.stack ? errorInfo.stack : "", + error: errorInfo.value, + errorBoundary: + null !== boundary && 1 === boundary.tag ? boundary.stateNode : null + }) && console.error(errorInfo.value); } catch (e) { setTimeout(function() { throw e; }); } } -function safelyCallComponentWillUnmount(current, instance) { - try { - (instance.props = current.memoizedProps), - (instance.state = current.memoizedState), - instance.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, unmountError); +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + lane.payload = { element: null }; + var error = errorInfo.value; + lane.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logCapturedError(fiber, errorInfo); + }; + return lane; +} +function createClassErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + lane.payload = function() { + logCapturedError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (lane.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logCapturedError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return lane; } +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -5041,7 +5400,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -5055,6 +5414,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: + return; case 5: case 6: case 4: @@ -5065,58 +5425,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitHookEffectListUnmount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var destroy = effect.destroy; - effect.destroy = void 0; - void 0 !== destroy && destroy(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} -function commitHookEffectListMount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var create = effect.create; - effect.destroy = create(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - commitHookEffectListMount(3, finishedWork); + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + if (3 === (finishedRoot.tag & 3)) { + var create$81 = finishedRoot.create; + finishedRoot.destroy = create$81(); + } + finishedRoot = finishedRoot.next; + } while (finishedRoot !== current); + } + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + var _effect = finishedRoot; + create$81 = _effect.next; + _effect = _effect.tag; + 0 !== (_effect & 4) && + 0 !== (_effect & 1) && + (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), + enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); + finishedRoot = create$81; + } while (finishedRoot !== current); + } return; case 1: finishedRoot = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current) finishedRoot.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - finishedRoot.componentDidUpdate( - prevProps, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ); - } + finishedWork.flags & 4 && + (null === current + ? finishedRoot.componentDidMount() + : ((create$81 = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current.memoizedProps + )), + finishedRoot.componentDidUpdate( + create$81, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ))); current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5137,10 +5496,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { } return; case 5: - if (null === current && finishedWork.effectTag & 4) - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); + null === current && finishedWork.flags & 4 && shim(); return; case 6: return; @@ -5154,74 +5510,25 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 23: + case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$jscomp$0); - switch (current$jscomp$0.tag) { - case 0: - case 11: - case 14: - case 15: - case 22: - finishedRoot = current$jscomp$0.updateQueue; - if ( - null !== finishedRoot && - ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) - ) { - var firstEffect = finishedRoot.next; - runWithPriority( - 97 < renderPriorityLevel ? 97 : renderPriorityLevel, - function() { - var effect = firstEffect; - do { - var _destroy = effect.destroy; - if (void 0 !== _destroy) { - var current = current$jscomp$0; - try { - _destroy(); - } catch (error) { - captureCommitPhaseError(current, error); - } - } - effect = effect.next; - } while (effect !== firstEffect); - } - ); - } - break; - case 1: - safelyDetachRef(current$jscomp$0); - renderPriorityLevel = current$jscomp$0.stateNode; - "function" === typeof renderPriorityLevel.componentWillUnmount && - safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); - break; - case 5: - safelyDetachRef(current$jscomp$0); - break; - case 4: - createChildNodeSet(current$jscomp$0.stateNode.containerInfo); - } -} -function detachFiber(current) { - var alternate = current.alternate; - current.return = null; - current.child = null; - current.memoizedState = null; - current.updateQueue = null; - current.dependencies = null; - current.alternate = null; - current.firstEffect = null; - current.lastEffect = null; - current.pendingProps = null; - current.memoizedProps = null; - current.stateNode = null; - null !== alternate && detachFiber(alternate); +function detachFiberMutation(fiber) { + fiber.alternate = null; + fiber.child = null; + fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.return = null; + fiber.updateQueue = null; } function commitWork(current, finishedWork) { switch (finishedWork.tag) { @@ -5230,7 +5537,19 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - commitHookEffectListUnmount(3, finishedWork); + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedWork = current = current.next; + do { + if (3 === (finishedWork.tag & 3)) { + var destroy = finishedWork.destroy; + finishedWork.destroy = void 0; + void 0 !== destroy && destroy(); + } + finishedWork = finishedWork.next; + } while (finishedWork !== current); + } return; case 12: return; @@ -5242,6 +5561,9 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; + case 23: + case 24: + return; } a: { switch (finishedWork.tag) { @@ -5260,84 +5582,45 @@ function commitWork(current, finishedWork) { } } function attachSuspenseRetryListeners(finishedWork) { - var thenables = finishedWork.updateQueue; - if (null !== thenables) { + var wakeables = finishedWork.updateQueue; + if (null !== wakeables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - thenables.forEach(function(thenable) { - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - retryCache.has(thenable) || - (retryCache.add(thenable), thenable.then(retry, retry)); + wakeables.forEach(function(wakeable) { + var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + retryCache.has(wakeable) || + (retryCache.add(wakeable), wakeable.then(retry, retry)); }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - expirationTime.payload = { element: null }; - var error = errorInfo.value; - expirationTime.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logError(fiber, errorInfo); - }; - return expirationTime; -} -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - expirationTime.payload = function() { - logError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; - } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (expirationTime.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return expirationTime; +function isSuspenseBoundaryBeingHidden(current, finishedWork) { + return null !== current && + ((current = current.memoizedState), + null === current || null !== current.dehydrated) + ? ((finishedWork = finishedWork.memoizedState), + null !== finishedWork && null === finishedWork.dehydrated) + : !1; } var ceil = Math.ceil, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - NoContext = 0, - LegacyUnbatchedContext = 8, - RenderContext = 16, - CommitContext = 32, - RootIncomplete = 0, - RootFatalErrored = 1, - RootErrored = 2, - RootSuspended = 3, - RootSuspendedWithDelay = 4, - RootCompleted = 5, - executionContext = NoContext, + executionContext = 0, workInProgressRoot = null, workInProgress = null, - renderExpirationTime$1 = 0, - workInProgressRootExitStatus = RootIncomplete, + workInProgressRootRenderLanes = 0, + subtreeRenderLanes = 0, + subtreeRenderLanesCursor = createCursor(0), + workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestProcessedExpirationTime = 1073741823, - workInProgressRootLatestSuspenseTimeout = 1073741823, - workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootNextUnprocessedUpdateTime = 0, - workInProgressRootHasPendingPing = !1, + workInProgressRootIncludedLanes = 0, + workInProgressRootSkippedLanes = 0, + workInProgressRootUpdatedLanes = 0, + workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, - FALLBACK_THROTTLE_MS = 500, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5345,205 +5628,186 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, - currentEventTime = 0; -function requestCurrentTimeForUpdate() { - return (executionContext & (RenderContext | CommitContext)) !== NoContext - ? 1073741821 - ((now() / 10) | 0) - : 0 !== currentEventTime + currentEventTime = -1, + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; +function requestEventTime() { + return 0 !== (executionContext & 48) + ? now() + : -1 !== currentEventTime ? currentEventTime - : (currentEventTime = 1073741821 - ((now() / 10) | 0)); + : (currentEventTime = now()); } -function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1073741823; - var priorityLevel = getCurrentPriorityLevel(); - if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; - if ((executionContext & RenderContext) !== NoContext) - return renderExpirationTime$1; - if (null !== suspenseConfig) - currentTime = - 1073741821 - - 25 * - ((((1073741821 - - currentTime + - (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / - 25) | - 0) + - 1); - else - switch (priorityLevel) { - case 99: - currentTime = 1073741823; - break; - case 98: - currentTime = - 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); - break; - case 97: - case 96: - currentTime = - 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); - break; - case 95: - currentTime = 2; - break; - default: - throw Error("Expected a valid priority level"); - } - null !== workInProgressRoot && - currentTime === renderExpirationTime$1 && - --currentTime; - return currentTime; -} -function scheduleWork(fiber, expirationTime) { + if (0 === (fiber & 2)) return 1; + if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; + 0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes); + if (0 !== ReactCurrentBatchConfig.transition) { + 0 !== currentEventPendingLanes && + (currentEventPendingLanes = + null !== mostRecentlyUpdatedRoot + ? mostRecentlyUpdatedRoot.pendingLanes + : 0); + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; + } + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; +} +function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (50 < nestedUpdateCount) throw ((nestedUpdateCount = 0), (rootWithNestedUpdates = null), Error( - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - )); - fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); - if (null !== fiber) { - var priorityLevel = getCurrentPriorityLevel(); - 1073741823 === expirationTime - ? (executionContext & LegacyUnbatchedContext) !== NoContext && - (executionContext & (RenderContext | CommitContext)) === NoContext - ? performSyncWorkOnRoot(fiber) - : (ensureRootIsScheduled(fiber), - executionContext === NoContext && flushSyncCallbackQueue()) - : ensureRootIsScheduled(fiber); - (executionContext & 4) === NoContext || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) - : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), - (void 0 === priorityLevel || priorityLevel > expirationTime) && - rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); - } -} -function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); - var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < expirationTime && - (alternate.expirationTime = expirationTime); - var node = fiber.return, - root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; - else - for (; null !== node; ) { - alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); - null !== alternate && - alternate.childExpirationTime < expirationTime && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { - root = node.stateNode; - break; + "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." + )); + fiber = markUpdateLaneFromFiberToRoot(fiber, lane); + if (null === fiber) return null; + markRootUpdated(fiber, lane, eventTime); + fiber === workInProgressRoot && + ((workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(fiber, workInProgressRootRenderLanes)); + var priorityLevel = getCurrentPriorityLevel(); + 1 === lane + ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) + ? performSyncWorkOnRoot(fiber) + : (ensureRootIsScheduled(fiber, eventTime), + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) + : (0 === (executionContext & 4) || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) + : rootsWithPendingDiscreteUpdates.add(fiber)), + ensureRootIsScheduled(fiber, eventTime)); + mostRecentlyUpdatedRoot = fiber; +} +function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + sourceFiber.lanes |= lane; + var alternate = sourceFiber.alternate; + null !== alternate && (alternate.lanes |= lane); + alternate = sourceFiber; + for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) + (sourceFiber.childLanes |= lane), + (alternate = sourceFiber.alternate), + null !== alternate && (alternate.childLanes |= lane), + (alternate = sourceFiber), + (sourceFiber = sourceFiber.return); + return 3 === alternate.tag ? alternate.stateNode : null; +} +function ensureRootIsScheduled(root, currentTime) { + for ( + var existingCallbackNode = root.callbackNode, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes; + 0 < lanes; + + ) { + var index$5 = 31 - clz32(lanes), + lane = 1 << index$5, + expirationTime = expirationTimes[index$5]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { + expirationTime = currentTime; + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; + expirationTimes[index$5] = + 10 <= priority + ? expirationTime + 250 + : 6 <= priority + ? expirationTime + 5e3 + : -1; } - node = node.return; - } - null !== root && - (workInProgressRoot === root && - (markUnprocessedUpdateTime(expirationTime), - workInProgressRootExitStatus === RootSuspendedWithDelay && - markRootSuspendedAtTime(root, renderExpirationTime$1)), - markRootUpdatedAtTime(root, expirationTime)); - return root; -} -function getNextRootExpirationTimeToWorkOn(root) { - var lastExpiredTime = root.lastExpiredTime; - if (0 !== lastExpiredTime) return lastExpiredTime; - lastExpiredTime = root.firstPendingTime; - if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; - var lastPingedTime = root.lastPingedTime; - root = root.nextKnownPendingLevel; - root = lastPingedTime > root ? lastPingedTime : root; - return 2 >= root && lastExpiredTime !== root ? 0 : root; -} -function ensureRootIsScheduled(root) { - if (0 !== root.lastExpiredTime) - (root.callbackExpirationTime = 1073741823), - (root.callbackPriority = 99), - (root.callbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - )); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + suspendedLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + currentTime = return_highestLanePriority; + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode), + (root.callbackNode = null), + (root.callbackPriority = 0)); else { - var expirationTime = getNextRootExpirationTimeToWorkOn(root), - existingCallbackNode = root.callbackNode; - if (0 === expirationTime) - null !== existingCallbackNode && - ((root.callbackNode = null), - (root.callbackExpirationTime = 0), - (root.callbackPriority = 90)); - else { - var priorityLevel = requestCurrentTimeForUpdate(); - 1073741823 === expirationTime - ? (priorityLevel = 99) - : 1 === expirationTime || 2 === expirationTime - ? (priorityLevel = 95) - : ((priorityLevel = - 10 * (1073741821 - expirationTime) - - 10 * (1073741821 - priorityLevel)), - (priorityLevel = - 0 >= priorityLevel - ? 99 - : 250 >= priorityLevel - ? 98 - : 5250 >= priorityLevel - ? 97 - : 95)); - if (null !== existingCallbackNode) { - var existingCallbackPriority = root.callbackPriority; - if ( - root.callbackExpirationTime === expirationTime && - existingCallbackPriority >= priorityLevel - ) - return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); - } - root.callbackExpirationTime = expirationTime; - root.callbackPriority = priorityLevel; - expirationTime = - 1073741823 === expirationTime - ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleCallback( - priorityLevel, - performConcurrentWorkOnRoot.bind(null, root), - { timeout: 10 * (1073741821 - expirationTime) - now() } - ); - root.callbackNode = expirationTime; + if (null !== existingCallbackNode) { + if (root.callbackPriority === currentTime) return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); } + 15 === currentTime + ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), + null === syncQueue + ? ((syncQueue = [existingCallbackNode]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(existingCallbackNode), + (existingCallbackNode = fakeCallbackNode)) + : 14 === currentTime + ? (existingCallbackNode = scheduleCallback( + 99, + performSyncWorkOnRoot.bind(null, root) + )) + : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), + (existingCallbackNode = scheduleCallback( + existingCallbackNode, + performConcurrentWorkOnRoot.bind(null, root) + ))); + root.callbackPriority = currentTime; + root.callbackNode = existingCallbackNode; } } -function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = 0; - if (didTimeout) { - didTimeout = requestCurrentTimeForUpdate(); - var lastExpiredTime = root.lastExpiredTime; - if (0 === lastExpiredTime || lastExpiredTime > didTimeout) - root.lastExpiredTime = didTimeout; - ensureRootIsScheduled(root); - return null; - } - lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); - if (0 === lastExpiredTime) return null; - didTimeout = root.callbackNode; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) +function performConcurrentWorkOnRoot(root) { + currentEventTime = -1; + currentEventPendingLanes = currentEventWipLanes = 0; + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - flushPassiveEffects(); - var expirationTime = lastExpiredTime; - var exitStatus = executionContext; - executionContext |= RenderContext; + var originalCallbackNode = root.callbackNode; + if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + return null; + var lanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + if (0 === lanes) return null; + var exitStatus = lanes; + var prevExecutionContext = executionContext; + executionContext |= 16; var prevDispatcher = pushDispatcher(); - (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || - prepareFreshStack(root, expirationTime); + if ( + workInProgressRoot !== root || + workInProgressRootRenderLanes !== exitStatus + ) + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, exitStatus); do try { workLoopConcurrent(); @@ -5553,199 +5817,163 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - ReactCurrentDispatcher$1.current = prevDispatcher; - executionContext = exitStatus; + ReactCurrentDispatcher$2.current = prevDispatcher; + executionContext = prevExecutionContext; null !== workInProgress - ? (exitStatus = RootIncomplete) + ? (exitStatus = 0) : ((workInProgressRoot = null), + (workInProgressRootRenderLanes = 0), (exitStatus = workInProgressRootExitStatus)); - if (exitStatus !== RootIncomplete) { - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) - throw ((didTimeout = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - didTimeout); - expirationTime = root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) + prepareFreshStack(root, 0); + else if (0 !== exitStatus) { + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = root.current.alternate; + root.finishedLanes = lanes; switch (exitStatus) { - case RootIncomplete: - case RootFatalErrored: + case 0: + case 1: throw Error("Root did not complete. This is a bug in React."); - case RootErrored: + case 2: commitRoot(root); break; - case RootSuspended: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - expirationTime - )); + case 3: + markRootSuspended$1(root, lanes); if ( - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - ((expirationTime = - globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), - 10 < expirationTime) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { - if ( - workInProgressRootHasPendingPing && - ((prevDispatcher = root.lastPingedTime), - 0 === prevDispatcher || prevDispatcher >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - prevDispatcher = getNextRootExpirationTimeToWorkOn(root); - if (0 !== prevDispatcher && prevDispatcher !== lastExpiredTime) break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; + if (0 !== getNextLanes(root, 0)) break; + prevExecutionContext = root.suspendedLanes; + if ((prevExecutionContext & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevExecutionContext; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - expirationTime + exitStatus ); break; } commitRoot(root); break; - case RootSuspendedWithDelay: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - expirationTime - )); - if ( - workInProgressRootHasPendingPing && - ((expirationTime = root.lastPingedTime), - 0 === expirationTime || expirationTime >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - expirationTime = getNextRootExpirationTimeToWorkOn(root); - if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; - break; + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) { + var index$4 = 31 - clz32(lanes); + prevDispatcher = 1 << index$4; + index$4 = exitStatus[index$4]; + index$4 > prevExecutionContext && (prevExecutionContext = index$4); + lanes &= ~prevDispatcher; } - 1073741823 !== workInProgressRootLatestSuspenseTimeout - ? (expirationTime = - 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - - now()) - : 1073741823 === workInProgressRootLatestProcessedExpirationTime - ? (expirationTime = 0) - : ((expirationTime = - 10 * - (1073741821 - workInProgressRootLatestProcessedExpirationTime) - - 5e3), - (exitStatus = now()), - (lastExpiredTime = - 10 * (1073741821 - lastExpiredTime) - exitStatus), - (expirationTime = exitStatus - expirationTime), - 0 > expirationTime && (expirationTime = 0), - (expirationTime = - (120 > expirationTime - ? 120 - : 480 > expirationTime - ? 480 - : 1080 > expirationTime - ? 1080 - : 1920 > expirationTime - ? 1920 - : 3e3 > expirationTime - ? 3e3 - : 4320 > expirationTime - ? 4320 - : 1960 * ceil(expirationTime / 1960)) - expirationTime), - lastExpiredTime < expirationTime && - (expirationTime = lastExpiredTime)); - if (10 < expirationTime) { + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - expirationTime + lanes ); break; } commitRoot(root); break; - case RootCompleted: - if ( - 1073741823 !== workInProgressRootLatestProcessedExpirationTime && - null !== workInProgressRootCanSuspendUsingConfig - ) { - prevDispatcher = workInProgressRootLatestProcessedExpirationTime; - var suspenseConfig = workInProgressRootCanSuspendUsingConfig; - expirationTime = suspenseConfig.busyMinDurationMs | 0; - 0 >= expirationTime - ? (expirationTime = 0) - : ((exitStatus = suspenseConfig.busyDelayMs | 0), - (prevDispatcher = - now() - - (10 * (1073741821 - prevDispatcher) - - (suspenseConfig.timeoutMs | 0 || 5e3))), - (expirationTime = - prevDispatcher <= exitStatus - ? 0 - : exitStatus + expirationTime - prevDispatcher)); - if (10 < expirationTime) { - markRootSuspendedAtTime(root, lastExpiredTime); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - expirationTime - ); - break; - } - } + case 5: commitRoot(root); break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root); - return root.callbackNode === didTimeout + ensureRootIsScheduled(root, now()); + return root.callbackNode === originalCallbackNode ? performConcurrentWorkOnRoot.bind(null, root) : null; } +function markRootSuspended$1(root, suspendedLanes) { + suspendedLanes &= ~workInProgressRootPingedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; + for (root = root.expirationTimes; 0 < suspendedLanes; ) { + var index$9 = 31 - clz32(suspendedLanes), + lane = 1 << index$9; + root[index$9] = -1; + suspendedLanes &= ~lane; + } +} function performSyncWorkOnRoot(root) { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lastExpiredTime = root.lastExpiredTime; - lastExpiredTime = - 0 !== lastExpiredTime - ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime - ? renderExpirationTime$1 - : lastExpiredTime - : 1073741823; - var exitStatus = renderRootSync(root, lastExpiredTime); + if ( + root === workInProgressRoot && + 0 !== (root.expiredLanes & workInProgressRootRenderLanes) + ) { + var lanes = workInProgressRootRenderLanes; + var exitStatus = renderRootSync(root, lanes); + 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && + ((lanes = getNextLanes(root, lanes)), + (exitStatus = renderRootSync(root, lanes))); + } else + (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); 0 !== root.tag && - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), exitStatus); root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + root.finishedLanes = lanes; commitRoot(root); - ensureRootIsScheduled(root); + ensureRootIsScheduled(root, now()); return null; } -function prepareFreshStack(root, expirationTime) { +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} +function popRenderLanes() { + subtreeRenderLanes = subtreeRenderLanesCursor.current; + pop(subtreeRenderLanesCursor); +} +function prepareFreshStack(root, lanes) { root.finishedWork = null; - root.finishedExpirationTime = 0; + root.finishedLanes = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -5763,6 +5991,7 @@ function prepareFreshStack(root, expirationTime) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); + resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -5778,25 +6007,27 @@ function prepareFreshStack(root, expirationTime) { break; case 10: popProvider(interruptedWork); + break; + case 23: + case 24: + popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - renderExpirationTime$1 = expirationTime; - workInProgressRootExitStatus = RootIncomplete; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; - workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootNextUnprocessedUpdateTime = 0; - workInProgressRootHasPendingPing = !1; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; } function handleError(root$jscomp$0, thrownValue) { do { + var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) { for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -5806,49 +6037,52 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - renderExpirationTime = 0; + didScheduleRenderPhaseUpdate = !1; + } + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdate = !1; - if (null === workInProgress || null === workInProgress.return) - return ( - (workInProgressRootExitStatus = RootFatalErrored), - (workInProgressRootFatalError = thrownValue), - (workInProgress = null) - ); + didScheduleRenderPhaseUpdateDuringThisPass = !1; + ReactCurrentOwner$2.current = null; + if (null === erroredWork || null === erroredWork.return) { + workInProgressRootExitStatus = 1; + workInProgressRootFatalError = thrownValue; + workInProgress = null; + break; + } a: { var root = root$jscomp$0, - returnFiber = workInProgress.return, - sourceFiber = workInProgress, + returnFiber = erroredWork.return, + sourceFiber = erroredWork, value = thrownValue; - thrownValue = renderExpirationTime$1; - sourceFiber.effectTag |= 2048; + thrownValue = workInProgressRootRenderLanes; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var thenable = value; + var wakeable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.expirationTime = currentSource.expirationTime)) + (sourceFiber.lanes = currentSource.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - _workInProgress = returnFiber; + workInProgress$76 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === _workInProgress.tag)) { - var nextState = _workInProgress.memoizedState; + if ((JSCompiler_temp = 13 === workInProgress$76.tag)) { + var nextState = workInProgress$76.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = _workInProgress.memoizedProps; + var props = workInProgress$76.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -5860,23 +6094,24 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var thenables = _workInProgress.updateQueue; - if (null === thenables) { + var wakeables = workInProgress$76.updateQueue; + if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(thenable); - _workInProgress.updateQueue = updateQueue; - } else thenables.add(thenable); - if (0 === (_workInProgress.mode & 2)) { - _workInProgress.effectTag |= 64; - sourceFiber.effectTag &= -2981; + updateQueue.add(wakeable); + workInProgress$76.updateQueue = updateQueue; + } else wakeables.add(wakeable); + if (0 === (workInProgress$76.mode & 2)) { + workInProgress$76.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(1073741823, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.expirationTime = 1073741823; + sourceFiber.lanes |= 1; break a; } value = void 0; @@ -5885,108 +6120,98 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(thenable, value)) - : ((value = pingCache.get(thenable)), + pingCache.set(wakeable, value)) + : ((value = pingCache.get(wakeable)), void 0 === value && - ((value = new Set()), pingCache.set(thenable, value))); + ((value = new Set()), pingCache.set(wakeable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - thenable, + wakeable, sourceFiber ); - thenable.then(ping, ping); + wakeable.then(ping, ping); } - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; + workInProgress$76.flags |= 8192; + workInProgress$76.lanes = thrownValue; break a; } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$76 = workInProgress$76.return; + } while (null !== workInProgress$76); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); } - workInProgressRootExitStatus !== RootCompleted && - (workInProgressRootExitStatus = RootErrored); + 5 !== workInProgressRootExitStatus && + (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - _workInProgress = returnFiber; + workInProgress$76 = returnFiber; do { - switch (_workInProgress.tag) { + switch (workInProgress$76.tag) { case 3: - thenable = value; - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update = createRootErrorUpdate( - _workInProgress, - thenable, + root = value; + workInProgress$76.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$76.lanes |= thrownValue; + var update$77 = createRootErrorUpdate( + workInProgress$76, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update); + enqueueCapturedUpdate(workInProgress$76, update$77); break a; case 1: - thenable = value; - var ctor = _workInProgress.type, - instance = _workInProgress.stateNode; + root = value; + var ctor = workInProgress$76.type, + instance = workInProgress$76.stateNode; if ( - 0 === (_workInProgress.effectTag & 64) && + 0 === (workInProgress$76.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update2 = createClassErrorUpdate( - _workInProgress, - thenable, + workInProgress$76.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$76.lanes |= thrownValue; + var update$80 = createClassErrorUpdate( + workInProgress$76, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update2); + enqueueCapturedUpdate(workInProgress$76, update$80); break a; } } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$76 = workInProgress$76.return; + } while (null !== workInProgress$76); } - workInProgress = completeUnitOfWork(workInProgress); + completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; + workInProgress === erroredWork && + null !== erroredWork && + (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$2.current; + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } -function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { - expirationTime < workInProgressRootLatestProcessedExpirationTime && - 2 < expirationTime && - (workInProgressRootLatestProcessedExpirationTime = expirationTime); - null !== suspenseConfig && - expirationTime < workInProgressRootLatestSuspenseTimeout && - 2 < expirationTime && - ((workInProgressRootLatestSuspenseTimeout = expirationTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); -} -function markUnprocessedUpdateTime(expirationTime) { - expirationTime > workInProgressRootNextUnprocessedUpdateTime && - (workInProgressRootNextUnprocessedUpdateTime = expirationTime); -} -function renderRootSync(root, expirationTime) { +function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= RenderContext; + executionContext |= 16; var prevDispatcher = pushDispatcher(); - (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || - prepareFreshStack(root, expirationTime); + (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) || + prepareFreshStack(root, lanes); do try { workLoopSync(); @@ -5997,142 +6222,144 @@ function renderRootSync(root, expirationTime) { while (1); resetContextDependencies(); executionContext = prevExecutionContext; - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher$2.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; + workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) - workInProgress = performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) performUnitOfWork(workInProgress); } function workLoopConcurrent() { - for (; null !== workInProgress && !shouldYield(); ) - workInProgress = performUnitOfWork(workInProgress); + for (; null !== workInProgress && !Scheduler_shouldYield(); ) + performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { - var next = beginWork$1( - unitOfWork.alternate, - unitOfWork, - renderExpirationTime$1 - ); + var next = beginWork$1(unitOfWork.alternate, unitOfWork, subtreeRenderLanes); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === next && (next = completeUnitOfWork(unitOfWork)); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); ReactCurrentOwner$2.current = null; - return next; } function completeUnitOfWork(unitOfWork) { - workInProgress = unitOfWork; + var completedWork = unitOfWork; do { - var current = workInProgress.alternate; - unitOfWork = workInProgress.return; - if (0 === (workInProgress.effectTag & 2048)) { - current = completeWork(current, workInProgress, renderExpirationTime$1); + var current = completedWork.alternate; + unitOfWork = completedWork.return; + if (0 === (completedWork.flags & 4096)) { + current = completeWork(current, completedWork, subtreeRenderLanes); + if (null !== current) { + workInProgress = current; + return; + } + current = completedWork; if ( - 1 === renderExpirationTime$1 || - 1 !== workInProgress.childExpirationTime + (24 !== current.tag && 23 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) ) { - for ( - var newChildExpirationTime = 0, _child = workInProgress.child; - null !== _child; - - ) { - var _childUpdateExpirationTime = _child.expirationTime, - _childChildExpirationTime = _child.childExpirationTime; - _childUpdateExpirationTime > newChildExpirationTime && - (newChildExpirationTime = _childUpdateExpirationTime); - _childChildExpirationTime > newChildExpirationTime && - (newChildExpirationTime = _childChildExpirationTime); - _child = _child.sibling; - } - workInProgress.childExpirationTime = newChildExpirationTime; + for (var newChildLanes = 0, child = current.child; null !== child; ) + (newChildLanes |= child.lanes | child.childLanes), + (child = child.sibling); + current.childLanes = newChildLanes; } - if (null !== current) return current; null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = workInProgress.firstEffect), - null !== workInProgress.lastEffect && + (unitOfWork.firstEffect = completedWork.firstEffect), + null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), - (unitOfWork.lastEffect = workInProgress.lastEffect)), - 1 < workInProgress.effectTag && + (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), + (unitOfWork.lastEffect = completedWork.lastEffect)), + 1 < completedWork.flags && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = workInProgress) - : (unitOfWork.firstEffect = workInProgress), - (unitOfWork.lastEffect = workInProgress))); + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { - current = unwindWork(workInProgress); - if (null !== current) return (current.effectTag &= 2047), current; + current = unwindWork(completedWork); + if (null !== current) { + current.flags &= 4095; + workInProgress = current; + return; + } null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } - current = workInProgress.sibling; - if (null !== current) return current; - workInProgress = unitOfWork; - } while (null !== workInProgress); - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootCompleted); - return null; -} -function getRemainingExpirationTime(fiber) { - var updateExpirationTime = fiber.expirationTime; - fiber = fiber.childExpirationTime; - return updateExpirationTime > fiber ? updateExpirationTime : fiber; + completedWork = completedWork.sibling; + if (null !== completedWork) { + workInProgress = completedWork; + return; + } + workInProgress = completedWork = unitOfWork; + } while (null !== completedWork); + 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { +function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - var finishedWork = root$jscomp$1.finishedWork, - expirationTime = root$jscomp$1.finishedExpirationTime; + var finishedWork = root.finishedWork; if (null === finishedWork) return null; - root$jscomp$1.finishedWork = null; - root$jscomp$1.finishedExpirationTime = 0; - if (finishedWork === root$jscomp$1.current) + root.finishedWork = null; + root.finishedLanes = 0; + if (finishedWork === root.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root$jscomp$1.callbackNode = null; - root$jscomp$1.callbackExpirationTime = 0; - root$jscomp$1.callbackPriority = 90; - root$jscomp$1.nextKnownPendingLevel = 0; - var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( - finishedWork - ); - root$jscomp$1.firstPendingTime = remainingExpirationTimeBeforeCommit; - expirationTime <= root$jscomp$1.lastSuspendedTime - ? (root$jscomp$1.firstSuspendedTime = root$jscomp$1.lastSuspendedTime = root$jscomp$1.nextKnownPendingLevel = 0) - : expirationTime <= root$jscomp$1.firstSuspendedTime && - (root$jscomp$1.firstSuspendedTime = expirationTime - 1); - expirationTime <= root$jscomp$1.lastPingedTime && - (root$jscomp$1.lastPingedTime = 0); - expirationTime <= root$jscomp$1.lastExpiredTime && - (root$jscomp$1.lastExpiredTime = 0); - root$jscomp$1 === workInProgressRoot && + root.callbackNode = null; + var remainingLanes = finishedWork.lanes | finishedWork.childLanes, + remainingLanes$jscomp$0 = remainingLanes, + noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; + root.pendingLanes = remainingLanes$jscomp$0; + root.suspendedLanes = 0; + root.pingedLanes = 0; + root.expiredLanes &= remainingLanes$jscomp$0; + root.mutableReadLanes &= remainingLanes$jscomp$0; + root.entangledLanes &= remainingLanes$jscomp$0; + remainingLanes$jscomp$0 = root.entanglements; + for ( + var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; + 0 < noLongerPendingLanes; + + ) { + var index$10 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$10; + remainingLanes$jscomp$0[index$10] = 0; + eventTimes[index$10] = -1; + expirationTimes[index$10] = -1; + noLongerPendingLanes &= ~lane; + } + null !== rootsWithPendingDiscreteUpdates && + 0 === (remainingLanes & 24) && + rootsWithPendingDiscreteUpdates.has(root) && + rootsWithPendingDiscreteUpdates.delete(root); + root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (renderExpirationTime$1 = 0)); - 1 < finishedWork.effectTag + (workInProgressRootRenderLanes = 0)); + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (remainingExpirationTimeBeforeCommit = finishedWork) - : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); - if (null !== remainingExpirationTimeBeforeCommit) { - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - ReactCurrentOwner$2.current = null; - nextEffect = remainingExpirationTimeBeforeCommit; + (remainingLanes = finishedWork.firstEffect)) + : (remainingLanes = finishedWork) + : (remainingLanes = finishedWork.firstEffect); + if (null !== remainingLanes) { + remainingLanes$jscomp$0 = executionContext; + executionContext |= 32; + focusedInstanceHandle = ReactCurrentOwner$2.current = null; + shouldFireAfterActiveInstanceBlur = !1; + nextEffect = remainingLanes; do try { commitBeforeMutationEffects(); @@ -6142,17 +6369,13 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - nextEffect = remainingExpirationTimeBeforeCommit; + focusedInstanceHandle = null; + nextEffect = remainingLanes; do try { - for ( - var root = root$jscomp$1, - renderPriorityLevel = renderPriorityLevel$jscomp$1; - null !== nextEffect; - - ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + for (; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6162,82 +6385,139 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: commitWork(nextEffect.alternate, nextEffect); break; case 8: - var current$jscomp$0 = nextEffect; - a: for ( - var finishedRoot = root, - root$jscomp$0 = current$jscomp$0, - renderPriorityLevel$jscomp$0 = renderPriorityLevel, - node = root$jscomp$0; - ; - - ) + eventTimes = nextEffect; + a: for (noLongerPendingLanes = expirationTimes = eventTimes; ; ) { + index$10 = noLongerPendingLanes; if ( - (commitUnmount( - finishedRoot, - node, - renderPriorityLevel$jscomp$0 - ), - null !== node.child) + injectedHook && + "function" === typeof injectedHook.onCommitFiberUnmount ) - (node.child.return = node), (node = node.child); + try { + injectedHook.onCommitFiberUnmount(rendererID, index$10); + } catch (err) {} + switch (index$10.tag) { + case 0: + case 11: + case 14: + case 15: + case 22: + var updateQueue = index$10.updateQueue; + if (null !== updateQueue) { + var lastEffect = updateQueue.lastEffect; + if (null !== lastEffect) { + var firstEffect = lastEffect.next; + lane = firstEffect; + do { + var _effect2 = lane, + destroy = _effect2.destroy, + tag = _effect2.tag; + if (void 0 !== destroy) + if (0 !== (tag & 4)) + enqueuePendingPassiveHookEffectUnmount( + index$10, + lane + ); + else { + _effect2 = index$10; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(_effect2, error); + } + } + lane = lane.next; + } while (lane !== firstEffect); + } + } + break; + case 1: + safelyDetachRef(index$10); + var instance = index$10.stateNode; + if ("function" === typeof instance.componentWillUnmount) + try { + (lane = index$10), + (_effect2 = instance), + (_effect2.props = lane.memoizedProps), + (_effect2.state = lane.memoizedState), + _effect2.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(index$10, unmountError); + } + break; + case 5: + safelyDetachRef(index$10); + break; + case 4: + createChildNodeSet(index$10.stateNode.containerInfo); + } + if (null !== noLongerPendingLanes.child) + (noLongerPendingLanes.child.return = noLongerPendingLanes), + (noLongerPendingLanes = noLongerPendingLanes.child); else { - if (node === root$jscomp$0) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === root$jscomp$0) + if (noLongerPendingLanes === expirationTimes) break; + for (; null === noLongerPendingLanes.sibling; ) { + if ( + null === noLongerPendingLanes.return || + noLongerPendingLanes.return === expirationTimes + ) break a; - node = node.return; + noLongerPendingLanes = noLongerPendingLanes.return; } - node.sibling.return = node.return; - node = node.sibling; + noLongerPendingLanes.sibling.return = + noLongerPendingLanes.return; + noLongerPendingLanes = noLongerPendingLanes.sibling; } - detachFiber(current$jscomp$0); + } + var alternate = eventTimes.alternate; + detachFiberMutation(eventTimes); + null !== alternate && detachFiberMutation(alternate); } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$87) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$87); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root$jscomp$1.current = finishedWork; - nextEffect = remainingExpirationTimeBeforeCommit; + root.current = finishedWork; + nextEffect = remainingLanes; do try { - for (effectTag = root$jscomp$1; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance = nextEffect.stateNode; + var instance$jscomp$0 = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current = instance.canonical; + current = instance$jscomp$0.canonical; break; default: - current = instance; + current = instance$jscomp$0; } "function" === typeof ref ? ref(current) @@ -6246,55 +6526,71 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$88) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$88); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - executionContext = prevExecutionContext; - } else root$jscomp$1.current = finishedWork; + executionContext = remainingLanes$jscomp$0; + } else root.current = finishedWork; if (rootDoesHavePassiveEffects) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root$jscomp$1), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$1); + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel); else - for ( - nextEffect = remainingExpirationTimeBeforeCommit; - null !== nextEffect; - - ) - (renderPriorityLevel$jscomp$1 = nextEffect.nextEffect), + for (nextEffect = remainingLanes; null !== nextEffect; ) + (renderPriorityLevel = nextEffect.nextEffect), (nextEffect.nextEffect = null), - (nextEffect = renderPriorityLevel$jscomp$1); - renderPriorityLevel$jscomp$1 = root$jscomp$1.firstPendingTime; - 0 === renderPriorityLevel$jscomp$1 && - (legacyErrorBoundariesThatAlreadyFailed = null); - 1073741823 === renderPriorityLevel$jscomp$1 - ? root$jscomp$1 === rootWithNestedUpdates + nextEffect.flags & 8 && + ((flags$jscomp$0 = nextEffect), + (flags$jscomp$0.sibling = null), + (flags$jscomp$0.stateNode = null)), + (nextEffect = renderPriorityLevel); + remainingLanes = root.pendingLanes; + 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); + 1 === remainingLanes + ? root === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$1)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode, expirationTime); - ensureRootIsScheduled(root$jscomp$1); + finishedWork = finishedWork.stateNode; + if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) + try { + injectedHook.onCommitFiberRoot( + rendererID, + finishedWork, + void 0, + 64 === (finishedWork.current.flags & 64) + ); + } catch (err) {} + ensureRootIsScheduled(root, now()); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root$jscomp$1 = firstUncaughtError), + (root = firstUncaughtError), (firstUncaughtError = null), - root$jscomp$1); - if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; + root); + if (0 !== (executionContext & 8)) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); - 0 === (effectTag & 512) || + var current = nextEffect.alternate; + shouldFireAfterActiveInstanceBlur || + null === focusedInstanceHandle || + (0 !== (nextEffect.flags & 8) + ? doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0) + : 13 === nextEffect.tag && + isSuspenseBoundaryBeingHidden(current, nextEffect) && + doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0)); + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -6313,45 +6609,81 @@ function flushPassiveEffects() { pendingPassiveEffectsRenderPriority = 90; return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } + return !1; +} +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= CommitContext; - for (root = root.current.firstEffect; null !== root; ) { + executionContext |= 32; + var unmountEffects = pendingPassiveHookEffectsUnmount; + pendingPassiveHookEffectsUnmount = []; + for (var i = 0; i < unmountEffects.length; i += 2) { + var effect$93 = unmountEffects[i], + fiber = unmountEffects[i + 1], + destroy = effect$93.destroy; + effect$93.destroy = void 0; + if ("function" === typeof destroy) + try { + destroy(); + } catch (error) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error); + } + } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$93 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; try { - var finishedWork = root; - if (0 !== (finishedWork.effectTag & 512)) - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - case 22: - commitHookEffectListUnmount(5, finishedWork), - commitHookEffectListMount(5, finishedWork); - } - } catch (error) { - if (null === root) throw Error("Should be working on an effect."); - captureCommitPhaseError(root, error); + var create$97 = effect$93.create; + effect$93.destroy = create$97(); + } catch (error$98) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error$98); } - finishedWork = root.nextEffect; - root.nextEffect = null; - root = finishedWork; } + for (create$97 = root.current.firstEffect; null !== create$97; ) + (root = create$97.nextEffect), + (create$97.nextEffect = null), + create$97.flags & 8 && + ((create$97.sibling = null), (create$97.stateNode = null)), + (create$97 = root); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); enqueueUpdate(rootFiber, sourceFiber); - rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); - null !== rootFiber && ensureRootIsScheduled(rootFiber); + sourceFiber = requestEventTime(); + rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); + null !== rootFiber && + (markRootUpdated(rootFiber, 1, sourceFiber), + ensureRootIsScheduled(rootFiber, sourceFiber)); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -6370,145 +6702,166 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); - null !== fiber && ensureRootIsScheduled(fiber); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); + fiber = markUpdateLaneFromFiberToRoot(fiber, 1); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, thenable, suspendedTime) { +function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - workInProgressRoot === root && renderExpirationTime$1 === suspendedTime - ? workInProgressRootExitStatus === RootSuspendedWithDelay || - (workInProgressRootExitStatus === RootSuspended && - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) - ? prepareFreshStack(root, renderExpirationTime$1) - : (workInProgressRootHasPendingPing = !0) - : isRootSuspendedAtTime(root, suspendedTime) && - ((thenable = root.lastPingedTime), - (0 !== thenable && thenable < suspendedTime) || - ((root.lastPingedTime = suspendedTime), ensureRootIsScheduled(root))); -} -function resolveRetryThenable(boundaryFiber, thenable) { + null !== pingCache && pingCache.delete(wakeable); + wakeable = requestEventTime(); + root.pingedLanes |= root.suspendedLanes & pingedLanes; + workInProgressRoot === root && + (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && + (4 === workInProgressRootExitStatus || + (3 === workInProgressRootExitStatus && + (workInProgressRootRenderLanes & 62914560) === + workInProgressRootRenderLanes && + 500 > now() - globalMostRecentFallbackTime) + ? prepareFreshStack(root, 0) + : (workInProgressRootPingedLanes |= pingedLanes)); + ensureRootIsScheduled(root, wakeable); +} +function resolveRetryWakeable(boundaryFiber, wakeable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(thenable); - thenable = 0; - 0 === thenable && - ((thenable = requestCurrentTimeForUpdate()), - (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); - boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); - null !== boundaryFiber && ensureRootIsScheduled(boundaryFiber); + null !== retryCache && retryCache.delete(wakeable); + wakeable = 0; + 0 === wakeable && + ((wakeable = boundaryFiber.mode), + 0 === (wakeable & 2) + ? (wakeable = 1) + : 0 === (wakeable & 4) + ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); + retryCache = requestEventTime(); + boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); + null !== boundaryFiber && + (markRootUpdated(boundaryFiber, wakeable, retryCache), + ensureRootIsScheduled(boundaryFiber, retryCache)); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; +beginWork$1 = function(current, workInProgress, renderLanes) { + var updateLanes = workInProgress.lanes; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (updateExpirationTime < renderExpirationTime) { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case 10: + updateLanes = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue2); + context._currentValue2 = updateLanes; + break; + case 13: + if (null !== workInProgress.memoizedState) { + if (0 !== (renderLanes & workInProgress.child.childLanes)) + return updateSuspenseComponent( + current, + workInProgress, + renderLanes + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( + current, workInProgress, - workInProgress.stateNode.containerInfo + renderLanes ); - break; - case 10: - updateExpirationTime = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue2); - context._currentValue2 = updateExpirationTime; - break; - case 13: - if (null !== workInProgress.memoizedState) { - updateExpirationTime = workInProgress.child.childExpirationTime; - if ( - 0 !== updateExpirationTime && - updateExpirationTime >= renderExpirationTime - ) - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateLanes = 0 !== (renderLanes & workInProgress.childLanes); + if (0 !== (current.flags & 64)) { + if (updateLanes) + return updateSuspenseListComponent( current, workInProgress, - renderExpirationTime + renderLanes ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateExpirationTime = - workInProgress.childExpirationTime >= renderExpirationTime; - if (0 !== (current.effectTag & 64)) { - if (updateExpirationTime) - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), (context.tail = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (!updateExpirationTime) return null; - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + workInProgress.flags |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), + (context.tail = null), + (context.lastEffect = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (updateLanes) break; + else return null; + case 23: + case 24: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; - workInProgress.expirationTime = 0; + workInProgress.lanes = 0; switch (workInProgress.tag) { case 2: - updateExpirationTime = workInProgress.type; + updateLanes = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); context = renderWithHooks( null, workInProgress, - updateExpirationTime, + updateLanes, current, context, - renderExpirationTime + renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -6518,7 +6871,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateExpirationTime)) { + if (isContextProvider(updateLanes)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -6527,53 +6880,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = - updateExpirationTime.getDerivedStateFromProps; + var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateExpirationTime, + updateLanes, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternalFiber = workInProgress; - mountClassInstance( - workInProgress, - updateExpirationTime, - current, - renderExpirationTime - ); + context._reactInternals = workInProgress; + mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, hasContext, - renderExpirationTime + renderLanes ); } else (workInProgress.tag = 0), - reconcileChildren( - null, - workInProgress, - context, - renderExpirationTime - ), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: + context = workInProgress.elementType; a: { - context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - initializeLazyComponentType(context); - if (1 !== context._status) throw context._result; - context = context._result; + hasContext = context._init; + context = hasContext(context._payload); workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -6584,7 +6925,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 1: @@ -6593,7 +6934,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 11: @@ -6602,7 +6943,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 14: @@ -6611,8 +6952,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, resolveDefaultProps(context.type, current), - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); break a; } @@ -6625,126 +6966,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return workInProgress; case 0: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 1: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 3: pushHostRootContext(workInProgress); - updateExpirationTime = workInProgress.updateQueue; - if (null === current || null === updateExpirationTime) + updateLanes = workInProgress.updateQueue; + if (null === current || null === updateLanes) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); - updateExpirationTime = workInProgress.pendingProps; + updateLanes = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue( - workInProgress, - updateExpirationTime, - null, - renderExpirationTime - ); - updateExpirationTime = workInProgress.memoizedState.element; - updateExpirationTime === context + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes )) - : (reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (updateLanes = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child), - workInProgress + reconcileChildren(current, workInProgress, updateLanes, renderLanes), + workInProgress.child ); case 6: return null; case 13: - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseComponent(current, workInProgress, renderLanes); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (updateLanes = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes )) : reconcileChildren( current, workInProgress, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ), workInProgress.child ); case 11: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 7: @@ -6753,7 +7074,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps, - renderExpirationTime + renderLanes ), workInProgress.child ); @@ -6763,7 +7084,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); @@ -6773,13 +7094,13 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); case 10: a: { - updateExpirationTime = workInProgress.type._context; + updateLanes = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -6791,9 +7112,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( context$jscomp$0, hasContext ) @@ -6807,7 +7127,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); break a; } @@ -6828,25 +7148,24 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ) { if ( - dependency.context === updateExpirationTime && + dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate(renderExpirationTime, null)), + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.expirationTime < renderExpirationTime && - (context$jscomp$0.expirationTime = renderExpirationTime); + context$jscomp$0.lanes |= renderLanes; dependency = context$jscomp$0.alternate; - null !== dependency && - dependency.expirationTime < renderExpirationTime && - (dependency.expirationTime = renderExpirationTime); + null !== dependency && (dependency.lanes |= renderLanes); scheduleWorkOnParentPath( context$jscomp$0.return, - renderExpirationTime + renderLanes ); - list.expirationTime < renderExpirationTime && - (list.expirationTime = renderExpirationTime); + list.lanes |= renderLanes; break; } dependency = dependency.next; @@ -6884,7 +7203,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, context.children, - renderExpirationTime + renderLanes ); workInProgress = workInProgress.child; } @@ -6893,17 +7212,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateExpirationTime = hasContext.children), - prepareToReadContext(workInProgress, renderExpirationTime), + (updateLanes = hasContext.children), + prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(context)), - (workInProgress.effectTag |= 1), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + (updateLanes = updateLanes(context)), + (workInProgress.flags |= 1), + reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: @@ -6919,8 +7233,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, hasContext, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); case 15: @@ -6929,48 +7243,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); case 17: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), - isContextProvider(updateExpirationTime) + isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderExpirationTime), - constructClassInstance(workInProgress, updateExpirationTime, context), - mountClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), + prepareToReadContext(workInProgress, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, current, - renderExpirationTime + renderLanes ) ); case 19: - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseListComponent(current, workInProgress, renderLanes); + case 23: + return updateOffscreenComponent(current, workInProgress, renderLanes); + case 24: + return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( "Unknown unit of work tag (" + @@ -6978,32 +7287,6 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { "). This error is likely caused by a bug in React. Please file an issue." ); }; -var onCommitFiberRoot = null, - onCommitFiberUnmount = null; -function injectInternals(internals) { - if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (hook.isDisabled || !hook.supportsFiber) return !0; - try { - var rendererID = hook.inject(internals); - onCommitFiberRoot = function(root) { - try { - hook.onCommitFiberRoot( - rendererID, - root, - void 0, - 64 === (root.current.effectTag & 64) - ); - } catch (err) {} - }; - onCommitFiberUnmount = function(fiber) { - try { - hook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) {} - }; - } catch (err) {} - return !0; -} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7013,11 +7296,14 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childExpirationTime = this.expirationTime = 0; + this.childLanes = this.lanes = 0; this.alternate = null; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); @@ -7035,7 +7321,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, @@ -7047,12 +7333,13 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.effectTag = 0), + (workInProgress.type = current.type), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7061,11 +7348,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.dependencies = null === pendingProps ? null - : { - expirationTime: pendingProps.expirationTime, - firstContext: pendingProps.firstContext, - responders: pendingProps.responders - }; + : { lanes: pendingProps.lanes, firstContext: pendingProps.firstContext }; workInProgress.sibling = current.sibling; workInProgress.index = current.index; workInProgress.ref = current.ref; @@ -7077,7 +7360,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - expirationTime + lanes ) { var fiberTag = 2; owner = type; @@ -7086,15 +7369,10 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment( - pendingProps.children, - mode, - expirationTime, - key - ); - case REACT_CONCURRENT_MODE_TYPE: + return createFiberFromFragment(pendingProps.children, mode, lanes, key); + case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 7; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7102,25 +7380,34 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(12, pendingProps, key, mode | 8)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), type ); case REACT_SUSPENSE_TYPE: return ( - (type = new FiberNode(13, pendingProps, key, mode)), + (type = createFiber(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = new FiberNode(19, pendingProps, key, mode)), + (type = createFiber(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), + type + ); + case REACT_OFFSCREEN_TYPE: + return createFiberFromOffscreen(pendingProps, mode, lanes, key); + case REACT_LEGACY_HIDDEN_TYPE: + return ( + (type = createFiber(24, pendingProps, key, mode)), + (type.elementType = REACT_LEGACY_HIDDEN_TYPE), + (type.lanes = lanes), type ); default: @@ -7152,30 +7439,36 @@ function createFiberFromTypeAndProps( "." ); } - key = new FiberNode(fiberTag, pendingProps, key, mode); + key = createFiber(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.expirationTime = expirationTime; + key.lanes = lanes; return key; } -function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(7, elements, key, mode); - elements.expirationTime = expirationTime; +function createFiberFromFragment(elements, mode, lanes, key) { + elements = createFiber(7, elements, key, mode); + elements.lanes = lanes; return elements; } -function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); - content.expirationTime = expirationTime; +function createFiberFromOffscreen(pendingProps, mode, lanes, key) { + pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps.elementType = REACT_OFFSCREEN_TYPE; + pendingProps.lanes = lanes; + return pendingProps; +} +function createFiberFromText(content, mode, lanes) { + content = createFiber(6, content, null, mode); + content.lanes = lanes; return content; } -function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( +function createFiberFromPortal(portal, mode, lanes) { + mode = createFiber( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.expirationTime = expirationTime; + mode.lanes = lanes; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -7185,51 +7478,31 @@ function createFiberFromPortal(portal, mode, expirationTime) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; - this.current = null; this.containerInfo = containerInfo; - this.pingCache = this.pendingChildren = null; - this.finishedExpirationTime = 0; - this.finishedWork = null; + this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 90; - this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; -} -function isRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - root = root.lastSuspendedTime; - return ( - 0 !== firstSuspendedTime && - firstSuspendedTime >= expirationTime && - root <= expirationTime - ); + this.callbackPriority = 0; + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); + this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; + this.entanglements = createLaneMap(0); } -function markRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime, - lastSuspendedTime = root.lastSuspendedTime; - firstSuspendedTime < expirationTime && - (root.firstSuspendedTime = expirationTime); - if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) - root.lastSuspendedTime = expirationTime; - expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); - expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); -} -function markRootUpdatedAtTime(root, expirationTime) { - expirationTime > root.firstPendingTime && - (root.firstPendingTime = expirationTime); - var firstSuspendedTime = root.firstSuspendedTime; - 0 !== firstSuspendedTime && - (expirationTime >= firstSuspendedTime - ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) - : expirationTime >= root.lastSuspendedTime && - (root.lastSuspendedTime = expirationTime + 1), - expirationTime > root.nextKnownPendingLevel && - (root.nextKnownPendingLevel = expirationTime)); +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findHostInstance(component) { - var fiber = component._reactInternalFiber; + var fiber = component._reactInternals; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -7243,11 +7516,10 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); + eventTime = requestEventTime(), + lane = requestUpdateLane(current); a: if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; + parentComponent = parentComponent._reactInternals; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -7256,22 +7528,23 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var parentContext = parentComponent; + var JSCompiler_inline_result = parentComponent; do { - switch (parentContext.tag) { + switch (JSCompiler_inline_result.tag) { case 3: - parentContext = parentContext.stateNode.context; + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode.context; break b; case 1: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode + if (isContextProvider(JSCompiler_inline_result.type)) { + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - parentContext = parentContext.return; - } while (null !== parentContext); + JSCompiler_inline_result = JSCompiler_inline_result.return; + } while (null !== JSCompiler_inline_result); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -7282,34 +7555,26 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - parentContext + JSCompiler_inline_result ); break a; } } - parentComponent = parentContext; + parentComponent = JSCompiler_inline_result; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(currentTime, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleWork(current, currentTime); - return currentTime; + scheduleUpdateOnFiber(current, lane, eventTime); + return lane; } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function emptyFindFiberByHostInstance() { + return null; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7331,53 +7596,70 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - executionContext === NoContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; -var roots = new Map(); -(function(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals({ - bundleType: devToolsConfig.bundleType, - version: devToolsConfig.version, - rendererPackageName: devToolsConfig.rendererPackageName, - rendererConfig: devToolsConfig.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; - }, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null - }); -})({ - findFiberByHostInstance: getInstanceFromInstance, - bundleType: 0, - version: "16.13.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } -}); +var roots = new Map(), + devToolsConfig$jscomp$inline_865 = { + findFiberByHostInstance: getInstanceFromInstance, + bundleType: 0, + version: "17.0.1-4e5d7faf5", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } + }; +var internals$jscomp$inline_1054 = { + bundleType: devToolsConfig$jscomp$inline_865.bundleType, + version: devToolsConfig$jscomp$inline_865.version, + rendererPackageName: devToolsConfig$jscomp$inline_865.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_865.rendererConfig, + overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, + overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: + devToolsConfig$jscomp$inline_865.findFiberByHostInstance || + emptyFindFiberByHostInstance, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null +}; +if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { + var hook$jscomp$inline_1055 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if ( + !hook$jscomp$inline_1055.isDisabled && + hook$jscomp$inline_1055.supportsFiber + ) + try { + (rendererID = hook$jscomp$inline_1055.inject( + internals$jscomp$inline_1054 + )), + (injectedHook = hook$jscomp$inline_1055); + } catch (err) {} +} exports.createPortal = function(children, containerTag) { return createPortal( children, @@ -7417,7 +7699,7 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var uninitializedFiber = new FiberNode(3, null, null, 0); + var uninitializedFiber = createFiber(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; initializeUpdateQueue(uninitializedFiber); diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 2529b47e0b91d4..7f8d5d62270acd 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -920,7 +920,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_229 = { +var injectedNamesToPlugins$jscomp$inline_223 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -955,34 +955,34 @@ var injectedNamesToPlugins$jscomp$inline_229 = { } } }, - isOrderingDirty$jscomp$inline_230 = !1, - pluginName$jscomp$inline_231; -for (pluginName$jscomp$inline_231 in injectedNamesToPlugins$jscomp$inline_229) + isOrderingDirty$jscomp$inline_224 = !1, + pluginName$jscomp$inline_225; +for (pluginName$jscomp$inline_225 in injectedNamesToPlugins$jscomp$inline_223) if ( - injectedNamesToPlugins$jscomp$inline_229.hasOwnProperty( - pluginName$jscomp$inline_231 + injectedNamesToPlugins$jscomp$inline_223.hasOwnProperty( + pluginName$jscomp$inline_225 ) ) { - var pluginModule$jscomp$inline_232 = - injectedNamesToPlugins$jscomp$inline_229[pluginName$jscomp$inline_231]; + var pluginModule$jscomp$inline_226 = + injectedNamesToPlugins$jscomp$inline_223[pluginName$jscomp$inline_225]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_231) || - namesToPlugins[pluginName$jscomp$inline_231] !== - pluginModule$jscomp$inline_232 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_225) || + namesToPlugins[pluginName$jscomp$inline_225] !== + pluginModule$jscomp$inline_226 ) { - if (namesToPlugins[pluginName$jscomp$inline_231]) + if (namesToPlugins[pluginName$jscomp$inline_225]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_231 + + pluginName$jscomp$inline_225 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_231 - ] = pluginModule$jscomp$inline_232; - isOrderingDirty$jscomp$inline_230 = !0; + pluginName$jscomp$inline_225 + ] = pluginModule$jscomp$inline_226; + isOrderingDirty$jscomp$inline_224 = !0; } } -isOrderingDirty$jscomp$inline_230 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_224 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1103,7 +1103,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1713,7 +1713,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1753,31 +1753,27 @@ if ( null == tracing.__interactionsRef.current ) throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); Scheduler_now(); -var return_highestLanePriority = 10; +var return_highestLanePriority = 8; function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 6), inputDiscreteLanes; inputDiscreteLanes = 62914560 & lanes; @@ -1791,18 +1787,18 @@ function getHighestPriorityLanes(lanes) { return (return_highestLanePriority = 2), inputDiscreteLanes; if (0 !== (1073741824 & lanes)) return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; + return_highestLanePriority = 8; return lanes; } function schedulerPriorityToLanePriority(schedulerPriorityLevel) { switch (schedulerPriorityLevel) { case 99: - return 17; + return 15; case 98: - return 12; + return 10; case 97: case 96: - return 10; + return 8; case 95: return 2; default: @@ -1811,16 +1807,14 @@ function schedulerPriorityToLanePriority(schedulerPriorityLevel) { } function lanePriorityToSchedulerPriority(lanePriority) { switch (lanePriority) { - case 17: - case 16: - return 99; case 15: case 14: + return 99; case 13: case 12: - return 98; case 11: case 10: + return 98; case 9: case 8: case 7: @@ -1850,7 +1844,7 @@ function getNextLanes(root, wipLanes) { pingedLanes = root.pingedLanes; if (0 !== expiredLanes) (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); + (nextLanePriority = return_highestLanePriority = 15); else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; 0 !== nonIdleUnblockedLanes @@ -1889,42 +1883,31 @@ function getNextLanes(root, wipLanes) { (wipLanes &= ~nextLanePriority); return nextLanes; } -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$4 = 31 - clz32(lanes), - lane = 1 << index$4; - index$4 = root[index$4]; - index$4 > mostRecentEventTime && (mostRecentEventTime = index$4); - lanes &= ~lane; - } - return mostRecentEventTime; -} function getLanesToRetrySynchronouslyOnError(root) { root = root.pendingLanes & -1073741825; return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; } function findUpdateLane(lanePriority, wipLanes) { switch (lanePriority) { - case 17: + case 15: return 1; - case 16: - return 2; case 14: + return 2; + case 12: return ( (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority ); - case 12: + case 10: return ( (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority ); - case 10: + case 8: return ( (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), 0 === lanePriority && (lanePriority = 512)), lanePriority ); @@ -1942,8 +1925,9 @@ function findUpdateLane(lanePriority, wipLanes) { function getHighestPriorityLane(lanes) { return lanes & -lanes; } -function pickArbitraryLane(lanes) { - return lanes & -lanes; +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; } function markRootUpdated(root, updateLane, eventTime) { root.pendingLanes |= updateLane; @@ -1978,7 +1962,7 @@ if ( null == tracing.__interactionsRef.current ) throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); var fakeCallbackNode = {}, requestPaint = @@ -2067,30 +2051,7 @@ function flushSyncCallbackQueueImpl() { } } } -function describeFiber(fiber) { - switch (fiber.tag) { - case 5: - return describeComponentFrame(fiber.type, null, null); - case 16: - return describeComponentFrame("Lazy", null, null); - case 13: - return describeComponentFrame("Suspense", null, null); - case 19: - return describeComponentFrame("SuspenseList", null, null); - case 0: - case 2: - case 15: - return describeFunctionComponentFrame(fiber.type, null); - case 11: - return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); - case 1: - return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; - default: - return ""; - } -} +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -2116,6 +2077,30 @@ function shallowEqual(objA, objB) { return !1; return !0; } +function describeFiber(fiber) { + switch (fiber.tag) { + case 5: + return describeComponentFrame(fiber.type, null, null); + case 16: + return describeComponentFrame("Lazy", null, null); + case 13: + return describeComponentFrame("Suspense", null, null); + case 19: + return describeComponentFrame("SuspenseList", null, null); + case 0: + case 2: + case 15: + return describeFunctionComponentFrame(fiber.type, null); + case 11: + return describeFunctionComponentFrame(fiber.type.render, null); + case 22: + return describeFunctionComponentFrame(fiber.type._render, null); + case 1: + return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; + default: + return ""; + } +} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2209,11 +2194,10 @@ function cloneUpdateQueue(current, workInProgress) { effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(eventTime, lane) { return { eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, @@ -2246,7 +2230,6 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { var clone = { eventTime: queue.eventTime, lane: queue.lane, - suspenseConfig: queue.suspenseConfig, tag: queue.tag, payload: queue.payload, callback: queue.callback, @@ -2320,16 +2303,11 @@ function processUpdateQueue( (current = current.next = { eventTime: updateEventTime, lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, next: null }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); a: { var workInProgress = workInProgress$jscomp$0, update = firstBaseUpdate; @@ -2349,8 +2327,7 @@ function processUpdateQueue( currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; pendingQueue = @@ -2373,7 +2350,7 @@ function processUpdateQueue( } } null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), + ((workInProgress$jscomp$0.flags |= 32), (pendingQueue = queue.effects), null === pendingQueue ? (queue.effects = [firstBaseUpdate]) @@ -2382,7 +2359,6 @@ function processUpdateQueue( (updateEventTime = { eventTime: updateEventTime, lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, @@ -2434,8 +2410,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2461,41 +2436,32 @@ var classComponentUpdater = { enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); } }; @@ -2588,7 +2554,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2603,7 +2569,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2637,7 +2603,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2661,7 +2627,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2693,16 +2659,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -3236,12 +3202,14 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3301,7 +3269,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim$1() || shim$1())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3333,7 +3301,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3458,40 +3426,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3576,10 +3538,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), + (maybeNewVersion = requestUpdateLane(fiber)), (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); maybeNewVersion = root.mutableReadLanes; root.entangledLanes |= maybeNewVersion; @@ -3588,9 +3547,9 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { 0 < lanes; ) { - var index$12 = 31 - clz32(lanes), - lane = 1 << index$12; - entanglements[index$12] |= maybeNewVersion; + var index$11 = 31 - clz32(lanes), + lane = 1 << index$11; + entanglements[index$11] |= maybeNewVersion; lanes &= ~lane; } } @@ -3604,7 +3563,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { latestSetSnapshot = refs.setSnapshot; try { latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); + var lane = requestUpdateLane(fiber); root.mutableReadLanes |= lane & root.pendingLanes; } catch (error) { latestSetSnapshot(function() { @@ -3675,17 +3634,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3693,12 +3652,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3737,13 +3696,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3771,39 +3723,36 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); - suspenseConfig = { - eventTime: eventTime, - lane: lane, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3819,8 +3768,8 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { @@ -3848,7 +3797,13 @@ var ContextOnlyDispatcher = { }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3894,36 +3849,30 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; }, useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); @@ -3953,36 +3902,27 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -4004,36 +3944,27 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -4090,11 +4021,11 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } @@ -4131,7 +4062,7 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, renderLanes ); @@ -4148,7 +4079,7 @@ function updateMemoComponent( Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4168,7 +4099,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -4203,9 +4134,7 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { return ( (current = null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [1073741824]) - : spawnedWorkDuringRender.push(1073741824), + markSpawnedWork(1073741824), (workInProgress.lanes = workInProgress.childLanes = 1073741824), (workInProgress.memoizedState = { baseLanes: current }), pushRenderLanes(workInProgress, current), @@ -4226,7 +4155,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4251,11 +4180,11 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } @@ -4275,7 +4204,7 @@ function updateClassComponent( null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); @@ -4341,9 +4270,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -4351,7 +4280,7 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); } else { instance = workInProgress.stateNode; @@ -4424,17 +4353,17 @@ function updateClassComponent( oldContext )), "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4444,11 +4373,11 @@ function updateClassComponent( : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4469,7 +4398,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4484,7 +4413,7 @@ function finishClassComponent( var nextChildren = null; profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((didCaptureError = nextChildren), (workInProgress.child = reconcileChildFibers( @@ -4522,55 +4451,49 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { + current = nextProps.children; + suspenseContext = nextProps.fallback; if (showFallback) return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps), - workInProgress.mode & 8 && - ((showFallback.actualDuration = 0), - (showFallback.actualStartTime = -1), - (showFallback.selfBaseDuration = 0), - (showFallback.treeBaseDuration = 0))) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( + (current = mountSuspenseFallbackChildren( + workInProgress, current, suspenseContext, - renderLanes, - null + renderLanes )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), current ); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432), + current + ); renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, + { mode: "visible", children: current }, workInProgress.mode, renderLanes, null @@ -4588,13 +4511,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4616,13 +4539,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4635,6 +4558,41 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { workInProgress.memoizedState = null; return renderLanes; } +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren), + workInProgress.mode & 8 && + ((progressedPrimaryFragment.actualDuration = 0), + (progressedPrimaryFragment.actualStartTime = -1), + (progressedPrimaryFragment.selfBaseDuration = 0), + (progressedPrimaryFragment.treeBaseDuration = 0))) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; +} function updateSuspensePrimaryChildren( current, workInProgress, @@ -4652,7 +4610,7 @@ function updateSuspensePrimaryChildren( primaryChildren.sibling = null; null !== current && ((current.nextEffect = null), - (current.effectTag = 8), + (current.flags = 8), (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } @@ -4696,7 +4654,7 @@ function updateSuspenseFallbackChildren( renderLanes, null )), - (fallbackChildren.effectTag |= 2)); + (fallbackChildren.flags |= 2)); fallbackChildren.return = workInProgress; primaryChildren.return = workInProgress; primaryChildren.sibling = fallbackChildren; @@ -4725,7 +4683,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4734,7 +4691,6 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } @@ -4745,9 +4701,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4882,7 +4838,7 @@ appendAllChildren = function( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4935,7 +4891,7 @@ function appendAllChildrenToContainer( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4979,7 +4935,7 @@ updateHostContainer = function(workInProgress) { newChildSet = createChildNodeSet(container); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; - workInProgress.effectTag |= 4; + workInProgress.flags |= 4; completeRoot(container, newChildSet); } }; @@ -5017,7 +4973,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { }), (workInProgress.stateNode = type), current - ? (workInProgress.effectTag |= 4) + ? (workInProgress.flags |= 4) : appendAllChildren(type, workInProgress, !1, !1)); } }; @@ -5031,7 +4987,7 @@ updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText, workInProgress )), - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { @@ -5086,7 +5042,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -5104,8 +5060,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -5140,7 +5095,7 @@ function completeWork(current, workInProgress, renderLanes) { current = { node: rootContainerInstance, canonical: current }; appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -5169,7 +5124,7 @@ function completeWork(current, workInProgress, renderLanes) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) + if (0 !== (workInProgress.flags & 64)) return ( (workInProgress.lanes = renderLanes), 0 !== (workInProgress.mode & 8) && @@ -5202,7 +5157,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - newProps && (workInProgress.effectTag |= 4); + newProps && (workInProgress.flags |= 4); return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -5214,24 +5169,24 @@ function completeWork(current, workInProgress, renderLanes) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.effectTag & 64)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; @@ -5239,7 +5194,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (updatePayload = current), - (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), @@ -5287,6 +5242,13 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); } else { if (!rootContainerInstance) @@ -5294,12 +5256,12 @@ function completeWork(current, workInProgress, renderLanes) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -5312,15 +5274,14 @@ function completeWork(current, workInProgress, renderLanes) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [renderLanes]) - : spawnedWorkDuringRender.push(renderLanes)); + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5331,9 +5292,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -5356,7 +5315,7 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), null ); } @@ -5370,9 +5329,9 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) @@ -5382,21 +5341,21 @@ function unwindWork(workInProgress) { pop(didPerformWorkStackCursor); pop(contextStackCursor); resetWorkInProgressVersions(); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) @@ -5452,7 +5411,7 @@ function logCapturedError(boundary, errorInfo) { } var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; lane.payload = { element: null }; var error = errorInfo.value; @@ -5463,7 +5422,7 @@ function createRootErrorUpdate(fiber, errorInfo, lane) { return lane; } function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { @@ -5509,7 +5468,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -5570,7 +5529,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && + finishedWork.flags & 4 && (null === current ? finishedRoot.componentDidMount() : ((create$82 = @@ -5605,7 +5564,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { } return; case 5: - null === current && finishedWork.effectTag & 4 && shim(); + null === current && finishedWork.flags & 4 && shim(); return; case 6: return; @@ -5738,14 +5697,13 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, - workInProgressRootCanSuspendUsingConfig = null, workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5772,46 +5730,33 @@ function requestEventTime() { ? currentEventTime : (currentEventTime = now()); } -function requestUpdateLane(fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; if (0 === (fiber & 2)) return 1; if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; 0 === currentEventWipLanes && (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; + if (0 !== ReactCurrentBatchConfig.transition) { 0 !== currentEventPendingLanes && (currentEventPendingLanes = null !== mostRecentlyUpdatedRoot ? mostRecentlyUpdatedRoot.pendingLanes : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (50 < nestedUpdateCount) @@ -5833,7 +5778,9 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber)) : (ensureRootIsScheduled(fiber, eventTime), schedulePendingInteractions(fiber, lane), - 0 === executionContext && flushSyncCallbackQueue()) + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) : (0 === (executionContext & 4) || (98 !== priorityLevel && 99 !== priorityLevel) || (null === rootsWithPendingDiscreteUpdates @@ -5875,8 +5822,8 @@ function ensureRootIsScheduled(root, currentTime) { getHighestPriorityLanes(lane); var priority = return_highestLanePriority; expirationTimes[index$5] = - 12 <= priority - ? expirationTime + 1e3 + 10 <= priority + ? expirationTime + 250 : 6 <= priority ? expirationTime + 5e3 : -1; @@ -5901,7 +5848,7 @@ function ensureRootIsScheduled(root, currentTime) { existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode); } - 17 === currentTime + 15 === currentTime ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), null === syncQueue ? ((syncQueue = [existingCallbackNode]), @@ -5911,7 +5858,7 @@ function ensureRootIsScheduled(root, currentTime) { ))) : syncQueue.push(existingCallbackNode), (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime + : 14 === currentTime ? (existingCallbackNode = scheduleCallback( 99, performSyncWorkOnRoot.bind(null, root) @@ -5925,7 +5872,7 @@ function ensureRootIsScheduled(root, currentTime) { root.callbackNode = existingCallbackNode; } } -function performConcurrentWorkOnRoot(root, didTimeout) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) @@ -5938,21 +5885,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); var lanes$jscomp$0 = lanes; - didTimeout = executionContext; + var exitStatus = executionContext; executionContext |= 16; var prevDispatcher = pushDispatcher(); if ( workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes$jscomp$0 ) - prepareFreshStack(root, lanes$jscomp$0), + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, lanes$jscomp$0), startWorkOnPendingInteractions(root, lanes$jscomp$0); lanes$jscomp$0 = pushInteractions(root); do @@ -5966,21 +5908,21 @@ function performConcurrentWorkOnRoot(root, didTimeout) { resetContextDependencies(); tracing.__interactionsRef.current = lanes$jscomp$0; ReactCurrentDispatcher$2.current = prevDispatcher; - executionContext = didTimeout; + executionContext = exitStatus; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = 0) : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); + (exitStatus = workInProgressRootExitStatus)); if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && + else if (0 !== exitStatus) { + 2 === exitStatus && ((executionContext |= 64), root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended$1(root, lanes), @@ -5988,7 +5930,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { originalCallbackNode); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; - switch (didTimeout) { + switch (exitStatus) { case 0: case 1: throw Error("Root did not complete. This is a bug in React."); @@ -5999,8 +5941,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes); if ( (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevDispatcher = root.suspendedLanes; @@ -6011,7 +5953,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -6019,33 +5961,31 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevDispatcher = -1; 0 < lanes; ) { + var index$4 = 31 - clz32(lanes); + lanes$jscomp$0 = 1 << index$4; + index$4 = exitStatus[index$4]; + index$4 > prevDispatcher && (prevDispatcher = index$4); + lanes &= ~lanes$jscomp$0; } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); + lanes = prevDispatcher; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), @@ -6056,30 +5996,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { commitRoot(root); break; case 5: - lanes$jscomp$0 = getMostRecentEventTime(root, lanes); - if ( - -1 !== lanes$jscomp$0 && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevDispatcher = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (lanes$jscomp$0 = now() - lanes$jscomp$0), - (didTimeout = - lanes$jscomp$0 <= prevDispatcher - ? 0 - : prevDispatcher + didTimeout - lanes$jscomp$0)), - 10 < didTimeout) - ) { - markRootSuspended$1(root, lanes); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - didTimeout - ); - break; - } commitRoot(root); break; default: @@ -6097,9 +6013,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$10 = 31 - clz32(suspendedLanes), - lane = 1 << index$10; - root[index$10] = -1; + var index$9 = 31 - clz32(suspendedLanes), + lane = 1 << index$9; + root[index$9] = -1; suspendedLanes &= ~lane; } } @@ -6193,8 +6109,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; - workInProgressRootCanSuspendUsingConfig = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; spawnedWorkDuringRender = null; } @@ -6234,7 +6148,7 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.effectTag |= 2048; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -6280,13 +6194,13 @@ function handleError(root$jscomp$0, thrownValue) { workInProgress$77.updateQueue = updateQueue; } else wakeables.add(wakeable); if (0 === (workInProgress$77.mode & 2)) { - workInProgress$77.effectTag |= 64; - sourceFiber.effectTag |= 16384; - sourceFiber.effectTag &= -2981; + workInProgress$77.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } @@ -6313,7 +6227,7 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$77.effectTag |= 4096; + workInProgress$77.flags |= 8192; workInProgress$77.lanes = thrownValue; break a; } @@ -6332,7 +6246,7 @@ function handleError(root$jscomp$0, thrownValue) { switch (workInProgress$77.tag) { case 3: root = value; - workInProgress$77.effectTag |= 4096; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; workInProgress$77.lanes |= thrownValue; var update$78 = createRootErrorUpdate( @@ -6347,14 +6261,14 @@ function handleError(root$jscomp$0, thrownValue) { var ctor = workInProgress$77.type, instance = workInProgress$77.stateNode; if ( - 0 === (workInProgress$77.effectTag & 64) && + 0 === (workInProgress$77.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$77.effectTag |= 4096; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; workInProgress$77.lanes |= thrownValue; var update$81 = createClassErrorUpdate( @@ -6390,13 +6304,6 @@ function pushInteractions(root) { tracing.__interactionsRef.current = root.memoizedInteractions; return prevInteractions; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); -} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 16; @@ -6450,7 +6357,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { + if (0 === (completedWork.flags & 4096)) { if (0 === (completedWork.mode & 8)) current = completeWork(current, completedWork, subtreeRenderLanes); else { @@ -6503,14 +6410,14 @@ function completeUnitOfWork(unitOfWork) { current.childLanes = fiber; } null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && (unitOfWork.firstEffect = completedWork.firstEffect), null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + 1 < completedWork.flags && (null !== unitOfWork.lastEffect ? (unitOfWork.lastEffect.nextEffect = completedWork) : (unitOfWork.firstEffect = completedWork), @@ -6518,7 +6425,7 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.effectTag &= 2047; + current.flags &= 4095; workInProgress = current; return; } @@ -6531,7 +6438,7 @@ function completeUnitOfWork(unitOfWork) { } null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -6577,11 +6484,11 @@ function commitRootImpl(root, renderPriorityLevel) { 0 < noLongerPendingLanes; ) { - var index$11 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$11; - remainingLanes$jscomp$0[index$11] = 0; - eventTimes[index$11] = -1; - expirationTimes[index$11] = -1; + var index$10 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$10; + remainingLanes$jscomp$0[index$10] = 0; + eventTimes[index$10] = -1; + expirationTimes[index$10] = -1; noLongerPendingLanes &= ~lane; } null !== rootsWithPendingDiscreteUpdates && @@ -6591,7 +6498,7 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - 1 < finishedWork.effectTag + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), (remainingLanes = finishedWork.firstEffect)) @@ -6619,8 +6526,8 @@ function commitRootImpl(root, renderPriorityLevel) { do try { for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6630,19 +6537,19 @@ function commitRootImpl(root, renderPriorityLevel) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: @@ -6650,8 +6557,8 @@ function commitRootImpl(root, renderPriorityLevel) { break; case 8: expirationTimes = nextEffect; - a: for (index$11 = noLongerPendingLanes = expirationTimes; ; ) { - lane = index$11; + a: for (index$10 = noLongerPendingLanes = expirationTimes; ; ) { + lane = index$10; if ( injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount @@ -6714,21 +6621,21 @@ function commitRootImpl(root, renderPriorityLevel) { case 4: createChildNodeSet(lane.stateNode.containerInfo); } - if (null !== index$11.child) - (index$11.child.return = index$11), - (index$11 = index$11.child); + if (null !== index$10.child) + (index$10.child.return = index$10), + (index$10 = index$10.child); else { - if (index$11 === noLongerPendingLanes) break; - for (; null === index$11.sibling; ) { + if (index$10 === noLongerPendingLanes) break; + for (; null === index$10.sibling; ) { if ( - null === index$11.return || - index$11.return === noLongerPendingLanes + null === index$10.return || + index$10.return === noLongerPendingLanes ) break a; - index$11 = index$11.return; + index$10 = index$10.return; } - index$11.sibling.return = index$11.return; - index$11 = index$11.sibling; + index$10.sibling.return = index$10.return; + index$10 = index$10.sibling; } } var alternate = expirationTimes.alternate; @@ -6737,9 +6644,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$95) { + } catch (error$90) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$95); + captureCommitPhaseError(nextEffect, error$90); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6747,11 +6654,11 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = remainingLanes; do try { - for (effectTag = root; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { @@ -6770,9 +6677,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$96) { + } catch (error$91) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$96); + captureCommitPhaseError(nextEffect, error$91); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6781,7 +6688,7 @@ function commitRootImpl(root, renderPriorityLevel) { tracing.__interactionsRef.current = eventTimes; executionContext = remainingLanes$jscomp$0; } else (root.current = finishedWork), (commitTime = now$1()); - if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects)) + if ((flags$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), (rootWithPendingPassiveEffects = root), (pendingPassiveEffectsLanes = lanes), @@ -6790,7 +6697,7 @@ function commitRootImpl(root, renderPriorityLevel) { for (nextEffect = remainingLanes; null !== nextEffect; ) (ref = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && + nextEffect.flags & 8 && ((instance$jscomp$0 = nextEffect), (instance$jscomp$0.sibling = null), (instance$jscomp$0.stateNode = null)), @@ -6812,7 +6719,7 @@ function commitRootImpl(root, renderPriorityLevel) { ); schedulePendingInteractions(root, remainingLanes); } else legacyErrorBoundariesThatAlreadyFailed = null; - effectTag$jscomp$0 || finishPendingInteractions(root, lanes); + flags$jscomp$0 || finishPendingInteractions(root, lanes); 1 === remainingLanes ? root === rootWithNestedUpdates ? nestedUpdateCount++ @@ -6825,7 +6732,7 @@ function commitRootImpl(root, renderPriorityLevel) { rendererID, finishedWork, renderPriorityLevel, - 64 === (finishedWork.current.effectTag & 64) + 64 === (finishedWork.current.flags & 64) ); } catch (err) {} ensureRootIsScheduled(root, now()); @@ -6843,17 +6750,16 @@ function commitBeforeMutationEffects() { var current = nextEffect.alternate; shouldFireAfterActiveInstanceBlur || null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) + (0 !== (nextEffect.flags & 8) ? doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0) : 13 === nextEffect.tag && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0)); - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); - 0 === (effectTag & 512) || + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -6870,7 +6776,6 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } return !1; @@ -6907,10 +6812,10 @@ function flushPassiveEffectsImpl() { unmountEffects = pendingPassiveHookEffectsUnmount; pendingPassiveHookEffectsUnmount = []; for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$101 = unmountEffects[i], + var effect$96 = unmountEffects[i], fiber = unmountEffects[i + 1], - destroy = effect$101.destroy; - effect$101.destroy = void 0; + destroy = effect$96.destroy; + effect$96.destroy = void 0; if ("function" === typeof destroy) try { destroy(); @@ -6922,22 +6827,22 @@ function flushPassiveEffectsImpl() { unmountEffects = pendingPassiveHookEffectsMount; pendingPassiveHookEffectsMount = []; for (i = 0; i < unmountEffects.length; i += 2) { - effect$101 = unmountEffects[i]; + effect$96 = unmountEffects[i]; fiber = unmountEffects[i + 1]; try { - var create$105 = effect$101.create; - effect$101.destroy = create$105(); - } catch (error$106) { + var create$100 = effect$96.create; + effect$96.destroy = create$100(); + } catch (error$101) { if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$106); + captureCommitPhaseError(fiber, error$101); } } for (unmountEffects = root.current.firstEffect; null !== unmountEffects; ) - (create$105 = unmountEffects.nextEffect), + (create$100 = unmountEffects.nextEffect), (unmountEffects.nextEffect = null), - unmountEffects.effectTag & 8 && + unmountEffects.flags & 8 && ((unmountEffects.sibling = null), (unmountEffects.stateNode = null)), - (unmountEffects = create$105); + (unmountEffects = create$100); tracing.__interactionsRef.current = prevInteractions; finishPendingInteractions(root, lanes); executionContext = prevExecutionContext; @@ -6972,14 +6877,22 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); - enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); fiber = markUpdateLaneFromFiberToRoot(fiber, 1); - null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber), - schedulePendingInteractions(fiber, 1)); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update), + schedulePendingInteractions(fiber, 1); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } @@ -7034,7 +6947,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) didReceiveUpdate = !0; else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { didReceiveUpdate = !1; switch (workInProgress.tag) { @@ -7062,7 +6975,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { break; case 12: 0 !== (renderLanes & workInProgress.childLanes) && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); updateLanes = workInProgress.stateNode; updateLanes.effectDuration = 0; updateLanes.passiveEffectDuration = 0; @@ -7087,14 +7000,14 @@ beginWork$1 = function(current, workInProgress, renderLanes) { break; case 19: updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { + if (0 !== (current.flags & 64)) { if (updateLanes) return updateSuspenseListComponent( current, workInProgress, renderLanes ); - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; } context = workInProgress.memoizedState; null !== context && @@ -7121,7 +7034,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); @@ -7133,7 +7046,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { context, renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -7183,7 +7096,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; hasContext = context._init; context = hasContext(context._payload); @@ -7362,7 +7275,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 12: return ( - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (updateLanes = workInProgress.stateNode), (updateLanes.effectDuration = 0), (updateLanes.passiveEffectDuration = 0), @@ -7430,8 +7343,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 1 === context$jscomp$0.tag && ((dependency = createUpdate( -1, - renderLanes & -renderLanes, - null + renderLanes & -renderLanes )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); @@ -7493,7 +7405,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), (updateLanes = updateLanes(context)), - (workInProgress.effectTag |= 1), + (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); @@ -7534,7 +7446,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) @@ -7564,6 +7476,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) { "). This error is likely caused by a bug in React. Please file an issue." ); }; +function markSpawnedWork(lane) { + null === spawnedWorkDuringRender + ? (spawnedWorkDuringRender = [lane]) + : spawnedWorkDuringRender.push(lane); +} function scheduleInteractions(root, lane, interactions) { if (0 < interactions.size) { var pendingInteractionMap = root.pendingInteractionMap, @@ -7637,9 +7554,9 @@ function finishPendingInteractions(root, committedLanes) { if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error$107) { + } catch (error$102) { scheduleCallback(99, function() { - throw error$107; + throw error$102; }); } })); @@ -7655,7 +7572,7 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; @@ -7696,7 +7613,7 @@ function createWorkInProgress(current, pendingProps) { (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), - (workInProgress.effectTag = 0), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), @@ -7852,10 +7769,10 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.hydrate = hydrate; this.callbackNode = null; this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.entanglements = createLaneMap(0); this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); @@ -7887,8 +7804,7 @@ function findHostInstance(component) { function updateContainer(element, container, parentComponent, callback) { var current = container.current, eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + lane = requestUpdateLane(current); a: if (parentComponent) { parentComponent = parentComponent._reactInternals; b: { @@ -7936,7 +7852,7 @@ function updateContainer(element, container, parentComponent, callback) { null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); @@ -7967,14 +7883,16 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_913 = { + devToolsConfig$jscomp$inline_887 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.0-alpha.0", + version: "17.0.1-4e5d7faf5", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7989,13 +7907,17 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1111 = { - bundleType: devToolsConfig$jscomp$inline_913.bundleType, - version: devToolsConfig$jscomp$inline_913.version, - rendererPackageName: devToolsConfig$jscomp$inline_913.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_913.rendererConfig, +var internals$jscomp$inline_1087 = { + bundleType: devToolsConfig$jscomp$inline_887.bundleType, + version: devToolsConfig$jscomp$inline_887.version, + rendererPackageName: devToolsConfig$jscomp$inline_887.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_887.rendererConfig, overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, setSuspenseHandler: null, scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, @@ -8004,7 +7926,7 @@ var internals$jscomp$inline_1111 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_913.findFiberByHostInstance || + devToolsConfig$jscomp$inline_887.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -8013,16 +7935,16 @@ var internals$jscomp$inline_1111 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1112 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1088 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1112.isDisabled && - hook$jscomp$inline_1112.supportsFiber + !hook$jscomp$inline_1088.isDisabled && + hook$jscomp$inline_1088.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1112.inject( - internals$jscomp$inline_1111 + (rendererID = hook$jscomp$inline_1088.inject( + internals$jscomp$inline_1087 )), - (injectedHook = hook$jscomp$inline_1112); + (injectedHook = hook$jscomp$inline_1088); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.js b/Libraries/Renderer/implementations/ReactFabric-profiling.js index cc076b1040285b..995495a12c799f 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.js @@ -17,16 +17,6 @@ var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/R React = require("react"), Scheduler = require("scheduler"), tracing = require("scheduler/tracing"); -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -97,109 +87,6 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } -function getListener(inst, registrationName) { - var listener = inst.stateNode; - if (!listener) return null; - var props = getFiberCurrentPropsFromNode(listener); - if (!props) return null; - listener = props[registrationName]; - a: switch (registrationName) { - case "onClick": - case "onClickCapture": - case "onDoubleClick": - case "onDoubleClickCapture": - case "onMouseDown": - case "onMouseDownCapture": - case "onMouseMove": - case "onMouseMoveCapture": - case "onMouseUp": - case "onMouseUpCapture": - case "onMouseEnter": - (props = !props.disabled) || - ((inst = inst.type), - (props = !( - "button" === inst || - "input" === inst || - "select" === inst || - "textarea" === inst - ))); - inst = !props; - break a; - default: - inst = !1; - } - if (inst) return null; - if (listener && "function" !== typeof listener) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - return listener; -} -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} function functionThatReturnsTrue() { return !0; } @@ -215,6 +102,7 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; + this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -294,7 +182,12 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { +function createOrGetPooledEvent( + dispatchConfig, + targetInst, + nativeEvent, + nativeInst +) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -311,8 +204,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { + EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; - EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -440,6 +333,22 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -453,65 +362,132 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" - }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" - }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" - }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" - }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies - }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies + dependencies: startDependencies + }, + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] + dependencies: ["topScroll"] + }, + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { - registrationName: "onResponderReject", - dependencies: [] + dependencies: ["topSelectionChange"] + }, + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } + dependencies: moveDependencies + }, + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies }, - ResponderEventPlugin = { + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { registrationName: "onResponderReject", dependencies: [] }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } +}; +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} +function getListener(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +var ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -572,68 +548,70 @@ var eventTypes = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp === responderInst; - JSCompiler_temp = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp; + JSCompiler_temp = targetInst === responderInst; + shouldSetEventType = ResponderSyntheticEvent.getPooled( shouldSetEventType, - JSCompiler_temp, + targetInst, nativeEvent, nativeEventTarget ); - JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; - targetInst + shouldSetEventType.touchHistory = + ResponderTouchHistoryStore.touchHistory; + JSCompiler_temp ? forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingle ); b: { - shouldSetEventType = JSCompiler_temp._dispatchListeners; - targetInst = JSCompiler_temp._dispatchInstances; - if (Array.isArray(shouldSetEventType)) + JSCompiler_temp = shouldSetEventType._dispatchListeners; + targetInst = shouldSetEventType._dispatchInstances; + if (Array.isArray(JSCompiler_temp)) for ( depthA = 0; - depthA < shouldSetEventType.length && - !JSCompiler_temp.isPropagationStopped(); + depthA < JSCompiler_temp.length && + !shouldSetEventType.isPropagationStopped(); depthA++ ) { if ( - shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) + JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) ) { - shouldSetEventType = targetInst[depthA]; + JSCompiler_temp = targetInst[depthA]; break b; } } else if ( - shouldSetEventType && - shouldSetEventType(JSCompiler_temp, targetInst) + JSCompiler_temp && + JSCompiler_temp(shouldSetEventType, targetInst) ) { - shouldSetEventType = targetInst; + JSCompiler_temp = targetInst; break b; } - shouldSetEventType = null; + JSCompiler_temp = null; } - JSCompiler_temp._dispatchInstances = null; - JSCompiler_temp._dispatchListeners = null; - JSCompiler_temp.isPersistent() || - JSCompiler_temp.constructor.release(JSCompiler_temp); - if (shouldSetEventType && shouldSetEventType !== responderInst) + shouldSetEventType._dispatchInstances = null; + shouldSetEventType._dispatchListeners = null; + shouldSetEventType.isPersistent() || + shouldSetEventType.constructor.release(shouldSetEventType); + if (JSCompiler_temp && JSCompiler_temp !== responderInst) if ( - ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( + ((shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), - (JSCompiler_temp.touchHistory = + (shouldSetEventType.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), + (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), responderInst) ) if ( @@ -660,13 +638,13 @@ var eventTypes = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [JSCompiler_temp, depthA] + [shouldSetEventType, depthA] ); - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), @@ -683,9 +661,9 @@ var eventTypes = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - JSCompiler_temp + shouldSetEventType )), - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -813,7 +791,6 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -830,7 +807,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -838,7 +815,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -866,13 +843,75 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - customBubblingEventTypes = + registrationNameModules = {}; +function getListener$1(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; +function accumulateDirectionalDispatches$1(inst, phase, event) { + if ( + (phase = getListener$1( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle$1(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + for (var inst = event._targetInst, path = []; inst; ) { + path.push(inst); + do inst = inst.return; + while (inst && 5 !== inst.tag); + inst = inst ? inst : null; + } + for (inst = path.length; 0 < inst--; ) + accumulateDirectionalDispatches$1(path[inst], "captured", event); + for (inst = 0; inst < path.length; inst++) + accumulateDirectionalDispatches$1(path[inst], "bubbled", event); + } +} +function accumulateDirectDispatchesSingle$1(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener$1(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -882,7 +921,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_92 = { +var injectedNamesToPlugins$jscomp$inline_223 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -906,42 +945,45 @@ var injectedNamesToPlugins$jscomp$inline_92 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); + forEachAccumulated( + topLevelType, + accumulateTwoPhaseDispatchesSingle$1 + ); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_93 = !1, - pluginName$jscomp$inline_94; -for (pluginName$jscomp$inline_94 in injectedNamesToPlugins$jscomp$inline_92) + isOrderingDirty$jscomp$inline_224 = !1, + pluginName$jscomp$inline_225; +for (pluginName$jscomp$inline_225 in injectedNamesToPlugins$jscomp$inline_223) if ( - injectedNamesToPlugins$jscomp$inline_92.hasOwnProperty( - pluginName$jscomp$inline_94 + injectedNamesToPlugins$jscomp$inline_223.hasOwnProperty( + pluginName$jscomp$inline_225 ) ) { - var pluginModule$jscomp$inline_95 = - injectedNamesToPlugins$jscomp$inline_92[pluginName$jscomp$inline_94]; + var pluginModule$jscomp$inline_226 = + injectedNamesToPlugins$jscomp$inline_223[pluginName$jscomp$inline_225]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_94) || - namesToPlugins[pluginName$jscomp$inline_94] !== - pluginModule$jscomp$inline_95 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_225) || + namesToPlugins[pluginName$jscomp$inline_225] !== + pluginModule$jscomp$inline_226 ) { - if (namesToPlugins[pluginName$jscomp$inline_94]) + if (namesToPlugins[pluginName$jscomp$inline_225]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_94 + + pluginName$jscomp$inline_225 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_94 - ] = pluginModule$jscomp$inline_95; - isOrderingDirty$jscomp$inline_93 = !0; + pluginName$jscomp$inline_225 + ] = pluginModule$jscomp$inline_226; + isOrderingDirty$jscomp$inline_224 = !0; } } -isOrderingDirty$jscomp$inline_93 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_224 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -965,31 +1007,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; -ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || - (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); -ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || - (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); -var hasSymbol = "function" === typeof Symbol && Symbol.for, - REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, - REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, - REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, - REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, - REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, - REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, - REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_CONCURRENT_MODE_TYPE = hasSymbol - ? Symbol.for("react.concurrent_mode") - : 60111, - REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, - REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_SUSPENSE_LIST_TYPE = hasSymbol - ? Symbol.for("react.suspense_list") - : 60120, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, + REACT_ELEMENT_TYPE = 60103, + REACT_PORTAL_TYPE = 60106, + REACT_FRAGMENT_TYPE = 60107, + REACT_STRICT_MODE_TYPE = 60108, + REACT_PROFILER_TYPE = 60114, + REACT_PROVIDER_TYPE = 60109, + REACT_CONTEXT_TYPE = 60110, + REACT_FORWARD_REF_TYPE = 60112, + REACT_SUSPENSE_TYPE = 60113, + REACT_SUSPENSE_LIST_TYPE = 60120, + REACT_MEMO_TYPE = 60115, + REACT_LAZY_TYPE = 60116, + REACT_BLOCK_TYPE = 60121, + REACT_DEBUG_TRACING_MODE_TYPE = 60129, + REACT_OFFSCREEN_TYPE = 60130, + REACT_LEGACY_HIDDEN_TYPE = 60131; +if ("function" === typeof Symbol && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor("react.element"); + REACT_PORTAL_TYPE = symbolFor("react.portal"); + REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); + REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); + REACT_PROFILER_TYPE = symbolFor("react.profiler"); + REACT_PROVIDER_TYPE = symbolFor("react.provider"); + REACT_CONTEXT_TYPE = symbolFor("react.context"); + REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); + REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); + REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); + REACT_MEMO_TYPE = symbolFor("react.memo"); + REACT_LAZY_TYPE = symbolFor("react.lazy"); + REACT_BLOCK_TYPE = symbolFor("react.block"); + symbolFor("react.scope"); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); + REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); + REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); +} +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -997,27 +1052,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function initializeLazyComponentType(lazyComponent) { - if (-1 === lazyComponent._status) { - var ctor = lazyComponent._result; - ctor || (ctor = lazyComponent._ctor); - ctor = ctor(); - lazyComponent._status = 0; - lazyComponent._result = ctor; - ctor.then( - function(moduleObject) { - 0 === lazyComponent._status && - ((moduleObject = moduleObject.default), - (lazyComponent._status = 1), - (lazyComponent._result = moduleObject)); - }, - function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); - } - ); - } -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1052,10 +1086,13 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type.render); + return getComponentName(type._render); case REACT_LAZY_TYPE: - if ((type = 1 === type._status ? type._result : null)) - return getComponentName(type); + innerType = type._payload; + type = type._init; + try { + return getComponentName(type(innerType)); + } catch (x) {} } return null; } @@ -1067,7 +1104,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1107,36 +1144,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, _child = parentA.child; _child; ) { - if (_child === a) { + for (var didFindChild = !1, child$0 = parentA.child; child$0; ) { + if (child$0 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (_child === b) { + if (child$0 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - _child = _child.sibling; + child$0 = child$0.sibling; } if (!didFindChild) { - for (_child = parentB.child; _child; ) { - if (_child === a) { + for (child$0 = parentB.child; child$0; ) { + if (child$0 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (_child === b) { + if (child$0 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - _child = _child.sibling; + child$0 = child$0.sibling; } if (!didFindChild) throw Error( @@ -1171,6 +1208,18 @@ function findCurrentHostFiber(parent) { } return null; } +function doesFiberContain(parentFiber, childFiber) { + for ( + var parentFiberAlternate = parentFiber.alternate; + null !== childFiber; + + ) { + if (childFiber === parentFiber || childFiber === parentFiberAlternate) + return !0; + childFiber = childFiber.return; + } + return !1; +} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -1384,19 +1433,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var _propKey in prevProps) - void 0 === nextProps[_propKey] && - (!(attributeConfig = validAttributes[_propKey]) || - (updatePayload && void 0 !== updatePayload[_propKey]) || - ((prevProp = prevProps[_propKey]), + for (var propKey$2 in prevProps) + void 0 === nextProps[propKey$2] && + (!(attributeConfig = validAttributes[propKey$2]) || + (updatePayload && void 0 !== updatePayload[propKey$2]) || + ((prevProp = prevProps[propKey$2]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[_propKey] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$2] = null), removedKeys || (removedKeys = {}), - removedKeys[_propKey] || - ((removedKeys[_propKey] = !0), removedKeyCount++)) + removedKeys[propKey$2] || + ((removedKeys[propKey$2] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1444,37 +1493,49 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null != stateNode && (eventTarget = stateNode.canonical); } batchedUpdates(function() { - var events = eventTarget; - for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { - var possiblePlugin = plugins[i]; + var JSCompiler_inline_result = eventTarget; + for ( + var events = null, legacyPlugins = plugins, i = 0; + i < legacyPlugins.length; + i++ + ) { + var possiblePlugin = legacyPlugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, target, nativeEvent, - events, - 1 + JSCompiler_inline_result )) && - (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); + (events = accumulateInto(events, possiblePlugin)); } - events = events$jscomp$0; - null !== events && (eventQueue = accumulateInto(eventQueue, events)); - events = eventQueue; + JSCompiler_inline_result = events; + null !== JSCompiler_inline_result && + (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); + JSCompiler_inline_result = eventQueue; eventQueue = null; - if (events) { - forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (JSCompiler_inline_result) { + forEachAccumulated( + JSCompiler_inline_result, + executeDispatchesAndReleaseTopLevel + ); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((events = rethrowError), + throw ((JSCompiler_inline_result = rethrowError), (hasRethrowError = !1), (rethrowError = null), - events); + JSCompiler_inline_result); } }); } +function shim() { + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); +} function shim$1() { throw Error( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." @@ -1567,19 +1628,32 @@ var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node; - var updatePayload = diffProperties( + var JSCompiler_inline_result = diffProperties( null, emptyObject, { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); return { - node: cloneNodeWithNewProps(node, updatePayload), + node: cloneNodeWithNewProps(node, JSCompiler_inline_result), canonical: instance.canonical }; } +function describeComponentFrame(name, source, ownerName) { + source = ""; + ownerName && (source = " (created by " + ownerName + ")"); + return "\n in " + (name || "Unknown") + source; +} +function describeFunctionComponentFrame(fn, source) { + return fn + ? describeComponentFrame(fn.displayName || fn.name || null, source, null) + : ""; +} var valueStack = [], index = -1; +function createCursor(defaultValue) { + return { current: defaultValue }; +} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1590,8 +1664,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = { current: emptyContextObject }, - didPerformWorkStackCursor = { current: !1 }, + contextStackCursor = createCursor(emptyContextObject), + didPerformWorkStackCursor = createCursor(!1), previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1640,7 +1714,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1671,12 +1745,212 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } +var rendererID = null, + injectedHook = null, + isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__, + Scheduler_now = Scheduler.unstable_now; +if ( + null == tracing.__interactionsRef || + null == tracing.__interactionsRef.current +) + throw Error( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" + ); +Scheduler_now(); +var return_highestLanePriority = 8; +function getHighestPriorityLanes(lanes) { + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; + var inputDiscreteLanes = 24 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 12), inputDiscreteLanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 10), inputDiscreteLanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 8), inputDiscreteLanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 6), inputDiscreteLanes; + inputDiscreteLanes = 62914560 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 5), inputDiscreteLanes; + if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; + if (0 !== (lanes & 134217728)) + return (return_highestLanePriority = 3), 134217728; + inputDiscreteLanes = 805306368 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 2), inputDiscreteLanes; + if (0 !== (1073741824 & lanes)) + return (return_highestLanePriority = 1), 1073741824; + return_highestLanePriority = 8; + return lanes; +} +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case 99: + return 15; + case 98: + return 10; + case 97: + case 96: + return 8; + case 95: + return 2; + default: + return 0; + } +} +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case 15: + case 14: + return 99; + case 13: + case 12: + case 11: + case 10: + return 98; + case 9: + case 8: + case 7: + case 6: + case 4: + case 5: + return 97; + case 3: + case 2: + case 1: + return 95; + case 0: + return 90; + default: + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); + } +} +function getNextLanes(root, wipLanes) { + var pendingLanes = root.pendingLanes; + if (0 === pendingLanes) return (return_highestLanePriority = 0); + var nextLanes = 0, + nextLanePriority = 0, + expiredLanes = root.expiredLanes, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes; + if (0 !== expiredLanes) + (nextLanes = expiredLanes), + (nextLanePriority = return_highestLanePriority = 15); + else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { + var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; + 0 !== nonIdleUnblockedLanes + ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), + (nextLanePriority = return_highestLanePriority)) + : ((pingedLanes &= expiredLanes), + 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority))); + } else + (expiredLanes = pendingLanes & ~suspendedLanes), + 0 !== expiredLanes + ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), + (nextLanePriority = return_highestLanePriority)) + : 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority)); + if (0 === nextLanes) return 0; + nextLanes = 31 - clz32(nextLanes); + nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); + if ( + 0 !== wipLanes && + wipLanes !== nextLanes && + 0 === (wipLanes & suspendedLanes) + ) { + getHighestPriorityLanes(wipLanes); + if (nextLanePriority <= return_highestLanePriority) return wipLanes; + return_highestLanePriority = nextLanePriority; + } + wipLanes = root.entangledLanes; + if (0 !== wipLanes) + for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) + (pendingLanes = 31 - clz32(wipLanes)), + (nextLanePriority = 1 << pendingLanes), + (nextLanes |= root[pendingLanes]), + (wipLanes &= ~nextLanePriority); + return nextLanes; +} +function getLanesToRetrySynchronouslyOnError(root) { + root = root.pendingLanes & -1073741825; + return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; +} +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case 15: + return 1; + case 14: + return 2; + case 12: + return ( + (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + ); + case 10: + return ( + (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority + ); + case 8: + return ( + (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), + 0 === lanePriority && + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), + 0 === lanePriority && (lanePriority = 512)), + lanePriority + ); + case 2: + return ( + (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), + 0 === wipLanes && (wipLanes = 268435456), + wipLanes + ); + } + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); +} +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; +} +function markRootUpdated(root, updateLane, eventTime) { + root.pendingLanes |= updateLane; + var higherPriorityLanes = updateLane - 1; + root.suspendedLanes &= higherPriorityLanes; + root.pingedLanes &= higherPriorityLanes; + root = root.eventTimes; + updateLane = 31 - clz32(updateLane); + root[updateLane] = eventTime; +} +var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, + log = Math.log, + LN2 = Math.LN2; +function clz32Fallback(lanes) { + return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; +} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now = Scheduler.unstable_now, + Scheduler_now$1 = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -1689,7 +1963,7 @@ if ( null == tracing.__interactionsRef.current ) throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); var fakeCallbackNode = {}, requestPaint = @@ -1697,12 +1971,12 @@ var fakeCallbackNode = {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), + initialTimeMs$1 = Scheduler_now$1(), now = - 1e4 > initialTimeMs - ? Scheduler_now + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 : function() { - return Scheduler_now() - initialTimeMs; + return Scheduler_now$1() - initialTimeMs$1; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -1744,16 +2018,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } -function scheduleSyncCallback(callback) { - null === syncQueue - ? ((syncQueue = [callback]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(callback); - return fakeCallbackNode; -} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -1788,19 +2052,7 @@ function flushSyncCallbackQueueImpl() { } } } -function inferPriorityFromExpirationTime(currentTime, expirationTime) { - if (1073741823 === expirationTime) return 99; - if (1 === expirationTime || 2 === expirationTime) return 95; - currentTime = - 10 * (1073741821 - expirationTime) - 10 * (1073741821 - currentTime); - return 0 >= currentTime - ? 99 - : 250 >= currentTime - ? 98 - : 5250 >= currentTime - ? 97 - : 95; -} +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -1826,42 +2078,29 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; -function getStackByFiberInDevAndProd(workInProgress) { - var info = ""; - do { - a: switch (workInProgress.tag) { - case 3: - case 4: - case 6: - case 7: - case 10: - case 9: - var JSCompiler_inline_result = ""; - break a; - default: - var owner = workInProgress._debugOwner, - source = workInProgress._debugSource, - name = getComponentName(workInProgress.type); - JSCompiler_inline_result = null; - owner && (JSCompiler_inline_result = getComponentName(owner.type)); - owner = name; - name = ""; - source - ? (name = - " (at " + - source.fileName.replace(BEFORE_SLASH_RE, "") + - ":" + - source.lineNumber + - ")") - : JSCompiler_inline_result && - (name = " (created by " + JSCompiler_inline_result + ")"); - JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - } - info += JSCompiler_inline_result; - workInProgress = workInProgress.return; - } while (workInProgress); - return info; +function describeFiber(fiber) { + switch (fiber.tag) { + case 5: + return describeComponentFrame(fiber.type, null, null); + case 16: + return describeComponentFrame("Lazy", null, null); + case 13: + return describeComponentFrame("Suspense", null, null); + case 19: + return describeComponentFrame("SuspenseList", null, null); + case 0: + case 2: + case 15: + return describeFunctionComponentFrame(fiber.type, null); + case 11: + return describeFunctionComponentFrame(fiber.type.render, null); + case 22: + return describeFunctionComponentFrame(fiber.type._render, null); + case 1: + return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; + default: + return ""; + } } function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { @@ -1870,10 +2109,11 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); + return baseProps; } return baseProps; } -var valueCursor = { current: null }, +var valueCursor = createCursor(null), currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -1885,31 +2125,29 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue2 = currentValue; } -function scheduleWorkOnParentPath(parent, renderExpirationTime) { +function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { var alternate = parent.alternate; - if (parent.childExpirationTime < renderExpirationTime) - (parent.childExpirationTime = renderExpirationTime), - null !== alternate && - alternate.childExpirationTime < renderExpirationTime && - (alternate.childExpirationTime = renderExpirationTime); - else if ( - null !== alternate && - alternate.childExpirationTime < renderExpirationTime - ) - alternate.childExpirationTime = renderExpirationTime; - else break; + if ((parent.childLanes & renderLanes) === renderLanes) + if ( + null === alternate || + (alternate.childLanes & renderLanes) === renderLanes + ) + break; + else alternate.childLanes |= renderLanes; + else + (parent.childLanes |= renderLanes), + null !== alternate && (alternate.childLanes |= renderLanes); parent = parent.return; } } -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress, renderLanes) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (workInProgress.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0), + (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -1928,7 +2166,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - expirationTime: 0, + lanes: 0, firstContext: observedBits, responders: null }; @@ -1940,7 +2178,8 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - baseQueue: null, + firstBaseUpdate: null, + lastBaseUpdate: null, shared: { pending: null }, effects: null }; @@ -1950,21 +2189,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - baseQueue: current.baseQueue, + firstBaseUpdate: current.firstBaseUpdate, + lastBaseUpdate: current.lastBaseUpdate, shared: current.shared, effects: current.effects }); } -function createUpdate(expirationTime, suspenseConfig) { - expirationTime = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, +function createUpdate(eventTime, lane) { + return { + eventTime: eventTime, + lane: lane, tag: 0, payload: null, callback: null, next: null }; - return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -1977,132 +2216,177 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, update) { - var current = workInProgress.alternate; - null !== current && cloneUpdateQueue(current, workInProgress); - workInProgress = workInProgress.updateQueue; - current = workInProgress.baseQueue; - null === current - ? ((workInProgress.baseQueue = update.next = update), - (update.next = update)) - : ((update.next = current.next), (current.next = update)); +function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + var queue = workInProgress.updateQueue, + current = workInProgress.alternate; + if ( + null !== current && + ((current = current.updateQueue), queue === current) + ) { + var newFirst = null, + newLast = null; + queue = queue.firstBaseUpdate; + if (null !== queue) { + do { + var clone = { + eventTime: queue.eventTime, + lane: queue.lane, + tag: queue.tag, + payload: queue.payload, + callback: queue.callback, + next: null + }; + null === newLast + ? (newFirst = newLast = clone) + : (newLast = newLast.next = clone); + queue = queue.next; + } while (null !== queue); + null === newLast + ? (newFirst = newLast = capturedUpdate) + : (newLast = newLast.next = capturedUpdate); + } else newFirst = newLast = capturedUpdate; + queue = { + baseState: current.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: current.shared, + effects: current.effects + }; + workInProgress.updateQueue = queue; + return; + } + workInProgress = queue.lastBaseUpdate; + null === workInProgress + ? (queue.firstBaseUpdate = capturedUpdate) + : (workInProgress.next = capturedUpdate); + queue.lastBaseUpdate = capturedUpdate; } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderExpirationTime + renderLanes ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var baseQueue = queue.baseQueue, + var firstBaseUpdate = queue.firstBaseUpdate, + lastBaseUpdate = queue.lastBaseUpdate, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - if (null !== baseQueue) { - var baseFirst = baseQueue.next; - baseQueue.next = pendingQueue.next; - pendingQueue.next = baseFirst; - } - baseQueue = pendingQueue; queue.shared.pending = null; - baseFirst = workInProgress$jscomp$0.alternate; - null !== baseFirst && - ((baseFirst = baseFirst.updateQueue), - null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); + var lastPendingUpdate = pendingQueue, + firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; + null === lastBaseUpdate + ? (firstBaseUpdate = firstPendingUpdate) + : (lastBaseUpdate.next = firstPendingUpdate); + lastBaseUpdate = lastPendingUpdate; + var current = workInProgress$jscomp$0.alternate; + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate + ? (current.firstBaseUpdate = firstPendingUpdate) + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } - if (null !== baseQueue) { - baseFirst = baseQueue.next; - var newState = queue.baseState, - newExpirationTime = 0, - newBaseState = null, - newBaseQueueFirst = null, - newBaseQueueLast = null; - if (null !== baseFirst) { - var update = baseFirst; - do { - pendingQueue = update.expirationTime; - if (pendingQueue < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, + if (null !== firstBaseUpdate) { + currentLastBaseUpdate = queue.baseState; + lastBaseUpdate = 0; + current = firstPendingUpdate = lastPendingUpdate = null; + do { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { + null !== current && + (current = current.next = { + eventTime: updateEventTime, + lane: 0, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (newBaseState = newState)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - pendingQueue > newExpirationTime && - (newExpirationTime = pendingQueue); - } else { - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }); - markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); - a: { - var workInProgress = workInProgress$jscomp$0, - update$jscomp$0 = update; - pendingQueue = props; - clone = instance; - switch (update$jscomp$0.tag) { - case 1: - workInProgress = update$jscomp$0.payload; - if ("function" === typeof workInProgress) { - newState = workInProgress.call(clone, newState, pendingQueue); - break a; - } - newState = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update$jscomp$0.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call(clone, newState, pendingQueue) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - newState = Object.assign({}, newState, pendingQueue); + }); + a: { + var workInProgress = workInProgress$jscomp$0, + update = firstBaseUpdate; + pendingQueue = props; + updateEventTime = instance; + switch (update.tag) { + case 1: + workInProgress = update.payload; + if ("function" === typeof workInProgress) { + currentLastBaseUpdate = workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ); break a; - case 2: - hasForceUpdate = !0; - } + } + currentLastBaseUpdate = workInProgress; + break a; + case 3: + workInProgress.flags = (workInProgress.flags & -8193) | 64; + case 0: + workInProgress = update.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); + break a; + case 2: + hasForceUpdate = !0; } - null !== update.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [update]) - : pendingQueue.push(update)); } - update = update.next; - if (null === update || update === baseFirst) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (update = baseQueue.next = pendingQueue.next), - (pendingQueue.next = baseFirst), - (queue.baseQueue = baseQueue = pendingQueue), - (queue.shared.pending = null); - } while (1); - } - null === newBaseQueueLast - ? (newBaseState = newState) - : (newBaseQueueLast.next = newBaseQueueFirst); - queue.baseState = newBaseState; - queue.baseQueue = newBaseQueueLast; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress$jscomp$0.expirationTime = newExpirationTime; - workInProgress$jscomp$0.memoizedState = newState; + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); + } else + (updateEventTime = { + eventTime: updateEventTime, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, + next: null + }), + null === current + ? ((firstPendingUpdate = current = updateEventTime), + (lastPendingUpdate = currentLastBaseUpdate)) + : (current = current.next = updateEventTime), + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), + (queue.shared.pending = null); + } while (1); + null === current && (lastPendingUpdate = currentLastBaseUpdate); + queue.baseState = lastPendingUpdate; + queue.firstBaseUpdate = firstPendingUpdate; + queue.lastBaseUpdate = current; + workInProgressRootSkippedLanes |= lastBaseUpdate; + workInProgress$jscomp$0.lanes = lastBaseUpdate; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2127,8 +2411,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2142,54 +2425,45 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.expirationTime && + 0 === workInProgress.lanes && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternalFiber) + return (component = component._reactInternals) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2227,7 +2501,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternalFiber = workInProgress; + ctor._reactInternals = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2248,12 +2522,7 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { +function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2266,7 +2535,7 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2283,15 +2552,10 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue( - workInProgress, - newProps, - instance, - renderExpirationTime - ), + processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2306,7 +2570,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2340,7 +2604,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2352,7 +2616,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - ")." + "). If you meant to render a collection of children, use an array instead." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2364,7 +2628,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2396,26 +2660,22 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, expirationTime) { + function updateTextNode(returnFiber, current, textContent, lanes) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromText(textContent, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2423,27 +2683,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, expirationTime) { + function updateElement(returnFiber, current, element, lanes) { if (null !== current && current.elementType === element.type) return ( - (expirationTime = useFiber(current, element.props)), - (expirationTime.ref = coerceRef(returnFiber, current, element)), - (expirationTime.return = returnFiber), - expirationTime + (lanes = useFiber(current, element.props)), + (lanes.ref = coerceRef(returnFiber, current, element)), + (lanes.return = returnFiber), + lanes ); - expirationTime = createFiberFromTypeAndProps( + lanes = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - expirationTime + lanes ); - expirationTime.ref = coerceRef(returnFiber, current, element); - expirationTime.return = returnFiber; - return expirationTime; + lanes.ref = coerceRef(returnFiber, current, element); + lanes.return = returnFiber; + return lanes; } - function updatePortal(returnFiber, current, portal, expirationTime) { + function updatePortal(returnFiber, current, portal, lanes) { if ( null === current || 4 !== current.tag || @@ -2451,11 +2711,7 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2463,13 +2719,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, expirationTime, key) { + function updateFragment(returnFiber, current, fragment, lanes, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - expirationTime, + lanes, key )), (current.return = returnFiber), @@ -2479,13 +2735,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, expirationTime) { + function createChild(returnFiber, newChild, lanes) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2494,24 +2750,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( + (lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef(returnFiber, null, newChild)), - (expirationTime.return = returnFiber), - expirationTime + (lanes.ref = coerceRef(returnFiber, null, newChild)), + (lanes.return = returnFiber), + lanes ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2522,7 +2778,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - expirationTime, + lanes, null )), (newChild.return = returnFiber), @@ -2532,12 +2788,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { + function updateSlot(returnFiber, oldFiber, newChild, lanes) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); + : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2547,26 +2803,20 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - expirationTime, + lanes, key ) - : updateElement(returnFiber, oldFiber, newChild, expirationTime) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) + ? updatePortal(returnFiber, oldFiber, newChild, lanes) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment( - returnFiber, - oldFiber, - newChild, - expirationTime, - null - ); + : updateFragment(returnFiber, oldFiber, newChild, lanes, null); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2576,17 +2826,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - expirationTime + lanes ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode( - returnFiber, - existingChildren, - "" + newChild, - expirationTime - ) + updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2601,15 +2846,10 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - expirationTime, + lanes, newChild.key ) - : updateElement( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -2617,24 +2857,13 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + updatePortal(returnFiber, existingChildren, newChild, lanes) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment( - returnFiber, - existingChildren, - newChild, - expirationTime, - null - ) + updateFragment(returnFiber, existingChildren, newChild, lanes, null) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2644,7 +2873,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - expirationTime + lanes ) { for ( var resultingFirstChild = null, @@ -2662,7 +2891,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - expirationTime + lanes ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2685,11 +2914,7 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )), + (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -2712,7 +2937,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - expirationTime + lanes )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -2739,7 +2964,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - expirationTime + lanes ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -2761,12 +2986,7 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot( - returnFiber, - oldFiber, - step.value, - expirationTime - ); + var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -2786,7 +3006,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, expirationTime)), + (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -2800,13 +3020,7 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap( - oldFiber, - returnFiber, - newIdx, - step.value, - expirationTime - )), + (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -2822,7 +3036,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, expirationTime) { + return function(returnFiber, currentFirstChild, newChild, lanes) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -2888,26 +3102,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - expirationTime, + lanes, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( + : ((lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef( + (lanes.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (expirationTime.return = returnFiber), - (returnFiber = expirationTime)); + (lanes.return = returnFiber), + (returnFiber = lanes)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -2946,7 +3160,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -2965,7 +3179,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - expirationTime + lanes )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -2976,25 +3190,27 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3002,9 +3218,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = { current: NO_CONTEXT }, - contextFiberStackCursor = { current: NO_CONTEXT }, - rootInstanceStackCursor = { current: NO_CONTEXT }; + contextStackCursor$1 = createCursor(NO_CONTEXT), + contextFiberStackCursor = createCursor(NO_CONTEXT), + rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3027,26 +3243,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var nextContext = fiber.type; - nextContext = - "AndroidTextInput" === nextContext || - "RCTMultilineTextInputView" === nextContext || - "RCTSinglelineTextInputView" === nextContext || - "RCTText" === nextContext || - "RCTVirtualText" === nextContext; - nextContext = - context.isInAParentText !== nextContext - ? { isInAParentText: nextContext } + var JSCompiler_inline_result = fiber.type; + JSCompiler_inline_result = + "AndroidTextInput" === JSCompiler_inline_result || + "RCTMultilineTextInputView" === JSCompiler_inline_result || + "RCTSinglelineTextInputView" === JSCompiler_inline_result || + "RCTText" === JSCompiler_inline_result || + "RCTVirtualText" === JSCompiler_inline_result; + JSCompiler_inline_result = + context.isInAParentText !== JSCompiler_inline_result + ? { isInAParentText: JSCompiler_inline_result } : context; - context !== nextContext && + context !== JSCompiler_inline_result && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, nextContext)); + push(contextStackCursor$1, JSCompiler_inline_result)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = { current: 0 }; +var suspenseStackCursor = createCursor(0); function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3054,7 +3270,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim$1() || shim$1())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3070,19 +3286,23 @@ function findFirstSuspended(row) { } return null; } -function createDeprecatedResponderListener(responder, props) { - return { responder: responder, props: props }; +var workInProgressSources = []; +function resetWorkInProgressVersions() { + for (var i = 0; i < workInProgressSources.length; i++) + workInProgressSources[i]._workInProgressVersionSecondary = null; + workInProgressSources.length = 0; } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderExpirationTime = 0, + renderLanes = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1; + didScheduleRenderPhaseUpdate = !1, + didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3097,36 +3317,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderExpirationTime + nextRenderLanes ) { - renderExpirationTime = nextRenderExpirationTime; + renderLanes = nextRenderLanes; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.expirationTime = 0; - ReactCurrentDispatcher.current = + workInProgress.lanes = 0; + ReactCurrentDispatcher$1.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (workInProgress.expirationTime === renderExpirationTime) { - nextRenderExpirationTime = 0; + if (didScheduleRenderPhaseUpdateDuringThisPass) { + nextRenderLanes = 0; do { - workInProgress.expirationTime = 0; - if (!(25 > nextRenderExpirationTime)) + didScheduleRenderPhaseUpdateDuringThisPass = !1; + if (!(25 > nextRenderLanes)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderExpirationTime += 1; + nextRenderLanes += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (workInProgress.expirationTime === renderExpirationTime); + } while (didScheduleRenderPhaseUpdateDuringThisPass); } - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3207,40 +3427,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var updateExpirationTime = update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }; - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - updateExpirationTime > currentlyRenderingFiber$1.expirationTime && - ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), - markUnprocessedUpdateTime(updateExpirationTime)); - } else + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) null !== newBaseQueueLast && (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), (current = update.eagerReducer === reducer ? update.eagerState : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3277,6 +3491,114 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } +function readFromUnsubcribedMutableSource(root, source, getSnapshot) { + var getVersion = source._getVersion; + getVersion = getVersion(source._source); + var JSCompiler_inline_result = source._workInProgressVersionSecondary; + if (null !== JSCompiler_inline_result) + root = JSCompiler_inline_result === getVersion; + else if ( + ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) + ) + (source._workInProgressVersionSecondary = getVersion), + workInProgressSources.push(source); + if (root) return getSnapshot(source._source); + workInProgressSources.push(source); + throw Error( + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." + ); +} +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = workInProgressRoot; + if (null === root) + throw Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + var getVersion = source._getVersion, + version = getVersion(source._source), + dispatcher = ReactCurrentDispatcher$1.current, + _dispatcher$useState = dispatcher.useState(function() { + return readFromUnsubcribedMutableSource(root, source, getSnapshot); + }), + setSnapshot = _dispatcher$useState[1], + snapshot = _dispatcher$useState[0]; + _dispatcher$useState = workInProgressHook; + var memoizedState = hook.memoizedState, + refs = memoizedState.refs, + prevGetSnapshot = refs.getSnapshot, + prevSource = memoizedState.source; + memoizedState = memoizedState.subscribe; + var fiber = currentlyRenderingFiber$1; + hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; + dispatcher.useEffect( + function() { + refs.getSnapshot = getSnapshot; + refs.setSnapshot = setSnapshot; + var maybeNewVersion = getVersion(source._source); + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); + maybeNewVersion = root.mutableReadLanes; + root.entangledLanes |= maybeNewVersion; + for ( + var entanglements = root.entanglements, lanes = maybeNewVersion; + 0 < lanes; + + ) { + var index$11 = 31 - clz32(lanes), + lane = 1 << index$11; + entanglements[index$11] |= maybeNewVersion; + lanes &= ~lane; + } + } + }, + [getSnapshot, source, subscribe] + ); + dispatcher.useEffect( + function() { + return subscribe(source._source, function() { + var latestGetSnapshot = refs.getSnapshot, + latestSetSnapshot = refs.setSnapshot; + try { + latestSetSnapshot(latestGetSnapshot(source._source)); + var lane = requestUpdateLane(fiber); + root.mutableReadLanes |= lane & root.pendingLanes; + } catch (error) { + latestSetSnapshot(function() { + throw error; + }); + } + }); + }, + [source, subscribe] + ); + (objectIs(prevGetSnapshot, getSnapshot) && + objectIs(prevSource, source) && + objectIs(memoizedState, subscribe)) || + ((hook = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), + (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); + return snapshot; +} +function updateMutableSource(source, getSnapshot, subscribe) { + var hook = updateWorkInProgressHook(); + return useMutableSource(hook, source, getSnapshot, subscribe); +} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3313,17 +3635,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3331,12 +3653,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3375,13 +3697,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3409,65 +3724,60 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); - suspenseConfig = { - expirationTime: currentTime, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + var eventTime = requestEventTime(), + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdate = !0), - (suspenseConfig.expirationTime = renderExpirationTime), - (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { if ( - 0 === fiber.expirationTime && - (null === pending || 0 === pending.expirationTime) && + 0 === fiber.lanes && + (null === pending || 0 === pending.lanes) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } -function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3480,14 +3790,21 @@ var ContextOnlyDispatcher = { useRef: throwInvalidHookError, useState: throwInvalidHookError, useDebugValue: throwInvalidHookError, - useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useEvent: throwInvalidHookError + useMutableSource: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, + unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3533,39 +3850,44 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; + }, + useMutableSource: function(source, getSnapshot, subscribe) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); }, - useEvent: function() {} + unstable_isNewReconciler: !1 }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -3581,39 +3903,33 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; + }, + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; }, - useEvent: updateEventListener + unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { readContext: readContext, @@ -3629,39 +3945,33 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; + }, + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; }, - useEvent: updateEventListener + unstable_isNewReconciler: !1 }, now$1 = Scheduler.unstable_now, commitTime = 0, @@ -3674,27 +3984,21 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { profilerStartTime = -1; } } +function transferActualDuration(fiber) { + for (var child = fiber.child; child; ) + (fiber.actualDuration += child.actualDuration), (child = child.sibling); +} var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime -) { +function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress.child = null === current - ? mountChildFibers( - workInProgress, - null, - nextChildren, - renderExpirationTime - ) + ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderExpirationTime + renderLanes ); } function updateForwardRef( @@ -3702,33 +4006,28 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } function updateMemoComponent( @@ -3736,8 +4035,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (null === current) { var type = Component.type; @@ -3756,17 +4055,17 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); current = createFiberFromTypeAndProps( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, - renderExpirationTime + renderLanes ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3774,19 +4073,14 @@ function updateMemoComponent( } type = current.child; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), + 0 === (updateLanes & renderLanes) && + ((updateLanes = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current.ref === workInProgress.ref) + Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3797,26 +4091,64 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { - return null !== current && + if ( + null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref && - ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) - ? ((workInProgress.expirationTime = current.expirationTime), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - )) - : updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderExpirationTime + current.ref === workInProgress.ref + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else + return ( + (workInProgress.lanes = current.lanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + ); + return updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderLanes + ); +} +function updateOffscreenComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, + nextChildren = nextProps.children, + prevState = null !== current ? current.memoizedState : null; + if ( + "hidden" === nextProps.mode || + "unstable-defer-without-hiding" === nextProps.mode + ) + if (0 === (workInProgress.mode & 4)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes(workInProgress, renderLanes); + else if (0 !== (renderLanes & 1073741824)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes( + workInProgress, + null !== prevState ? prevState.baseLanes : renderLanes + ); + else + return ( + (current = + null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), + markSpawnedWork(1073741824), + (workInProgress.lanes = workInProgress.childLanes = 1073741824), + (workInProgress.memoizedState = { baseLanes: current }), + pushRenderLanes(workInProgress, current), + null ); + else + null !== prevState + ? ((nextProps = prevState.baseLanes | renderLanes), + (workInProgress.memoizedState = null)) + : (nextProps = renderLanes), + pushRenderLanes(workInProgress, nextProps); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -3824,42 +4156,37 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } function updateClassComponent( @@ -3867,25 +4194,20 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ), + mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -3916,12 +4238,7 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ); + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -3954,9 +4271,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -3964,119 +4281,113 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); - } else - (instance = workInProgress.stateNode), - cloneUpdateQueue(current, workInProgress), - (oldProps = workInProgress.memoizedProps), - (instance.props = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps)), - (oldContext = instance.context), - (contextType = Component.contextType), - "object" === typeof contextType && null !== contextType - ? (contextType = readContext(contextType)) - : ((contextType = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = - "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( + } else { + instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); + oldProps = workInProgress.memoizedProps; + contextType = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); + instance.props = contextType; + hasNewLifecycles = workInProgress.pendingProps; + oldState = instance.context; + oldContext = Component.contextType; + "object" === typeof oldContext && null !== oldContext + ? (oldContext = readContext(oldContext)) + : ((oldContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (oldContext = getMaskedContext(workInProgress, oldContext))); + var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; + (getDerivedStateFromProps = + "function" === typeof getDerivedStateFromProps$jscomp$0 || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== hasNewLifecycles || oldState !== oldContext) && + callComponentWillReceiveProps( + workInProgress, + instance, + nextProps, + oldContext + )); + hasForceUpdate = !1; + oldState = workInProgress.memoizedState; + instance.state = oldState; + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + var newState = workInProgress.memoizedState; + oldProps !== hasNewLifecycles || + oldState !== newState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps$jscomp$0, + nextProps + ), + (newState = workInProgress.memoizedState)), + (contextType = + hasForceUpdate || + checkShouldComponentUpdate( workInProgress, - instance, + Component, + contextType, nextProps, - contextType - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (instance.state = oldContext), - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState), - oldProps !== nextProps || - oldContext !== oldState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldState = workInProgress.memoizedState)), - (getDerivedStateFromProps = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - oldProps, - nextProps, - oldContext, - oldState, - contextType - )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( - nextProps, - oldState, - contextType - ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - oldState, - contextType - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), - (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); + oldState, + newState, + oldContext + )) + ? (getDerivedStateFromProps || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate(nextProps, newState, oldContext), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + newState, + oldContext + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.flags |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.flags |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = newState)), + (instance.props = nextProps), + (instance.state = newState), + (instance.context = oldContext), + (nextProps = contextType)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (nextProps = !1)); + } return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderExpirationTime + renderLanes ); } function finishClassComponent( @@ -4085,18 +4396,14 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4107,27 +4414,22 @@ function finishClassComponent( var nextChildren = null; profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((didCaptureError = nextChildren), (workInProgress.child = reconcileChildFibers( workInProgress, current.child, null, - renderExpirationTime + renderLanes )), (workInProgress.child = reconcileChildFibers( workInProgress, null, didCaptureError, - renderExpirationTime + renderLanes ))) - : reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + : reconcileChildren(current, workInProgress, nextChildren, renderLanes); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4144,169 +4446,227 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; -function updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime -) { - var mode = workInProgress.mode, - nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; +function updateSuspenseComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - nextDidTimeout = !1, + showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = - 0 !== (suspenseContext & 2) && - (null === current || null !== current.memoizedState)); + null !== current && null === current.memoizedState + ? !1 + : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + current = nextProps.children; + suspenseContext = nextProps.fallback; + if (showFallback) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + current ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - mode = nextProps.children; - workInProgress.memoizedState = null; - return (workInProgress.child = mountChildFibers( - workInProgress, - null, - mode, - renderExpirationTime - )); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432), + current + ); + renderLanes = createFiberFromOffscreen( + { mode: "visible", children: current }, + workInProgress.mode, + renderLanes, + null + ); + renderLanes.return = workInProgress; + return (workInProgress.child = renderLanes); } if (null !== current.memoizedState) { - current = current.child; - mode = current.sibling; - if (nextDidTimeout) { - nextProps = nextProps.fallback; - renderExpirationTime = createWorkInProgress( - current, - current.pendingProps + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - if ( - 0 === (workInProgress.mode & 2) && - ((nextDidTimeout = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child), - nextDidTimeout !== current.child) - ) - for ( - renderExpirationTime.child = nextDidTimeout; - null !== nextDidTimeout; - - ) - (nextDidTimeout.return = renderExpirationTime), - (nextDidTimeout = nextDidTimeout.sibling); - if (workInProgress.mode & 8) { - nextDidTimeout = 0; - for (current = renderExpirationTime.child; null !== current; ) - (nextDidTimeout += current.treeBaseDuration), - (current = current.sibling); - renderExpirationTime.treeBaseDuration = nextDidTimeout; - } - mode = createWorkInProgress(mode, nextProps); - mode.return = workInProgress; - renderExpirationTime.sibling = mode; - renderExpirationTime.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = renderExpirationTime; - return mode; - } - renderExpirationTime = reconcileChildFibers( + renderLanes = updateSuspensePrimaryChildren( + current, workInProgress, - current.child, nextProps.children, - renderExpirationTime + renderLanes ); workInProgress.memoizedState = null; - return (workInProgress.child = renderExpirationTime); + return renderLanes; } - current = current.child; - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - nextProps.child = current; - null !== current && (current.return = nextProps); - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - if (workInProgress.mode & 8) { - current = 0; - for (suspenseContext = nextProps.child; null !== suspenseContext; ) - (current += suspenseContext.treeBaseDuration), - (suspenseContext = suspenseContext.sibling); - nextProps.treeBaseDuration = current; - } - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - renderExpirationTime.effectTag |= 2; - nextProps.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - workInProgress.memoizedState = null; - return (workInProgress.child = reconcileChildFibers( - workInProgress, + renderLanes = updateSuspensePrimaryChildren( current, + workInProgress, nextProps.children, - renderExpirationTime - )); + renderLanes + ); + workInProgress.memoizedState = null; + return renderLanes; } -function scheduleWorkOnFiber(fiber, renderExpirationTime) { - fiber.expirationTime < renderExpirationTime && - (fiber.expirationTime = renderExpirationTime); +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren), + workInProgress.mode & 8 && + ((progressedPrimaryFragment.actualDuration = 0), + (progressedPrimaryFragment.actualStartTime = -1), + (progressedPrimaryFragment.selfBaseDuration = 0), + (progressedPrimaryFragment.treeBaseDuration = 0))) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; +} +function updateSuspensePrimaryChildren( + current, + workInProgress, + primaryChildren, + renderLanes +) { + var currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { + mode: "visible", + children: primaryChildren + }); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); + primaryChildren.return = workInProgress; + primaryChildren.sibling = null; + null !== current && + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); + return (workInProgress.child = primaryChildren); +} +function updateSuspenseFallbackChildren( + current, + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + var primaryChildProps = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment + ? ((primaryChildren = workInProgress.child), + (primaryChildren.childLanes = 0), + (primaryChildren.pendingProps = primaryChildProps), + workInProgress.mode & 8 && + ((primaryChildren.actualDuration = 0), + (primaryChildren.actualStartTime = -1), + (primaryChildren.selfBaseDuration = + currentPrimaryChildFragment.selfBaseDuration), + (primaryChildren.treeBaseDuration = + currentPrimaryChildFragment.treeBaseDuration)), + (currentPrimaryChildFragment = primaryChildren.lastEffect), + null !== currentPrimaryChildFragment + ? ((workInProgress.firstEffect = primaryChildren.firstEffect), + (workInProgress.lastEffect = currentPrimaryChildFragment), + (currentPrimaryChildFragment.nextEffect = null)) + : (workInProgress.firstEffect = workInProgress.lastEffect = null)) + : (primaryChildren = createWorkInProgress( + currentPrimaryChildFragment, + primaryChildProps + )); + null !== current + ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) + : ((fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + )), + (fallbackChildren.flags |= 2)); + fallbackChildren.return = workInProgress; + primaryChildren.return = workInProgress; + primaryChildren.sibling = fallbackChildren; + workInProgress.child = primaryChildren; + return fallbackChildren; +} +function scheduleWorkOnFiber(fiber, renderLanes) { + fiber.lanes |= renderLanes; var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < renderExpirationTime && - (alternate.expirationTime = renderExpirationTime); - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + null !== alternate && (alternate.lanes |= renderLanes); + scheduleWorkOnParentPath(fiber.return, renderLanes); } function initSuspenseListRenderState( workInProgress, @@ -4324,7 +4684,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4333,35 +4692,24 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime -) { +function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren( - current, - workInProgress, - nextProps.children, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderExpirationTime); - else if (19 === current.tag) - scheduleWorkOnFiber(current, renderExpirationTime); + scheduleWorkOnFiber(current, renderLanes); + else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4383,30 +4731,29 @@ function updateSuspenseListComponent( else switch (revealOrder) { case "forwards": - renderExpirationTime = workInProgress.child; - for (revealOrder = null; null !== renderExpirationTime; ) - (current = renderExpirationTime.alternate), + renderLanes = workInProgress.child; + for (revealOrder = null; null !== renderLanes; ) + (current = renderLanes.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderExpirationTime), - (renderExpirationTime = renderExpirationTime.sibling); - renderExpirationTime = revealOrder; - null === renderExpirationTime + (revealOrder = renderLanes), + (renderLanes = renderLanes.sibling); + renderLanes = revealOrder; + null === renderLanes ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderExpirationTime.sibling), - (renderExpirationTime.sibling = null)); + : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderExpirationTime, + renderLanes, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderExpirationTime = null; + renderLanes = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4415,14 +4762,14 @@ function updateSuspenseListComponent( break; } current = revealOrder.sibling; - revealOrder.sibling = renderExpirationTime; - renderExpirationTime = revealOrder; + revealOrder.sibling = renderLanes; + renderLanes = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderExpirationTime, + renderLanes, null, tailMode, workInProgress.lastEffect @@ -4443,36 +4790,29 @@ function updateSuspenseListComponent( } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime -) { +function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); profilerStartTime = -1; - var updateExpirationTime = workInProgress.expirationTime; - 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); - if (workInProgress.childExpirationTime < renderExpirationTime) return null; - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderExpirationTime = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderExpirationTime; - for ( - renderExpirationTime.return = workInProgress; - null !== current.sibling; - - ) - (current = current.sibling), - (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderExpirationTime.return = workInProgress); - renderExpirationTime.sibling = null; + workInProgressRootSkippedLanes |= workInProgress.lanes; + if (0 !== (renderLanes & workInProgress.childLanes)) { + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderLanes = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderLanes; + for (renderLanes.return = workInProgress; null !== current.sibling; ) + (current = current.sibling), + (renderLanes = renderLanes.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderLanes.return = workInProgress); + renderLanes.sibling = null; + } + return workInProgress.child; } - return workInProgress.child; + return null; } var appendAllChildren, updateHostContainer, @@ -4499,7 +4839,7 @@ appendAllChildren = function( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4552,7 +4892,7 @@ function appendAllChildrenToContainer( } else if (4 !== node.tag) { if ( 13 === node.tag && - 0 !== (node.effectTag & 4) && + 0 !== (node.flags & 4) && (instance = null !== node.memoizedState) ) { var primaryChildParent = node.child; @@ -4596,7 +4936,7 @@ updateHostContainer = function(workInProgress) { newChildSet = createChildNodeSet(container); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; - workInProgress.effectTag |= 4; + workInProgress.flags |= 4; completeRoot(container, newChildSet); } }; @@ -4634,7 +4974,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { }), (workInProgress.stateNode = type), current - ? (workInProgress.effectTag |= 4) + ? (workInProgress.flags |= 4) : appendAllChildren(type, workInProgress, !1, !1)); } }; @@ -4648,7 +4988,7 @@ updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText, workInProgress )), - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : (workInProgress.stateNode = current.stateNode); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { @@ -4665,17 +5005,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var _lastTailNode = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), + for (var lastTailNode$65 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === _lastTailNode + null === lastTailNode$65 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (_lastTailNode.sibling = null); + : (lastTailNode$65.sibling = null); } } -function completeWork(current, workInProgress, renderExpirationTime) { +function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -4696,10 +5036,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - (current = workInProgress.stateNode), - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)), + resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)), + (null !== current && null !== current.child) || + newProps.hydrate || + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -4708,17 +5052,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderExpirationTime = workInProgress.type; + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderExpirationTime, + renderLanes, newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4730,30 +5073,30 @@ function completeWork(current, workInProgress, renderExpirationTime) { requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; - renderExpirationTime = getViewConfigForType(renderExpirationTime); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - renderExpirationTime.validAttributes + renderLanes.validAttributes ); rootContainerInstance = createNode( current, - renderExpirationTime.uiViewClassName, + renderLanes.uiViewClassName, rootContainerInstance, updatePayload, workInProgress ); current = new ReactFabricHostComponent( current, - renderExpirationTime, + renderLanes, newProps, workInProgress ); current = { node: rootContainerInstance, canonical: current }; appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -4782,52 +5125,40 @@ function completeWork(current, workInProgress, renderExpirationTime) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) + if (0 !== (workInProgress.flags & 64)) return ( - (workInProgress.expirationTime = renderExpirationTime), workInProgress + (workInProgress.lanes = renderLanes), + 0 !== (workInProgress.mode & 8) && + transferActualDuration(workInProgress), + workInProgress ); newProps = null !== newProps; rootContainerInstance = !1; null !== current && - ((renderExpirationTime = current.memoizedState), - (rootContainerInstance = null !== renderExpirationTime), - newProps || - null === renderExpirationTime || - ((renderExpirationTime = current.child.sibling), - null !== renderExpirationTime && - ((updatePayload = workInProgress.firstEffect), - null !== updatePayload - ? ((workInProgress.firstEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = updatePayload)) - : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = null)), - (renderExpirationTime.effectTag = 8)))); + (rootContainerInstance = null !== current.memoizedState); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); + 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3); else { if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( - workInProgressRoot, - renderExpirationTime$1 - ), - markRootUpdatedAtTime( + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || + markRootSuspended$1( workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); + workInProgressRootRenderLanes + ); } - newProps && (workInProgress.effectTag |= 4); + newProps && (workInProgress.flags |= 4); return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -4839,71 +5170,70 @@ function completeWork(current, workInProgress, renderExpirationTime) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== current && 0 !== (current.effectTag & 64)) + 0 !== workInProgressRootExitStatus || + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderExpirationTime; + current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (updatePayload = current), - (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), - (renderExpirationTime = rootContainerInstance.alternate), - null === renderExpirationTime - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = updatePayload), + (renderLanes = rootContainerInstance.alternate), + null === renderLanes + ? ((rootContainerInstance.childLanes = 0), + (rootContainerInstance.lanes = updatePayload), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), (rootContainerInstance.dependencies = null), + (rootContainerInstance.stateNode = null), (rootContainerInstance.selfBaseDuration = 0), (rootContainerInstance.treeBaseDuration = 0)) - : ((rootContainerInstance.childExpirationTime = - renderExpirationTime.childExpirationTime), - (rootContainerInstance.expirationTime = - renderExpirationTime.expirationTime), - (rootContainerInstance.child = - renderExpirationTime.child), + : ((rootContainerInstance.childLanes = + renderLanes.childLanes), + (rootContainerInstance.lanes = renderLanes.lanes), + (rootContainerInstance.child = renderLanes.child), (rootContainerInstance.memoizedProps = - renderExpirationTime.memoizedProps), + renderLanes.memoizedProps), (rootContainerInstance.memoizedState = - renderExpirationTime.memoizedState), + renderLanes.memoizedState), (rootContainerInstance.updateQueue = - renderExpirationTime.updateQueue), - (updatePayload = renderExpirationTime.dependencies), + renderLanes.updateQueue), + (rootContainerInstance.type = renderLanes.type), + (updatePayload = renderLanes.dependencies), (rootContainerInstance.dependencies = null === updatePayload ? null : { - expirationTime: updatePayload.expirationTime, - firstContext: updatePayload.firstContext, - responders: updatePayload.responders + lanes: updatePayload.lanes, + firstContext: updatePayload.firstContext }), (rootContainerInstance.selfBaseDuration = - renderExpirationTime.selfBaseDuration), + renderLanes.selfBaseDuration), (rootContainerInstance.treeBaseDuration = - renderExpirationTime.treeBaseDuration)), + renderLanes.treeBaseDuration)), (newProps = newProps.sibling); push( suspenseStackCursor, @@ -4913,6 +5243,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); } else { if (!rootContainerInstance) @@ -4920,12 +5257,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -4938,16 +5275,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1 < renderExpirationTime && - ((workInProgress.effectTag |= 64), + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && + 1073741824 !== renderLanes && + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (current = renderExpirationTime - 1), - (workInProgress.expirationTime = workInProgress.childExpirationTime = current), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [current]) - : spawnedWorkDuringRender.push(current)); + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -4958,9 +5293,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -4975,6 +5308,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { ), current) : null; + case 23: + case 24: + return ( + popRenderLanes(), + null !== current && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && + "unstable-defer-without-hiding" !== newProps.mode && + (workInProgress.flags |= 4), + null + ); } throw Error( "Unknown unit of work tag (" + @@ -4986,30 +5330,35 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && + transferActualDuration(workInProgress), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + resetWorkInProgressVersions(); + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && + transferActualDuration(workInProgress), workInProgress) : null ); @@ -5019,16 +5368,25 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 23: + case 24: + return popRenderLanes(), null; default: return null; } } function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; + try { + var info = "", + node = source; + do (info += describeFiber(node)), (node = node.return); + while (node); + var JSCompiler_inline_result = info; + } catch (x) { + JSCompiler_inline_result = + "\nError generating stack: " + x.message + "\n" + x.stack; + } + return { value: value, source: source, stack: JSCompiler_inline_result }; } if ( "function" !== @@ -5037,51 +5395,61 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(capturedError) { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( - capturedError - ) && console.error(capturedError.error); -} -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; -function logError(boundary, errorInfo) { - var source = errorInfo.source, - stack = errorInfo.stack; - null === stack && - null !== source && - (stack = getStackByFiberInDevAndProd(source)); - errorInfo = { - componentName: null !== source ? getComponentName(source.type) : null, - componentStack: null !== stack ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: !1, - willRetry: !1 - }; - null !== boundary && - 1 === boundary.tag && - ((errorInfo.errorBoundary = boundary.stateNode), - (errorInfo.errorBoundaryName = getComponentName(boundary.type)), - (errorInfo.errorBoundaryFound = !0), - (errorInfo.willRetry = !0)); +function logCapturedError(boundary, errorInfo) { try { - logCapturedError(errorInfo); + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + componentStack: null !== errorInfo.stack ? errorInfo.stack : "", + error: errorInfo.value, + errorBoundary: + null !== boundary && 1 === boundary.tag ? boundary.stateNode : null + }) && console.error(errorInfo.value); } catch (e) { setTimeout(function() { throw e; }); } } -function safelyCallComponentWillUnmount(current, instance) { - try { - (instance.props = current.memoizedProps), - (instance.state = current.memoizedState), - instance.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, unmountError); +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + lane.payload = { element: null }; + var error = errorInfo.value; + lane.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logCapturedError(fiber, errorInfo); + }; + return lane; +} +function createClassErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + lane.payload = function() { + logCapturedError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (lane.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logCapturedError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return lane; } +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -5101,7 +5469,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -5115,6 +5483,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: + return; case 5: case 6: case 4: @@ -5125,58 +5494,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitHookEffectListUnmount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var destroy = effect.destroy; - effect.destroy = void 0; - void 0 !== destroy && destroy(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} -function commitHookEffectListMount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var create = effect.create; - effect.destroy = create(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - commitHookEffectListMount(3, finishedWork); + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + if (3 === (finishedRoot.tag & 3)) { + var create$82 = finishedRoot.create; + finishedRoot.destroy = create$82(); + } + finishedRoot = finishedRoot.next; + } while (finishedRoot !== current); + } + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + var _effect = finishedRoot; + create$82 = _effect.next; + _effect = _effect.tag; + 0 !== (_effect & 4) && + 0 !== (_effect & 1) && + (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), + enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); + finishedRoot = create$82; + } while (finishedRoot !== current); + } return; case 1: finishedRoot = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current) finishedRoot.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - finishedRoot.componentDidUpdate( - prevProps, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ); - } + finishedWork.flags & 4 && + (null === current + ? finishedRoot.componentDidMount() + : ((create$82 = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current.memoizedProps + )), + finishedRoot.componentDidUpdate( + create$82, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ))); current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5197,26 +5565,23 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { } return; case 5: - if (null === current && finishedWork.effectTag & 4) - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); + null === current && finishedWork.flags & 4 && shim(); return; case 6: return; case 4: return; case 12: - prevProps = finishedWork.memoizedProps.onRender; - var commitTime$jscomp$0 = commitTime; - "function" === typeof prevProps && - prevProps( + create$82 = finishedWork.memoizedProps.onRender; + _effect = commitTime; + "function" === typeof create$82 && + create$82( finishedWork.memoizedProps.id, null === current ? "mount" : "update", finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, - commitTime$jscomp$0, + _effect, finishedRoot.memoizedInteractions ); return; @@ -5226,74 +5591,25 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 23: + case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$jscomp$0); - switch (current$jscomp$0.tag) { - case 0: - case 11: - case 14: - case 15: - case 22: - finishedRoot = current$jscomp$0.updateQueue; - if ( - null !== finishedRoot && - ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) - ) { - var firstEffect = finishedRoot.next; - runWithPriority( - 97 < renderPriorityLevel ? 97 : renderPriorityLevel, - function() { - var effect = firstEffect; - do { - var _destroy = effect.destroy; - if (void 0 !== _destroy) { - var current = current$jscomp$0; - try { - _destroy(); - } catch (error) { - captureCommitPhaseError(current, error); - } - } - effect = effect.next; - } while (effect !== firstEffect); - } - ); - } - break; - case 1: - safelyDetachRef(current$jscomp$0); - renderPriorityLevel = current$jscomp$0.stateNode; - "function" === typeof renderPriorityLevel.componentWillUnmount && - safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); - break; - case 5: - safelyDetachRef(current$jscomp$0); - break; - case 4: - createChildNodeSet(current$jscomp$0.stateNode.containerInfo); - } -} -function detachFiber(current) { - var alternate = current.alternate; - current.return = null; - current.child = null; - current.memoizedState = null; - current.updateQueue = null; - current.dependencies = null; - current.alternate = null; - current.firstEffect = null; - current.lastEffect = null; - current.pendingProps = null; - current.memoizedProps = null; - current.stateNode = null; - null !== alternate && detachFiber(alternate); +function detachFiberMutation(fiber) { + fiber.alternate = null; + fiber.child = null; + fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.return = null; + fiber.updateQueue = null; } function commitWork(current, finishedWork) { switch (finishedWork.tag) { @@ -5302,7 +5618,19 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - commitHookEffectListUnmount(3, finishedWork); + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedWork = current = current.next; + do { + if (3 === (finishedWork.tag & 3)) { + var destroy = finishedWork.destroy; + finishedWork.destroy = void 0; + void 0 !== destroy && destroy(); + } + finishedWork = finishedWork.next; + } while (finishedWork !== current); + } return; case 12: return; @@ -5314,6 +5642,9 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; + case 23: + case 24: + return; } a: { switch (finishedWork.tag) { @@ -5332,87 +5663,48 @@ function commitWork(current, finishedWork) { } } function attachSuspenseRetryListeners(finishedWork) { - var thenables = finishedWork.updateQueue; - if (null !== thenables) { + var wakeables = finishedWork.updateQueue; + if (null !== wakeables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - thenables.forEach(function(thenable) { - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - retryCache.has(thenable) || - (!0 !== thenable.__reactDoNotTraceInteractions && + wakeables.forEach(function(wakeable) { + var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + retryCache.has(wakeable) || + (!0 !== wakeable.__reactDoNotTraceInteractions && (retry = tracing.unstable_wrap(retry)), - retryCache.add(thenable), - thenable.then(retry, retry)); + retryCache.add(wakeable), + wakeable.then(retry, retry)); }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - expirationTime.payload = { element: null }; - var error = errorInfo.value; - expirationTime.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logError(fiber, errorInfo); - }; - return expirationTime; -} -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - expirationTime.payload = function() { - logError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; - } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (expirationTime.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return expirationTime; +function isSuspenseBoundaryBeingHidden(current, finishedWork) { + return null !== current && + ((current = current.memoizedState), + null === current || null !== current.dehydrated) + ? ((finishedWork = finishedWork.memoizedState), + null !== finishedWork && null === finishedWork.dehydrated) + : !1; } var ceil = Math.ceil, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - NoContext = 0, - LegacyUnbatchedContext = 8, - RenderContext = 16, - CommitContext = 32, - RootIncomplete = 0, - RootFatalErrored = 1, - RootErrored = 2, - RootSuspended = 3, - RootSuspendedWithDelay = 4, - RootCompleted = 5, - executionContext = NoContext, + executionContext = 0, workInProgressRoot = null, workInProgress = null, - renderExpirationTime$1 = 0, - workInProgressRootExitStatus = RootIncomplete, + workInProgressRootRenderLanes = 0, + subtreeRenderLanes = 0, + subtreeRenderLanesCursor = createCursor(0), + workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestProcessedExpirationTime = 1073741823, - workInProgressRootLatestSuspenseTimeout = 1073741823, - workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootNextUnprocessedUpdateTime = 0, - workInProgressRootHasPendingPing = !1, + workInProgressRootIncludedLanes = 0, + workInProgressRootSkippedLanes = 0, + workInProgressRootUpdatedLanes = 0, + workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, - FALLBACK_THROTTLE_MS = 500, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5420,201 +5712,192 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, - pendingPassiveEffectsExpirationTime = 0, + pendingPassiveEffectsLanes = 0, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, spawnedWorkDuringRender = null, - currentEventTime = 0; -function requestCurrentTimeForUpdate() { - return (executionContext & (RenderContext | CommitContext)) !== NoContext - ? 1073741821 - ((now() / 10) | 0) - : 0 !== currentEventTime + currentEventTime = -1, + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; +function requestEventTime() { + return 0 !== (executionContext & 48) + ? now() + : -1 !== currentEventTime ? currentEventTime - : (currentEventTime = 1073741821 - ((now() / 10) | 0)); + : (currentEventTime = now()); } -function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1073741823; - var priorityLevel = getCurrentPriorityLevel(); - if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; - if ((executionContext & RenderContext) !== NoContext) - return renderExpirationTime$1; - if (null !== suspenseConfig) - currentTime = - 1073741821 - - 25 * - ((((1073741821 - - currentTime + - (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / - 25) | - 0) + - 1); - else - switch (priorityLevel) { - case 99: - currentTime = 1073741823; - break; - case 98: - currentTime = - 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); - break; - case 97: - case 96: - currentTime = - 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); - break; - case 95: - currentTime = 2; - break; - default: - throw Error("Expected a valid priority level"); - } - null !== workInProgressRoot && - currentTime === renderExpirationTime$1 && - --currentTime; - return currentTime; -} -function scheduleWork(fiber, expirationTime) { + if (0 === (fiber & 2)) return 1; + if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; + 0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes); + if (0 !== ReactCurrentBatchConfig.transition) { + 0 !== currentEventPendingLanes && + (currentEventPendingLanes = + null !== mostRecentlyUpdatedRoot + ? mostRecentlyUpdatedRoot.pendingLanes + : 0); + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; + } + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; +} +function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (50 < nestedUpdateCount) throw ((nestedUpdateCount = 0), (rootWithNestedUpdates = null), Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." )); - fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); - if (null !== fiber) { - var priorityLevel = getCurrentPriorityLevel(); - 1073741823 === expirationTime - ? (executionContext & LegacyUnbatchedContext) !== NoContext && - (executionContext & (RenderContext | CommitContext)) === NoContext - ? (schedulePendingInteractions(fiber, expirationTime), - performSyncWorkOnRoot(fiber)) - : (ensureRootIsScheduled(fiber), - schedulePendingInteractions(fiber, expirationTime), - executionContext === NoContext && flushSyncCallbackQueue()) - : (ensureRootIsScheduled(fiber), - schedulePendingInteractions(fiber, expirationTime)); - (executionContext & 4) === NoContext || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) - : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), - (void 0 === priorityLevel || priorityLevel > expirationTime) && - rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); - } -} -function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); - var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < expirationTime && - (alternate.expirationTime = expirationTime); - var node = fiber.return, - root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; - else - for (; null !== node; ) { - alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); - null !== alternate && - alternate.childExpirationTime < expirationTime && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { - root = node.stateNode; - break; + fiber = markUpdateLaneFromFiberToRoot(fiber, lane); + if (null === fiber) return null; + markRootUpdated(fiber, lane, eventTime); + fiber === workInProgressRoot && + ((workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(fiber, workInProgressRootRenderLanes)); + var priorityLevel = getCurrentPriorityLevel(); + 1 === lane + ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) + ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber)) + : (ensureRootIsScheduled(fiber, eventTime), + schedulePendingInteractions(fiber, lane), + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) + : (0 === (executionContext & 4) || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) + : rootsWithPendingDiscreteUpdates.add(fiber)), + ensureRootIsScheduled(fiber, eventTime), + schedulePendingInteractions(fiber, lane)); + mostRecentlyUpdatedRoot = fiber; +} +function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + sourceFiber.lanes |= lane; + var alternate = sourceFiber.alternate; + null !== alternate && (alternate.lanes |= lane); + alternate = sourceFiber; + for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) + (sourceFiber.childLanes |= lane), + (alternate = sourceFiber.alternate), + null !== alternate && (alternate.childLanes |= lane), + (alternate = sourceFiber), + (sourceFiber = sourceFiber.return); + return 3 === alternate.tag ? alternate.stateNode : null; +} +function ensureRootIsScheduled(root, currentTime) { + for ( + var existingCallbackNode = root.callbackNode, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes; + 0 < lanes; + + ) { + var index$5 = 31 - clz32(lanes), + lane = 1 << index$5, + expirationTime = expirationTimes[index$5]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { + expirationTime = currentTime; + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; + expirationTimes[index$5] = + 10 <= priority + ? expirationTime + 250 + : 6 <= priority + ? expirationTime + 5e3 + : -1; } - node = node.return; - } - null !== root && - (workInProgressRoot === root && - (markUnprocessedUpdateTime(expirationTime), - workInProgressRootExitStatus === RootSuspendedWithDelay && - markRootSuspendedAtTime(root, renderExpirationTime$1)), - markRootUpdatedAtTime(root, expirationTime)); - return root; -} -function getNextRootExpirationTimeToWorkOn(root) { - var lastExpiredTime = root.lastExpiredTime; - if (0 !== lastExpiredTime) return lastExpiredTime; - lastExpiredTime = root.firstPendingTime; - if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; - var lastPingedTime = root.lastPingedTime; - root = root.nextKnownPendingLevel; - root = lastPingedTime > root ? lastPingedTime : root; - return 2 >= root && lastExpiredTime !== root ? 0 : root; -} -function ensureRootIsScheduled(root) { - if (0 !== root.lastExpiredTime) - (root.callbackExpirationTime = 1073741823), - (root.callbackPriority = 99), - (root.callbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - )); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + suspendedLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + currentTime = return_highestLanePriority; + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode), + (root.callbackNode = null), + (root.callbackPriority = 0)); else { - var expirationTime = getNextRootExpirationTimeToWorkOn(root), - existingCallbackNode = root.callbackNode; - if (0 === expirationTime) - null !== existingCallbackNode && - ((root.callbackNode = null), - (root.callbackExpirationTime = 0), - (root.callbackPriority = 90)); - else { - var currentTime = requestCurrentTimeForUpdate(); - currentTime = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); - if (null !== existingCallbackNode) { - var existingCallbackPriority = root.callbackPriority; - if ( - root.callbackExpirationTime === expirationTime && - existingCallbackPriority >= currentTime - ) - return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); - } - root.callbackExpirationTime = expirationTime; - root.callbackPriority = currentTime; - expirationTime = - 1073741823 === expirationTime - ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleCallback( - currentTime, - performConcurrentWorkOnRoot.bind(null, root), - { timeout: 10 * (1073741821 - expirationTime) - now() } - ); - root.callbackNode = expirationTime; + if (null !== existingCallbackNode) { + if (root.callbackPriority === currentTime) return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); } + 15 === currentTime + ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), + null === syncQueue + ? ((syncQueue = [existingCallbackNode]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(existingCallbackNode), + (existingCallbackNode = fakeCallbackNode)) + : 14 === currentTime + ? (existingCallbackNode = scheduleCallback( + 99, + performSyncWorkOnRoot.bind(null, root) + )) + : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), + (existingCallbackNode = scheduleCallback( + existingCallbackNode, + performConcurrentWorkOnRoot.bind(null, root) + ))); + root.callbackPriority = currentTime; + root.callbackNode = existingCallbackNode; } } -function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = 0; - if (didTimeout) { - didTimeout = requestCurrentTimeForUpdate(); - var lastExpiredTime = root.lastExpiredTime; - if (0 === lastExpiredTime || lastExpiredTime > didTimeout) - root.lastExpiredTime = didTimeout; - ensureRootIsScheduled(root); - return null; - } - lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); - if (0 === lastExpiredTime) return null; - didTimeout = root.callbackNode; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) +function performConcurrentWorkOnRoot(root) { + currentEventTime = -1; + currentEventPendingLanes = currentEventWipLanes = 0; + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - flushPassiveEffects(); - var expirationTime = lastExpiredTime, - prevExecutionContext = executionContext; - executionContext |= RenderContext; - var exitStatus = pushDispatcher(); - if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) - prepareFreshStack(root, expirationTime), - startWorkOnPendingInteractions(root, expirationTime); - expirationTime = pushInteractions(root); + var originalCallbackNode = root.callbackNode; + if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + return null; + var lanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + if (0 === lanes) return null; + var lanes$jscomp$0 = lanes; + var exitStatus = executionContext; + executionContext |= 16; + var prevDispatcher = pushDispatcher(); + if ( + workInProgressRoot !== root || + workInProgressRootRenderLanes !== lanes$jscomp$0 + ) + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, lanes$jscomp$0), + startWorkOnPendingInteractions(root, lanes$jscomp$0); + lanes$jscomp$0 = pushInteractions(root); do try { workLoopConcurrent(); @@ -5624,205 +5907,164 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = expirationTime; - ReactCurrentDispatcher$1.current = exitStatus; - executionContext = prevExecutionContext; + tracing.__interactionsRef.current = lanes$jscomp$0; + ReactCurrentDispatcher$2.current = prevDispatcher; + executionContext = exitStatus; null !== workInProgress - ? (exitStatus = RootIncomplete) + ? (exitStatus = 0) : ((workInProgressRoot = null), + (workInProgressRootRenderLanes = 0), (exitStatus = workInProgressRootExitStatus)); - if (exitStatus !== RootIncomplete) { - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) - throw ((didTimeout = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - didTimeout); - prevExecutionContext = root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) + prepareFreshStack(root, 0); + else if (0 !== exitStatus) { + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = root.current.alternate; + root.finishedLanes = lanes; switch (exitStatus) { - case RootIncomplete: - case RootFatalErrored: + case 0: + case 1: throw Error("Root did not complete. This is a bug in React."); - case RootErrored: + case 2: commitRoot(root); break; - case RootSuspended: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - prevExecutionContext - )); + case 3: + markRootSuspended$1(root, lanes); if ( - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - ((prevExecutionContext = - globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), - 10 < prevExecutionContext) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { - if ( - workInProgressRootHasPendingPing && - ((expirationTime = root.lastPingedTime), - 0 === expirationTime || expirationTime >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - expirationTime = getNextRootExpirationTimeToWorkOn(root); - if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; + if (0 !== getNextLanes(root, 0)) break; + prevDispatcher = root.suspendedLanes; + if ((prevDispatcher & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevDispatcher; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - prevExecutionContext + exitStatus ); break; } commitRoot(root); break; - case RootSuspendedWithDelay: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - prevExecutionContext - )); - if ( - workInProgressRootHasPendingPing && - ((prevExecutionContext = root.lastPingedTime), - 0 === prevExecutionContext || prevExecutionContext >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - prevExecutionContext = getNextRootExpirationTimeToWorkOn(root); - if ( - 0 !== prevExecutionContext && - prevExecutionContext !== lastExpiredTime - ) - break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; - break; + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevDispatcher = -1; 0 < lanes; ) { + var index$4 = 31 - clz32(lanes); + lanes$jscomp$0 = 1 << index$4; + index$4 = exitStatus[index$4]; + index$4 > prevDispatcher && (prevDispatcher = index$4); + lanes &= ~lanes$jscomp$0; } - 1073741823 !== workInProgressRootLatestSuspenseTimeout - ? (prevExecutionContext = - 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - - now()) - : 1073741823 === workInProgressRootLatestProcessedExpirationTime - ? (prevExecutionContext = 0) - : ((prevExecutionContext = - 10 * - (1073741821 - workInProgressRootLatestProcessedExpirationTime) - - 5e3), - (exitStatus = now()), - (lastExpiredTime = - 10 * (1073741821 - lastExpiredTime) - exitStatus), - (prevExecutionContext = exitStatus - prevExecutionContext), - 0 > prevExecutionContext && (prevExecutionContext = 0), - (prevExecutionContext = - (120 > prevExecutionContext - ? 120 - : 480 > prevExecutionContext - ? 480 - : 1080 > prevExecutionContext - ? 1080 - : 1920 > prevExecutionContext - ? 1920 - : 3e3 > prevExecutionContext - ? 3e3 - : 4320 > prevExecutionContext - ? 4320 - : 1960 * ceil(prevExecutionContext / 1960)) - - prevExecutionContext), - lastExpiredTime < prevExecutionContext && - (prevExecutionContext = lastExpiredTime)); - if (10 < prevExecutionContext) { + lanes = prevDispatcher; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - prevExecutionContext + lanes ); break; } commitRoot(root); break; - case RootCompleted: - if ( - 1073741823 !== workInProgressRootLatestProcessedExpirationTime && - null !== workInProgressRootCanSuspendUsingConfig - ) { - expirationTime = workInProgressRootLatestProcessedExpirationTime; - var suspenseConfig = workInProgressRootCanSuspendUsingConfig; - prevExecutionContext = suspenseConfig.busyMinDurationMs | 0; - 0 >= prevExecutionContext - ? (prevExecutionContext = 0) - : ((exitStatus = suspenseConfig.busyDelayMs | 0), - (expirationTime = - now() - - (10 * (1073741821 - expirationTime) - - (suspenseConfig.timeoutMs | 0 || 5e3))), - (prevExecutionContext = - expirationTime <= exitStatus - ? 0 - : exitStatus + prevExecutionContext - expirationTime)); - if (10 < prevExecutionContext) { - markRootSuspendedAtTime(root, lastExpiredTime); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - prevExecutionContext - ); - break; - } - } + case 5: commitRoot(root); break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root); - return root.callbackNode === didTimeout + ensureRootIsScheduled(root, now()); + return root.callbackNode === originalCallbackNode ? performConcurrentWorkOnRoot.bind(null, root) : null; } +function markRootSuspended$1(root, suspendedLanes) { + suspendedLanes &= ~workInProgressRootPingedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; + for (root = root.expirationTimes; 0 < suspendedLanes; ) { + var index$9 = 31 - clz32(suspendedLanes), + lane = 1 << index$9; + root[index$9] = -1; + suspendedLanes &= ~lane; + } +} function performSyncWorkOnRoot(root) { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lastExpiredTime = root.lastExpiredTime; - lastExpiredTime = - 0 !== lastExpiredTime - ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime - ? renderExpirationTime$1 - : lastExpiredTime - : 1073741823; - var exitStatus = renderRootSync(root, lastExpiredTime); + if ( + root === workInProgressRoot && + 0 !== (root.expiredLanes & workInProgressRootRenderLanes) + ) { + var lanes = workInProgressRootRenderLanes; + var exitStatus = renderRootSync(root, lanes); + 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && + ((lanes = getNextLanes(root, lanes)), + (exitStatus = renderRootSync(root, lanes))); + } else + (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); 0 !== root.tag && - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), exitStatus); root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + root.finishedLanes = lanes; commitRoot(root); - ensureRootIsScheduled(root); + ensureRootIsScheduled(root, now()); return null; } -function prepareFreshStack(root, expirationTime) { +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} +function popRenderLanes() { + subtreeRenderLanes = subtreeRenderLanesCursor.current; + pop(subtreeRenderLanesCursor); +} +function prepareFreshStack(root, lanes) { root.finishedWork = null; - root.finishedExpirationTime = 0; + root.finishedLanes = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -5840,6 +6082,7 @@ function prepareFreshStack(root, expirationTime) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); + resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -5855,26 +6098,28 @@ function prepareFreshStack(root, expirationTime) { break; case 10: popProvider(interruptedWork); + break; + case 23: + case 24: + popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - renderExpirationTime$1 = expirationTime; - workInProgressRootExitStatus = RootIncomplete; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; - workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootNextUnprocessedUpdateTime = 0; - workInProgressRootHasPendingPing = !1; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; spawnedWorkDuringRender = null; } function handleError(root$jscomp$0, thrownValue) { do { + var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) { for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -5884,51 +6129,54 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - renderExpirationTime = 0; + didScheduleRenderPhaseUpdate = !1; + } + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdate = !1; - if (null === workInProgress || null === workInProgress.return) - return ( - (workInProgressRootExitStatus = RootFatalErrored), - (workInProgressRootFatalError = thrownValue), - (workInProgress = null) - ); - workInProgress.mode & 8 && - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); + didScheduleRenderPhaseUpdateDuringThisPass = !1; + ReactCurrentOwner$2.current = null; + if (null === erroredWork || null === erroredWork.return) { + workInProgressRootExitStatus = 1; + workInProgressRootFatalError = thrownValue; + workInProgress = null; + break; + } + erroredWork.mode & 8 && + stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); a: { var root = root$jscomp$0, - returnFiber = workInProgress.return, - sourceFiber = workInProgress, + returnFiber = erroredWork.return, + sourceFiber = erroredWork, value = thrownValue; - thrownValue = renderExpirationTime$1; - sourceFiber.effectTag |= 2048; + thrownValue = workInProgressRootRenderLanes; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var thenable = value; + var wakeable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.expirationTime = currentSource.expirationTime)) + (sourceFiber.lanes = currentSource.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - _workInProgress = returnFiber; + workInProgress$77 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === _workInProgress.tag)) { - var nextState = _workInProgress.memoizedState; + if ((JSCompiler_temp = 13 === workInProgress$77.tag)) { + var nextState = workInProgress$77.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = _workInProgress.memoizedProps; + var props = workInProgress$77.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -5940,23 +6188,24 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var thenables = _workInProgress.updateQueue; - if (null === thenables) { + var wakeables = workInProgress$77.updateQueue; + if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(thenable); - _workInProgress.updateQueue = updateQueue; - } else thenables.add(thenable); - if (0 === (_workInProgress.mode & 2)) { - _workInProgress.effectTag |= 64; - sourceFiber.effectTag &= -2981; + updateQueue.add(wakeable); + workInProgress$77.updateQueue = updateQueue; + } else wakeables.add(wakeable); + if (0 === (workInProgress$77.mode & 2)) { + workInProgress$77.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(1073741823, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.expirationTime = 1073741823; + sourceFiber.lanes |= 1; break a; } value = void 0; @@ -5965,86 +6214,90 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(thenable, value)) - : ((value = pingCache.get(thenable)), + pingCache.set(wakeable, value)) + : ((value = pingCache.get(wakeable)), void 0 === value && - ((value = new Set()), pingCache.set(thenable, value))); + ((value = new Set()), pingCache.set(wakeable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - thenable, + wakeable, sourceFiber ); - thenable.then(ping, ping); + wakeable.then(ping, ping); } - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; + workInProgress$77.flags |= 8192; + workInProgress$77.lanes = thrownValue; break a; } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$77 = workInProgress$77.return; + } while (null !== workInProgress$77); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); } - workInProgressRootExitStatus !== RootCompleted && - (workInProgressRootExitStatus = RootErrored); + 5 !== workInProgressRootExitStatus && + (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - _workInProgress = returnFiber; + workInProgress$77 = returnFiber; do { - switch (_workInProgress.tag) { + switch (workInProgress$77.tag) { case 3: - thenable = value; - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update = createRootErrorUpdate( - _workInProgress, - thenable, + root = value; + workInProgress$77.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$77.lanes |= thrownValue; + var update$78 = createRootErrorUpdate( + workInProgress$77, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update); + enqueueCapturedUpdate(workInProgress$77, update$78); break a; case 1: - thenable = value; - var ctor = _workInProgress.type, - instance = _workInProgress.stateNode; + root = value; + var ctor = workInProgress$77.type, + instance = workInProgress$77.stateNode; if ( - 0 === (_workInProgress.effectTag & 64) && + 0 === (workInProgress$77.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update2 = createClassErrorUpdate( - _workInProgress, - thenable, + workInProgress$77.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$77.lanes |= thrownValue; + var update$81 = createClassErrorUpdate( + workInProgress$77, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update2); + enqueueCapturedUpdate(workInProgress$77, update$81); break a; } } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$77 = workInProgress$77.return; + } while (null !== workInProgress$77); } - workInProgress = completeUnitOfWork(workInProgress); + completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; + workInProgress === erroredWork && + null !== erroredWork && + (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$2.current; + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } function pushInteractions(root) { @@ -6052,28 +6305,13 @@ function pushInteractions(root) { tracing.__interactionsRef.current = root.memoizedInteractions; return prevInteractions; } -function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { - expirationTime < workInProgressRootLatestProcessedExpirationTime && - 2 < expirationTime && - (workInProgressRootLatestProcessedExpirationTime = expirationTime); - null !== suspenseConfig && - expirationTime < workInProgressRootLatestSuspenseTimeout && - 2 < expirationTime && - ((workInProgressRootLatestSuspenseTimeout = expirationTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); -} -function markUnprocessedUpdateTime(expirationTime) { - expirationTime > workInProgressRootNextUnprocessedUpdateTime && - (workInProgressRootNextUnprocessedUpdateTime = expirationTime); -} -function renderRootSync(root, expirationTime) { +function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= RenderContext; + executionContext |= 16; var prevDispatcher = pushDispatcher(); - if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) - prepareFreshStack(root, expirationTime), - startWorkOnPendingInteractions(root, expirationTime); - expirationTime = pushInteractions(root); + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) + prepareFreshStack(root, lanes), startWorkOnPendingInteractions(root, lanes); + lanes = pushInteractions(root); do try { workLoopSync(); @@ -6083,187 +6321,197 @@ function renderRootSync(root, expirationTime) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = expirationTime; + tracing.__interactionsRef.current = lanes; executionContext = prevExecutionContext; - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher$2.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; + workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) - workInProgress = performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) performUnitOfWork(workInProgress); } function workLoopConcurrent() { for (; null !== workInProgress && !Scheduler_shouldYield(); ) - workInProgress = performUnitOfWork(workInProgress); + performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; 0 !== (unitOfWork.mode & 8) ? ((profilerStartTime = now$1()), 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), - (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)), + (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)), stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0)) - : (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)); + : (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current && (current = completeUnitOfWork(unitOfWork)); + null === current + ? completeUnitOfWork(unitOfWork) + : (workInProgress = current); ReactCurrentOwner$2.current = null; - return current; } function completeUnitOfWork(unitOfWork) { - workInProgress = unitOfWork; + var completedWork = unitOfWork; do { - var current = workInProgress.alternate; - unitOfWork = workInProgress.return; - if (0 === (workInProgress.effectTag & 2048)) { - if (0 === (workInProgress.mode & 8)) - current = completeWork(current, workInProgress, renderExpirationTime$1); + var current = completedWork.alternate; + unitOfWork = completedWork.return; + if (0 === (completedWork.flags & 4096)) { + if (0 === (completedWork.mode & 8)) + current = completeWork(current, completedWork, subtreeRenderLanes); else { - var fiber = workInProgress; + var fiber = completedWork; profilerStartTime = now$1(); 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); - current = completeWork(current, workInProgress, renderExpirationTime$1); - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + current = completeWork(current, completedWork, subtreeRenderLanes); + stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); + } + if (null !== current) { + workInProgress = current; + return; } - fiber = workInProgress; - if (1 === renderExpirationTime$1 || 1 !== fiber.childExpirationTime) { - var newChildExpirationTime = 0; - if (0 !== (fiber.mode & 8)) { + current = completedWork; + if ( + (24 !== current.tag && 23 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) + ) { + fiber = 0; + if (0 !== (current.mode & 8)) { for ( - var actualDuration = fiber.actualDuration, - treeBaseDuration = fiber.selfBaseDuration, + var actualDuration = current.actualDuration, + treeBaseDuration = current.selfBaseDuration, shouldBubbleActualDurations = - null === fiber.alternate || - fiber.child !== fiber.alternate.child, - child = fiber.child; + null === current.alternate || + current.child !== current.alternate.child, + child = current.child; null !== child; - ) { - var childUpdateExpirationTime = child.expirationTime, - childChildExpirationTime = child.childExpirationTime; - childUpdateExpirationTime > newChildExpirationTime && - (newChildExpirationTime = childUpdateExpirationTime); - childChildExpirationTime > newChildExpirationTime && - (newChildExpirationTime = childChildExpirationTime); - shouldBubbleActualDurations && - (actualDuration += child.actualDuration); - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; - } - fiber.actualDuration = actualDuration; - fiber.treeBaseDuration = treeBaseDuration; + ) + (fiber |= child.lanes | child.childLanes), + shouldBubbleActualDurations && + (actualDuration += child.actualDuration), + (treeBaseDuration += child.treeBaseDuration), + (child = child.sibling); + 13 === current.tag && + null !== current.memoizedState && + ((shouldBubbleActualDurations = current.child), + null !== shouldBubbleActualDurations && + (treeBaseDuration -= + shouldBubbleActualDurations.treeBaseDuration)); + current.actualDuration = actualDuration; + current.treeBaseDuration = treeBaseDuration; } else - for (actualDuration = fiber.child; null !== actualDuration; ) - (treeBaseDuration = actualDuration.expirationTime), - (shouldBubbleActualDurations = - actualDuration.childExpirationTime), - treeBaseDuration > newChildExpirationTime && - (newChildExpirationTime = treeBaseDuration), - shouldBubbleActualDurations > newChildExpirationTime && - (newChildExpirationTime = shouldBubbleActualDurations), + for (actualDuration = current.child; null !== actualDuration; ) + (fiber |= actualDuration.lanes | actualDuration.childLanes), (actualDuration = actualDuration.sibling); - fiber.childExpirationTime = newChildExpirationTime; + current.childLanes = fiber; } - if (null !== current) return current; null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = workInProgress.firstEffect), - null !== workInProgress.lastEffect && + (unitOfWork.firstEffect = completedWork.firstEffect), + null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), - (unitOfWork.lastEffect = workInProgress.lastEffect)), - 1 < workInProgress.effectTag && + (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), + (unitOfWork.lastEffect = completedWork.lastEffect)), + 1 < completedWork.flags && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = workInProgress) - : (unitOfWork.firstEffect = workInProgress), - (unitOfWork.lastEffect = workInProgress))); + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { - current = unwindWork(workInProgress); - if (0 !== (workInProgress.mode & 8)) { - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - fiber = workInProgress.actualDuration; - for ( - newChildExpirationTime = workInProgress.child; - null !== newChildExpirationTime; - - ) - (fiber += newChildExpirationTime.actualDuration), - (newChildExpirationTime = newChildExpirationTime.sibling); - workInProgress.actualDuration = fiber; + current = unwindWork(completedWork); + if (null !== current) { + current.flags &= 4095; + workInProgress = current; + return; + } + if (0 !== (completedWork.mode & 8)) { + stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); + current = completedWork.actualDuration; + for (fiber = completedWork.child; null !== fiber; ) + (current += fiber.actualDuration), (fiber = fiber.sibling); + completedWork.actualDuration = current; } - if (null !== current) return (current.effectTag &= 2047), current; null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } - current = workInProgress.sibling; - if (null !== current) return current; - workInProgress = unitOfWork; - } while (null !== workInProgress); - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootCompleted); - return null; -} -function getRemainingExpirationTime(fiber) { - var updateExpirationTime = fiber.expirationTime; - fiber = fiber.childExpirationTime; - return updateExpirationTime > fiber ? updateExpirationTime : fiber; + completedWork = completedWork.sibling; + if (null !== completedWork) { + workInProgress = completedWork; + return; + } + workInProgress = completedWork = unitOfWork; + } while (null !== completedWork); + 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { +function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - var finishedWork = root$jscomp$1.finishedWork, - expirationTime = root$jscomp$1.finishedExpirationTime; + var finishedWork = root.finishedWork, + lanes = root.finishedLanes; if (null === finishedWork) return null; - root$jscomp$1.finishedWork = null; - root$jscomp$1.finishedExpirationTime = 0; - if (finishedWork === root$jscomp$1.current) + root.finishedWork = null; + root.finishedLanes = 0; + if (finishedWork === root.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root$jscomp$1.callbackNode = null; - root$jscomp$1.callbackExpirationTime = 0; - root$jscomp$1.callbackPriority = 90; - root$jscomp$1.nextKnownPendingLevel = 0; - var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( - finishedWork - ); - root$jscomp$1.firstPendingTime = remainingExpirationTimeBeforeCommit; - expirationTime <= root$jscomp$1.lastSuspendedTime - ? (root$jscomp$1.firstSuspendedTime = root$jscomp$1.lastSuspendedTime = root$jscomp$1.nextKnownPendingLevel = 0) - : expirationTime <= root$jscomp$1.firstSuspendedTime && - (root$jscomp$1.firstSuspendedTime = expirationTime - 1); - expirationTime <= root$jscomp$1.lastPingedTime && - (root$jscomp$1.lastPingedTime = 0); - expirationTime <= root$jscomp$1.lastExpiredTime && - (root$jscomp$1.lastExpiredTime = 0); - root$jscomp$1 === workInProgressRoot && + root.callbackNode = null; + var remainingLanes = finishedWork.lanes | finishedWork.childLanes, + remainingLanes$jscomp$0 = remainingLanes, + noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; + root.pendingLanes = remainingLanes$jscomp$0; + root.suspendedLanes = 0; + root.pingedLanes = 0; + root.expiredLanes &= remainingLanes$jscomp$0; + root.mutableReadLanes &= remainingLanes$jscomp$0; + root.entangledLanes &= remainingLanes$jscomp$0; + remainingLanes$jscomp$0 = root.entanglements; + for ( + var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; + 0 < noLongerPendingLanes; + + ) { + var index$10 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$10; + remainingLanes$jscomp$0[index$10] = 0; + eventTimes[index$10] = -1; + expirationTimes[index$10] = -1; + noLongerPendingLanes &= ~lane; + } + null !== rootsWithPendingDiscreteUpdates && + 0 === (remainingLanes & 24) && + rootsWithPendingDiscreteUpdates.has(root) && + rootsWithPendingDiscreteUpdates.delete(root); + root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (renderExpirationTime$1 = 0)); - 1 < finishedWork.effectTag + (workInProgressRootRenderLanes = 0)); + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (remainingExpirationTimeBeforeCommit = finishedWork) - : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); - if (null !== remainingExpirationTimeBeforeCommit) { - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - var prevInteractions = pushInteractions(root$jscomp$1); - ReactCurrentOwner$2.current = null; - nextEffect = remainingExpirationTimeBeforeCommit; + (remainingLanes = finishedWork.firstEffect)) + : (remainingLanes = finishedWork) + : (remainingLanes = finishedWork.firstEffect); + if (null !== remainingLanes) { + remainingLanes$jscomp$0 = executionContext; + executionContext |= 32; + eventTimes = pushInteractions(root); + focusedInstanceHandle = ReactCurrentOwner$2.current = null; + shouldFireAfterActiveInstanceBlur = !1; + nextEffect = remainingLanes; do try { commitBeforeMutationEffects(); @@ -6273,18 +6521,14 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); + focusedInstanceHandle = null; commitTime = now$1(); - nextEffect = remainingExpirationTimeBeforeCommit; + nextEffect = remainingLanes; do try { - for ( - var root = root$jscomp$1, - renderPriorityLevel = renderPriorityLevel$jscomp$1; - null !== nextEffect; - - ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + for (; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6294,82 +6538,138 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: commitWork(nextEffect.alternate, nextEffect); break; case 8: - var current$jscomp$0 = nextEffect; - a: for ( - var finishedRoot = root, - root$jscomp$0 = current$jscomp$0, - renderPriorityLevel$jscomp$0 = renderPriorityLevel, - node = root$jscomp$0; - ; - - ) + expirationTimes = nextEffect; + a: for (index$10 = noLongerPendingLanes = expirationTimes; ; ) { + lane = index$10; if ( - (commitUnmount( - finishedRoot, - node, - renderPriorityLevel$jscomp$0 - ), - null !== node.child) + injectedHook && + "function" === typeof injectedHook.onCommitFiberUnmount ) - (node.child.return = node), (node = node.child); + try { + injectedHook.onCommitFiberUnmount(rendererID, lane); + } catch (err) {} + switch (lane.tag) { + case 0: + case 11: + case 14: + case 15: + case 22: + var updateQueue = lane.updateQueue; + if (null !== updateQueue) { + var lastEffect = updateQueue.lastEffect; + if (null !== lastEffect) { + var firstEffect = lastEffect.next, + effect = firstEffect; + do { + var _effect2 = effect, + destroy = _effect2.destroy, + tag = _effect2.tag; + if (void 0 !== destroy) + if (0 !== (tag & 4)) + enqueuePendingPassiveHookEffectUnmount( + lane, + effect + ); + else { + _effect2 = lane; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(_effect2, error); + } + } + effect = effect.next; + } while (effect !== firstEffect); + } + } + break; + case 1: + safelyDetachRef(lane); + var instance = lane.stateNode; + if ("function" === typeof instance.componentWillUnmount) + try { + (effect = lane), + (_effect2 = instance), + (_effect2.props = effect.memoizedProps), + (_effect2.state = effect.memoizedState), + _effect2.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(lane, unmountError); + } + break; + case 5: + safelyDetachRef(lane); + break; + case 4: + createChildNodeSet(lane.stateNode.containerInfo); + } + if (null !== index$10.child) + (index$10.child.return = index$10), + (index$10 = index$10.child); else { - if (node === root$jscomp$0) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === root$jscomp$0) + if (index$10 === noLongerPendingLanes) break; + for (; null === index$10.sibling; ) { + if ( + null === index$10.return || + index$10.return === noLongerPendingLanes + ) break a; - node = node.return; + index$10 = index$10.return; } - node.sibling.return = node.return; - node = node.sibling; + index$10.sibling.return = index$10.return; + index$10 = index$10.sibling; } - detachFiber(current$jscomp$0); + } + var alternate = expirationTimes.alternate; + detachFiberMutation(expirationTimes); + null !== alternate && detachFiberMutation(alternate); } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$90) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$90); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root$jscomp$1.current = finishedWork; - nextEffect = remainingExpirationTimeBeforeCommit; + root.current = finishedWork; + nextEffect = remainingLanes; do try { - for (effectTag = root$jscomp$1; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance = nextEffect.stateNode; + var instance$jscomp$0 = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current = instance.canonical; + current = instance$jscomp$0.canonical; break; default: - current = instance; + current = instance$jscomp$0; } "function" === typeof ref ? ref(current) @@ -6378,73 +6678,89 @@ function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$91) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$91); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - tracing.__interactionsRef.current = prevInteractions; - executionContext = prevExecutionContext; - } else (root$jscomp$1.current = finishedWork), (commitTime = now$1()); - if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects)) + tracing.__interactionsRef.current = eventTimes; + executionContext = remainingLanes$jscomp$0; + } else (root.current = finishedWork), (commitTime = now$1()); + if ((flags$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root$jscomp$1), - (pendingPassiveEffectsExpirationTime = expirationTime), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$1); + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsLanes = lanes), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel); else - for ( - nextEffect = remainingExpirationTimeBeforeCommit; - null !== nextEffect; - - ) - (renderPriorityLevel$jscomp$1 = nextEffect.nextEffect), + for (nextEffect = remainingLanes; null !== nextEffect; ) + (ref = nextEffect.nextEffect), (nextEffect.nextEffect = null), - (nextEffect = renderPriorityLevel$jscomp$1); - renderPriorityLevel$jscomp$1 = root$jscomp$1.firstPendingTime; - if (0 !== renderPriorityLevel$jscomp$1) { + nextEffect.flags & 8 && + ((instance$jscomp$0 = nextEffect), + (instance$jscomp$0.sibling = null), + (instance$jscomp$0.stateNode = null)), + (nextEffect = ref); + remainingLanes = root.pendingLanes; + if (0 !== remainingLanes) { if (null !== spawnedWorkDuringRender) for ( - remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, + ref = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - ref = 0; - ref < remainingExpirationTimeBeforeCommit.length; - ref++ + instance$jscomp$0 = 0; + instance$jscomp$0 < ref.length; + instance$jscomp$0++ ) scheduleInteractions( - root$jscomp$1, - remainingExpirationTimeBeforeCommit[ref], - root$jscomp$1.memoizedInteractions + root, + ref[instance$jscomp$0], + root.memoizedInteractions ); - schedulePendingInteractions(root$jscomp$1, renderPriorityLevel$jscomp$1); + schedulePendingInteractions(root, remainingLanes); } else legacyErrorBoundariesThatAlreadyFailed = null; - effectTag$jscomp$0 || - finishPendingInteractions(root$jscomp$1, expirationTime); - 1073741823 === renderPriorityLevel$jscomp$1 - ? root$jscomp$1 === rootWithNestedUpdates + flags$jscomp$0 || finishPendingInteractions(root, lanes); + 1 === remainingLanes + ? root === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$1)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode, expirationTime); - ensureRootIsScheduled(root$jscomp$1); + finishedWork = finishedWork.stateNode; + if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) + try { + injectedHook.onCommitFiberRoot( + rendererID, + finishedWork, + renderPriorityLevel, + 64 === (finishedWork.current.flags & 64) + ); + } catch (err) {} + ensureRootIsScheduled(root, now()); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root$jscomp$1 = firstUncaughtError), + (root = firstUncaughtError), (firstUncaughtError = null), - root$jscomp$1); - if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; + root); + if (0 !== (executionContext & 8)) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); - 0 === (effectTag & 512) || + var current = nextEffect.alternate; + shouldFireAfterActiveInstanceBlur || + null === focusedInstanceHandle || + (0 !== (nextEffect.flags & 8) + ? doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0) + : 13 === nextEffect.tag && + isSuspenseBoundaryBeingHidden(current, nextEffect) && + doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0)); + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -6463,56 +6779,87 @@ function flushPassiveEffects() { pendingPassiveEffectsRenderPriority = 90; return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } + return !1; +} +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects, - expirationTime = pendingPassiveEffectsExpirationTime; + lanes = pendingPassiveEffectsLanes; rootWithPendingPassiveEffects = null; - pendingPassiveEffectsExpirationTime = 0; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + pendingPassiveEffectsLanes = 0; + if (0 !== (executionContext & 48)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= CommitContext; - for ( - var prevInteractions = pushInteractions(root), - _effect2 = root.current.firstEffect; - null !== _effect2; - - ) { + executionContext |= 32; + var prevInteractions = pushInteractions(root), + unmountEffects = pendingPassiveHookEffectsUnmount; + pendingPassiveHookEffectsUnmount = []; + for (var i = 0; i < unmountEffects.length; i += 2) { + var effect$96 = unmountEffects[i], + fiber = unmountEffects[i + 1], + destroy = effect$96.destroy; + effect$96.destroy = void 0; + if ("function" === typeof destroy) + try { + destroy(); + } catch (error) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error); + } + } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$96 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; try { - var finishedWork = _effect2; - if (0 !== (finishedWork.effectTag & 512)) - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - case 22: - commitHookEffectListUnmount(5, finishedWork), - commitHookEffectListMount(5, finishedWork); - } - } catch (error) { - if (null === _effect2) throw Error("Should be working on an effect."); - captureCommitPhaseError(_effect2, error); + var create$100 = effect$96.create; + effect$96.destroy = create$100(); + } catch (error$101) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error$101); } - finishedWork = _effect2.nextEffect; - _effect2.nextEffect = null; - _effect2 = finishedWork; } + for (unmountEffects = root.current.firstEffect; null !== unmountEffects; ) + (create$100 = unmountEffects.nextEffect), + (unmountEffects.nextEffect = null), + unmountEffects.flags & 8 && + ((unmountEffects.sibling = null), (unmountEffects.stateNode = null)), + (unmountEffects = create$100); tracing.__interactionsRef.current = prevInteractions; - finishPendingInteractions(root, expirationTime); + finishPendingInteractions(root, lanes); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); enqueueUpdate(rootFiber, sourceFiber); - rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + sourceFiber = requestEventTime(); + rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); null !== rootFiber && - (ensureRootIsScheduled(rootFiber), - schedulePendingInteractions(rootFiber, 1073741823)); + (markRootUpdated(rootFiber, 1, sourceFiber), + ensureRootIsScheduled(rootFiber, sourceFiber), + schedulePendingInteractions(rootFiber, 1)); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -6531,158 +6878,176 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); - null !== fiber && - (ensureRootIsScheduled(fiber), - schedulePendingInteractions(fiber, 1073741823)); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); + fiber = markUpdateLaneFromFiberToRoot(fiber, 1); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update), + schedulePendingInteractions(fiber, 1); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, thenable, suspendedTime) { +function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - workInProgressRoot === root && renderExpirationTime$1 === suspendedTime - ? workInProgressRootExitStatus === RootSuspendedWithDelay || - (workInProgressRootExitStatus === RootSuspended && - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) - ? prepareFreshStack(root, renderExpirationTime$1) - : (workInProgressRootHasPendingPing = !0) - : isRootSuspendedAtTime(root, suspendedTime) && - ((thenable = root.lastPingedTime), - (0 !== thenable && thenable < suspendedTime) || - ((root.lastPingedTime = suspendedTime), - ensureRootIsScheduled(root), - schedulePendingInteractions(root, suspendedTime))); -} -function resolveRetryThenable(boundaryFiber, thenable) { + null !== pingCache && pingCache.delete(wakeable); + wakeable = requestEventTime(); + root.pingedLanes |= root.suspendedLanes & pingedLanes; + workInProgressRoot === root && + (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && + (4 === workInProgressRootExitStatus || + (3 === workInProgressRootExitStatus && + (workInProgressRootRenderLanes & 62914560) === + workInProgressRootRenderLanes && + 500 > now() - globalMostRecentFallbackTime) + ? prepareFreshStack(root, 0) + : (workInProgressRootPingedLanes |= pingedLanes)); + ensureRootIsScheduled(root, wakeable); + schedulePendingInteractions(root, pingedLanes); +} +function resolveRetryWakeable(boundaryFiber, wakeable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(thenable); - thenable = 0; - 0 === thenable && - ((thenable = requestCurrentTimeForUpdate()), - (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); - boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); + null !== retryCache && retryCache.delete(wakeable); + wakeable = 0; + 0 === wakeable && + ((wakeable = boundaryFiber.mode), + 0 === (wakeable & 2) + ? (wakeable = 1) + : 0 === (wakeable & 4) + ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); + retryCache = requestEventTime(); + boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); null !== boundaryFiber && - (ensureRootIsScheduled(boundaryFiber), - schedulePendingInteractions(boundaryFiber, thenable)); + (markRootUpdated(boundaryFiber, wakeable, retryCache), + ensureRootIsScheduled(boundaryFiber, retryCache), + schedulePendingInteractions(boundaryFiber, wakeable)); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; +beginWork$1 = function(current, workInProgress, renderLanes) { + var updateLanes = workInProgress.lanes; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (updateExpirationTime < renderExpirationTime) { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case 10: + updateLanes = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue2); + context._currentValue2 = updateLanes; + break; + case 12: + 0 !== (renderLanes & workInProgress.childLanes) && + (workInProgress.flags |= 4); + updateLanes = workInProgress.stateNode; + updateLanes.effectDuration = 0; + updateLanes.passiveEffectDuration = 0; + break; + case 13: + if (null !== workInProgress.memoizedState) { + if (0 !== (renderLanes & workInProgress.child.childLanes)) + return updateSuspenseComponent( + current, + workInProgress, + renderLanes + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( + current, workInProgress, - workInProgress.stateNode.containerInfo + renderLanes ); - break; - case 10: - updateExpirationTime = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue2); - context._currentValue2 = updateExpirationTime; - break; - case 12: - workInProgress.childExpirationTime >= renderExpirationTime && - (workInProgress.effectTag |= 4); - updateExpirationTime = workInProgress.stateNode; - updateExpirationTime.effectDuration = 0; - updateExpirationTime.passiveEffectDuration = 0; - break; - case 13: - if (null !== workInProgress.memoizedState) { - updateExpirationTime = workInProgress.child.childExpirationTime; - if ( - 0 !== updateExpirationTime && - updateExpirationTime >= renderExpirationTime - ) - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateLanes = 0 !== (renderLanes & workInProgress.childLanes); + if (0 !== (current.flags & 64)) { + if (updateLanes) + return updateSuspenseListComponent( current, workInProgress, - renderExpirationTime + renderLanes ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateExpirationTime = - workInProgress.childExpirationTime >= renderExpirationTime; - if (0 !== (current.effectTag & 64)) { - if (updateExpirationTime) - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), (context.tail = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (!updateExpirationTime) return null; - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + workInProgress.flags |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), + (context.tail = null), + (context.lastEffect = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (updateLanes) break; + else return null; + case 23: + case 24: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; - workInProgress.expirationTime = 0; + workInProgress.lanes = 0; switch (workInProgress.tag) { case 2: - updateExpirationTime = workInProgress.type; + updateLanes = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); context = renderWithHooks( null, workInProgress, - updateExpirationTime, + updateLanes, current, context, - renderExpirationTime + renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -6692,7 +7057,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateExpirationTime)) { + if (isContextProvider(updateLanes)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -6701,53 +7066,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = - updateExpirationTime.getDerivedStateFromProps; + var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateExpirationTime, + updateLanes, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternalFiber = workInProgress; - mountClassInstance( - workInProgress, - updateExpirationTime, - current, - renderExpirationTime - ); + context._reactInternals = workInProgress; + mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, hasContext, - renderExpirationTime + renderLanes ); } else (workInProgress.tag = 0), - reconcileChildren( - null, - workInProgress, - context, - renderExpirationTime - ), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: + context = workInProgress.elementType; a: { - context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - initializeLazyComponentType(context); - if (1 !== context._status) throw context._result; - context = context._result; + hasContext = context._init; + context = hasContext(context._payload); workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -6758,7 +7111,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 1: @@ -6767,7 +7120,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 11: @@ -6776,7 +7129,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 14: @@ -6785,8 +7138,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, resolveDefaultProps(context.type, current), - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); break a; } @@ -6799,126 +7152,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return workInProgress; case 0: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 1: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 3: pushHostRootContext(workInProgress); - updateExpirationTime = workInProgress.updateQueue; - if (null === current || null === updateExpirationTime) + updateLanes = workInProgress.updateQueue; + if (null === current || null === updateLanes) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); - updateExpirationTime = workInProgress.pendingProps; + updateLanes = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue( - workInProgress, - updateExpirationTime, - null, - renderExpirationTime - ); - updateExpirationTime = workInProgress.memoizedState.element; - updateExpirationTime === context + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes )) - : (reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (updateLanes = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child), - workInProgress + reconcileChildren(current, workInProgress, updateLanes, renderLanes), + workInProgress.child ); case 6: return null; case 13: - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseComponent(current, workInProgress, renderLanes); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (updateLanes = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes )) : reconcileChildren( current, workInProgress, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ), workInProgress.child ); case 11: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 7: @@ -6927,7 +7260,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps, - renderExpirationTime + renderLanes ), workInProgress.child ); @@ -6937,27 +7270,27 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); case 12: return ( - (workInProgress.effectTag |= 4), - (updateExpirationTime = workInProgress.stateNode), - (updateExpirationTime.effectDuration = 0), - (updateExpirationTime.passiveEffectDuration = 0), + (workInProgress.flags |= 4), + (updateLanes = workInProgress.stateNode), + (updateLanes.effectDuration = 0), + (updateLanes.passiveEffectDuration = 0), reconcileChildren( current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); case 10: a: { - updateExpirationTime = workInProgress.type._context; + updateLanes = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -6969,9 +7302,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( context$jscomp$0, hasContext ) @@ -6985,7 +7317,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); break a; } @@ -7006,25 +7338,24 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ) { if ( - dependency.context === updateExpirationTime && + dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate(renderExpirationTime, null)), + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.expirationTime < renderExpirationTime && - (context$jscomp$0.expirationTime = renderExpirationTime); + context$jscomp$0.lanes |= renderLanes; dependency = context$jscomp$0.alternate; - null !== dependency && - dependency.expirationTime < renderExpirationTime && - (dependency.expirationTime = renderExpirationTime); + null !== dependency && (dependency.lanes |= renderLanes); scheduleWorkOnParentPath( context$jscomp$0.return, - renderExpirationTime + renderLanes ); - list.expirationTime < renderExpirationTime && - (list.expirationTime = renderExpirationTime); + list.lanes |= renderLanes; break; } dependency = dependency.next; @@ -7062,7 +7393,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, context.children, - renderExpirationTime + renderLanes ); workInProgress = workInProgress.child; } @@ -7071,17 +7402,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateExpirationTime = hasContext.children), - prepareToReadContext(workInProgress, renderExpirationTime), + (updateLanes = hasContext.children), + prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(context)), - (workInProgress.effectTag |= 1), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + (updateLanes = updateLanes(context)), + (workInProgress.flags |= 1), + reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: @@ -7097,8 +7423,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, hasContext, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); case 15: @@ -7107,48 +7433,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); case 17: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), - isContextProvider(updateExpirationTime) + isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderExpirationTime), - constructClassInstance(workInProgress, updateExpirationTime, context), - mountClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), + prepareToReadContext(workInProgress, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, current, - renderExpirationTime + renderLanes ) ); case 19: - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseListComponent(current, workInProgress, renderLanes); + case 23: + return updateOffscreenComponent(current, workInProgress, renderLanes); + case 24: + return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( "Unknown unit of work tag (" + @@ -7156,16 +7477,21 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { "). This error is likely caused by a bug in React. Please file an issue." ); }; -function scheduleInteractions(root, expirationTime, interactions) { +function markSpawnedWork(lane) { + null === spawnedWorkDuringRender + ? (spawnedWorkDuringRender = [lane]) + : spawnedWorkDuringRender.push(lane); +} +function scheduleInteractions(root, lane, interactions) { if (0 < interactions.size) { var pendingInteractionMap = root.pendingInteractionMap, - pendingInteractions = pendingInteractionMap.get(expirationTime); + pendingInteractions = pendingInteractionMap.get(lane); null != pendingInteractions ? interactions.forEach(function(interaction) { pendingInteractions.has(interaction) || interaction.__count++; pendingInteractions.add(interaction); }) - : (pendingInteractionMap.set(expirationTime, new Set(interactions)), + : (pendingInteractionMap.set(lane, new Set(interactions)), interactions.forEach(function(interaction) { interaction.__count++; })); @@ -7173,20 +7499,20 @@ function scheduleInteractions(root, expirationTime, interactions) { if (null !== pendingInteractionMap) pendingInteractionMap.onWorkScheduled( interactions, - 1e3 * expirationTime + root.interactionThreadID + 1e3 * lane + root.interactionThreadID ); } } -function schedulePendingInteractions(root, expirationTime) { - scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); +function schedulePendingInteractions(root, lane) { + scheduleInteractions(root, lane, tracing.__interactionsRef.current); } -function startWorkOnPendingInteractions(root, expirationTime) { +function startWorkOnPendingInteractions(root, lanes) { var interactions = new Set(); root.pendingInteractionMap.forEach(function( scheduledInteractions, - scheduledExpirationTime + scheduledLane ) { - scheduledExpirationTime >= expirationTime && + 0 !== (lanes & scheduledLane) && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -7195,7 +7521,7 @@ function startWorkOnPendingInteractions(root, expirationTime) { if (0 < interactions.size) { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber) { - root = 1e3 * expirationTime + root.interactionThreadID; + root = 1e3 * lanes + root.interactionThreadID; try { subscriber.onWorkStarted(interactions, root); } catch (error) { @@ -7206,14 +7532,14 @@ function startWorkOnPendingInteractions(root, expirationTime) { } } } -function finishPendingInteractions(root, committedExpirationTime) { - var earliestRemainingTimeAfterCommit = root.firstPendingTime; +function finishPendingInteractions(root, committedLanes) { + var remainingLanesAfterCommit = root.pendingLanes; try { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber && 0 < root.memoizedInteractions.size) subscriber.onWorkStopped( root.memoizedInteractions, - 1e3 * committedExpirationTime + root.interactionThreadID + 1e3 * committedLanes + root.interactionThreadID ); } catch (error) { scheduleCallback(99, function() { @@ -7221,54 +7547,23 @@ function finishPendingInteractions(root, committedExpirationTime) { }); } finally { var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - scheduledExpirationTime > earliestRemainingTimeAfterCommit && - (pendingInteractionMap.delete(scheduledExpirationTime), + pendingInteractionMap.forEach(function(scheduledInteractions, lane) { + 0 === (remainingLanesAfterCommit & lane) && + (pendingInteractionMap.delete(lane), scheduledInteractions.forEach(function(interaction) { interaction.__count--; if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { + } catch (error$102) { scheduleCallback(99, function() { - throw error; + throw error$102; }); } })); }); } } -var onCommitFiberRoot = null, - onCommitFiberUnmount = null, - isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__; -function injectInternals(internals) { - if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (hook.isDisabled || !hook.supportsFiber) return !0; - try { - var rendererID = hook.inject(internals); - onCommitFiberRoot = function(root, expirationTime) { - try { - var didError = 64 === (root.current.effectTag & 64), - currentTime = 1073741821 - ((now() / 10) | 0), - priorityLevel = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); - hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); - } catch (err) {} - }; - onCommitFiberUnmount = function(fiber) { - try { - hook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) {} - }; - } catch (err) {} - return !0; -} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7278,14 +7573,17 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childExpirationTime = this.expirationTime = 0; + this.childLanes = this.lanes = 0; this.alternate = null; this.actualDuration = 0; this.actualStartTime = -1; this.treeBaseDuration = this.selfBaseDuration = 0; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); @@ -7303,7 +7601,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, @@ -7315,14 +7613,15 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.effectTag = 0), + (workInProgress.type = current.type), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7331,11 +7630,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.dependencies = null === pendingProps ? null - : { - expirationTime: pendingProps.expirationTime, - firstContext: pendingProps.firstContext, - responders: pendingProps.responders - }; + : { lanes: pendingProps.lanes, firstContext: pendingProps.firstContext }; workInProgress.sibling = current.sibling; workInProgress.index = current.index; workInProgress.ref = current.ref; @@ -7349,7 +7644,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - expirationTime + lanes ) { var fiberTag = 2; owner = type; @@ -7358,15 +7653,10 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment( - pendingProps.children, - mode, - expirationTime, - key - ); - case REACT_CONCURRENT_MODE_TYPE: + return createFiberFromFragment(pendingProps.children, mode, lanes, key); + case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 7; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7374,26 +7664,35 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(12, pendingProps, key, mode | 8)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), (type.stateNode = { effectDuration: 0, passiveEffectDuration: 0 }), type ); case REACT_SUSPENSE_TYPE: return ( - (type = new FiberNode(13, pendingProps, key, mode)), + (type = createFiber(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = new FiberNode(19, pendingProps, key, mode)), + (type = createFiber(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), + type + ); + case REACT_OFFSCREEN_TYPE: + return createFiberFromOffscreen(pendingProps, mode, lanes, key); + case REACT_LEGACY_HIDDEN_TYPE: + return ( + (type = createFiber(24, pendingProps, key, mode)), + (type.elementType = REACT_LEGACY_HIDDEN_TYPE), + (type.lanes = lanes), type ); default: @@ -7425,30 +7724,36 @@ function createFiberFromTypeAndProps( "." ); } - key = new FiberNode(fiberTag, pendingProps, key, mode); + key = createFiber(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.expirationTime = expirationTime; + key.lanes = lanes; return key; } -function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(7, elements, key, mode); - elements.expirationTime = expirationTime; +function createFiberFromFragment(elements, mode, lanes, key) { + elements = createFiber(7, elements, key, mode); + elements.lanes = lanes; return elements; } -function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); - content.expirationTime = expirationTime; +function createFiberFromOffscreen(pendingProps, mode, lanes, key) { + pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps.elementType = REACT_OFFSCREEN_TYPE; + pendingProps.lanes = lanes; + return pendingProps; +} +function createFiberFromText(content, mode, lanes) { + content = createFiber(6, content, null, mode); + content.lanes = lanes; return content; } -function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( +function createFiberFromPortal(portal, mode, lanes) { + mode = createFiber( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.expirationTime = expirationTime; + mode.lanes = lanes; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -7458,54 +7763,34 @@ function createFiberFromPortal(portal, mode, expirationTime) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; - this.current = null; this.containerInfo = containerInfo; - this.pingCache = this.pendingChildren = null; - this.finishedExpirationTime = 0; - this.finishedWork = null; + this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 90; - this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; + this.callbackPriority = 0; + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); + this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; + this.entanglements = createLaneMap(0); this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } -function isRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - root = root.lastSuspendedTime; - return ( - 0 !== firstSuspendedTime && - firstSuspendedTime >= expirationTime && - root <= expirationTime - ); -} -function markRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime, - lastSuspendedTime = root.lastSuspendedTime; - firstSuspendedTime < expirationTime && - (root.firstSuspendedTime = expirationTime); - if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) - root.lastSuspendedTime = expirationTime; - expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); - expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); -} -function markRootUpdatedAtTime(root, expirationTime) { - expirationTime > root.firstPendingTime && - (root.firstPendingTime = expirationTime); - var firstSuspendedTime = root.firstSuspendedTime; - 0 !== firstSuspendedTime && - (expirationTime >= firstSuspendedTime - ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) - : expirationTime >= root.lastSuspendedTime && - (root.lastSuspendedTime = expirationTime + 1), - expirationTime > root.nextKnownPendingLevel && - (root.nextKnownPendingLevel = expirationTime)); +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findHostInstance(component) { - var fiber = component._reactInternalFiber; + var fiber = component._reactInternals; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -7519,11 +7804,10 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); + eventTime = requestEventTime(), + lane = requestUpdateLane(current); a: if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; + parentComponent = parentComponent._reactInternals; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -7532,22 +7816,23 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var parentContext = parentComponent; + var JSCompiler_inline_result = parentComponent; do { - switch (parentContext.tag) { + switch (JSCompiler_inline_result.tag) { case 3: - parentContext = parentContext.stateNode.context; + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode.context; break b; case 1: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode + if (isContextProvider(JSCompiler_inline_result.type)) { + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - parentContext = parentContext.return; - } while (null !== parentContext); + JSCompiler_inline_result = JSCompiler_inline_result.return; + } while (null !== JSCompiler_inline_result); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -7558,34 +7843,26 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - parentContext + JSCompiler_inline_result ); break a; } } - parentComponent = parentContext; + parentComponent = JSCompiler_inline_result; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(currentTime, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleWork(current, currentTime); - return currentTime; + scheduleUpdateOnFiber(current, lane, eventTime); + return lane; } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function emptyFindFiberByHostInstance() { + return null; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7607,53 +7884,70 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - executionContext === NoContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; -var roots = new Map(); -(function(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals({ - bundleType: devToolsConfig.bundleType, - version: devToolsConfig.version, - rendererPackageName: devToolsConfig.rendererPackageName, - rendererConfig: devToolsConfig.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; - }, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null - }); -})({ - findFiberByHostInstance: getInstanceFromInstance, - bundleType: 0, - version: "16.13.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } -}); +var roots = new Map(), + devToolsConfig$jscomp$inline_887 = { + findFiberByHostInstance: getInstanceFromInstance, + bundleType: 0, + version: "17.0.1-4e5d7faf5", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } + }; +var internals$jscomp$inline_1087 = { + bundleType: devToolsConfig$jscomp$inline_887.bundleType, + version: devToolsConfig$jscomp$inline_887.version, + rendererPackageName: devToolsConfig$jscomp$inline_887.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_887.rendererConfig, + overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, + overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: + devToolsConfig$jscomp$inline_887.findFiberByHostInstance || + emptyFindFiberByHostInstance, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null +}; +if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { + var hook$jscomp$inline_1088 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if ( + !hook$jscomp$inline_1088.isDisabled && + hook$jscomp$inline_1088.supportsFiber + ) + try { + (rendererID = hook$jscomp$inline_1088.inject( + internals$jscomp$inline_1087 + )), + (injectedHook = hook$jscomp$inline_1088); + } catch (err) {} +} exports.createPortal = function(children, containerTag) { return createPortal( children, @@ -7693,12 +7987,17 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var uninitializedFiber = 0; - isDevToolsPresent && (uninitializedFiber |= 8); - uninitializedFiber = new FiberNode(3, null, null, uninitializedFiber); - root.current = uninitializedFiber; - uninitializedFiber.stateNode = root; - initializeUpdateQueue(uninitializedFiber); + var JSCompiler_inline_result = 0; + isDevToolsPresent && (JSCompiler_inline_result |= 8); + JSCompiler_inline_result = createFiber( + 3, + null, + null, + JSCompiler_inline_result + ); + root.current = JSCompiler_inline_result; + JSCompiler_inline_result.stateNode = root; + initializeUpdateQueue(JSCompiler_inline_result); roots.set(containerTag, root); } updateContainer(element, root, null, callback); diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index c88a74b6a040b1..3cbae57ed62639 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -139,7 +139,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { // If document doesn't exist we know for sure we will crash in this method // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebookincubator/create-react-app/issues/3482 + // errors: https://github.com/facebook/create-react-app/issues/3482 // So we preemptively throw with a better message instead. if (!(typeof document !== "undefined")) { throw Error( @@ -263,7 +263,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; 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." + "See https://reactjs.org/link/crossorigin-error for more information." ); } @@ -806,13 +806,6 @@ addEventPoolingTo(SyntheticEvent); */ function getPooledWarningPropertyDefinition(propName, getVal) { - var isFunction = typeof getVal === "function"; - return { - configurable: true, - set: set, - get: get - }; - function set(val) { var action = isFunction ? "setting the method" : "setting the property"; warn(action, "This is effectively a no-op"); @@ -834,13 +827,20 @@ function getPooledWarningPropertyDefinition(propName, getVal) { "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", + "See https://reactjs.org/link/event-pooling for more information.", action, propName, result ); } } + + var isFunction = typeof getVal === "function"; + return { + configurable: true, + set: set, + get: get + }; } function createOrGetPooledEvent( @@ -3007,9 +3007,15 @@ function getComponentName(type) { return null; } +// The rest of the flags are static for better dead code elimination. +var enableProfilerTimer = true; +var enableFundamentalAPI = false; +var warnAboutStringRefs = false; +var enableNewReconciler = false; + // Don't change these two values. They're used by React Dev Tools. -var NoEffect = - /* */ +var NoFlags = + /* */ 0; var PerformedWork = /* */ @@ -3044,41 +3050,32 @@ var Snapshot = 256; var Passive = /* */ - 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old. - -var PassiveUnmountPendingDev = - /* */ - 8192; + 512; var Hydrating = /* */ 1024; var HydratingAndUpdate = /* */ - 1028; // Passive & Update & Callback & Ref & Snapshot - -var LifecycleEffectMask = - /* */ - 932; // Union of all host effects + 1028; +var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = /* */ - 2047; // These are not really side effects, but we still reuse this field. + 4095; // These are not really side effects, but we still reuse this field. var Incomplete = /* */ - 2048; + 4096; var ShouldCapture = /* */ - 4096; + 8192; // TODO (effects) Remove this bit once the new reconciler is synced to the old. + +var PassiveUnmountPendingDev = + /* */ + 16384; var ForceUpdateForLegacySuspense = /* */ - 16384; // Static tags describe aspects of a fiber that are not specific to a render, - -// The rest of the flags are static for better dead code elimination. -var enableProfilerTimer = true; -var enableFundamentalAPI = false; -var warnAboutStringRefs = false; -var enableNewReconciler = false; + 32768; // Static tags describe aspects of a fiber that are not specific to a render, var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -3093,7 +3090,7 @@ function getNearestMountedFiber(fiber) { do { node = nextNode; - if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((node.flags & (Placement | Hydrating)) !== NoFlags) { // This is an insertion or in-progress hydration. The nearest possible // mounted fiber is the parent but we need to continue to figure out // if that one is still mounted. @@ -3873,104 +3870,102 @@ function warnForStyleProps(props, validAttributes) { } } -var ReactNativeFiberHostComponent = - /*#__PURE__*/ - (function() { - function ReactNativeFiberHostComponent( - tag, - viewConfig, - internalInstanceHandleDEV - ) { - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; +var ReactNativeFiberHostComponent = /*#__PURE__*/ (function() { + function ReactNativeFiberHostComponent( + tag, + viewConfig, + internalInstanceHandleDEV + ) { + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; - { - this._internalFiberInstanceHandleDEV = internalInstanceHandleDEV; - } + { + this._internalFiberInstanceHandleDEV = internalInstanceHandleDEV; } + } - var _proto = ReactNativeFiberHostComponent.prototype; + var _proto = ReactNativeFiberHostComponent.prototype; - _proto.blur = function blur() { - ReactNativePrivateInterface.TextInputState.blurTextInput(this); - }; + _proto.blur = function blur() { + ReactNativePrivateInterface.TextInputState.blurTextInput(this); + }; - _proto.focus = function focus() { - ReactNativePrivateInterface.TextInputState.focusTextInput(this); - }; + _proto.focus = function focus() { + ReactNativePrivateInterface.TextInputState.focusTextInput(this); + }; - _proto.measure = function measure(callback) { - ReactNativePrivateInterface.UIManager.measure( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + _proto.measure = function measure(callback) { + ReactNativePrivateInterface.UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - _proto.measureInWindow = function measureInWindow(callback) { - ReactNativePrivateInterface.UIManager.measureInWindow( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + _proto.measureInWindow = function measureInWindow(callback) { + ReactNativePrivateInterface.UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - _proto.measureLayout = function measureLayout( - relativeToNativeNode, - onSuccess, - onFail - ) /* currently unused */ - { - var relativeNode; + _proto.measureLayout = function measureLayout( + relativeToNativeNode, + onSuccess, + onFail + ) /* currently unused */ + { + var relativeNode; - if (typeof relativeToNativeNode === "number") { - // Already a node handle - relativeNode = relativeToNativeNode; - } else { - var nativeNode = relativeToNativeNode; + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else { + var nativeNode = relativeToNativeNode; - if (nativeNode._nativeTag) { - relativeNode = nativeNode._nativeTag; - } + if (nativeNode._nativeTag) { + relativeNode = nativeNode._nativeTag; } + } - if (relativeNode == null) { - { - error( - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); - } - - return; + if (relativeNode == null) { + { + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); } - ReactNativePrivateInterface.UIManager.measureLayout( - this._nativeTag, - relativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; + return; + } - _proto.setNativeProps = function setNativeProps(nativeProps) { - { - warnForStyleProps(nativeProps, this.viewConfig.validAttributes); - } + ReactNativePrivateInterface.UIManager.measureLayout( + this._nativeTag, + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + }; - var updatePayload = create(nativeProps, this.viewConfig.validAttributes); // Avoid the overhead of bridge calls if there's no update. - // This is an expensive no-op for Android, and causes an unnecessary - // view invalidation for certain components (eg RCTTextInput) on iOS. + _proto.setNativeProps = function setNativeProps(nativeProps) { + { + warnForStyleProps(nativeProps, this.viewConfig.validAttributes); + } - if (updatePayload != null) { - ReactNativePrivateInterface.UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - updatePayload - ); - } - }; + var updatePayload = create(nativeProps, this.viewConfig.validAttributes); // Avoid the overhead of bridge calls if there's no update. + // This is an expensive no-op for Android, and causes an unnecessary + // view invalidation for certain components (eg RCTTextInput) on iOS. + + if (updatePayload != null) { + ReactNativePrivateInterface.UIManager.updateView( + this._nativeTag, + this.viewConfig.uiViewClassName, + updatePayload + ); + } + }; - return ReactNativeFiberHostComponent; - })(); // eslint-disable-next-line no-unused-expressions + return ReactNativeFiberHostComponent; +})(); // eslint-disable-next-line no-unused-expressions // can re-export everything from this module. @@ -4890,7 +4885,7 @@ function processChildContext(fiber, type, parentContext) { checkPropTypes(childContextTypes, childContext, "child context", name); } - return Object.assign({}, parentContext, {}, childContext); + return Object.assign({}, parentContext, childContext); } } @@ -5017,7 +5012,7 @@ function injectInternals(internals) { error( "The installed version of React DevTools is too old and will not work " + "with the current version of React. Please update React DevTools. " + - "https://fb.me/react-devtools" + "https://reactjs.org/link/react-devtools" ); } // DevTools exists, even though it doesn't support Fiber. @@ -5058,7 +5053,7 @@ function onScheduleRoot(root, children) { function onCommitRoot(root, priorityLevel) { if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") { try { - var didError = (root.current.effectTag & DidCapture) === DidCapture; + var didError = (root.current.flags & DidCapture) === DidCapture; if (enableProfilerTimer) { injectedHook.onCommitFiberRoot( @@ -5111,7 +5106,7 @@ var Scheduler_now = Scheduler.unstable_now; ) ) { throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); } } @@ -5127,18 +5122,16 @@ var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only var NoPriority = 90; var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. -var SyncLanePriority = 17; -var SyncBatchedLanePriority = 16; -var InputDiscreteHydrationLanePriority = 15; -var InputDiscreteLanePriority = 14; -var InputContinuousHydrationLanePriority = 13; -var InputContinuousLanePriority = 12; -var DefaultHydrationLanePriority = 11; -var DefaultLanePriority = 10; -var TransitionShortHydrationLanePriority = 9; -var TransitionShortLanePriority = 8; -var TransitionLongHydrationLanePriority = 7; -var TransitionLongLanePriority = 6; +var SyncLanePriority = 15; +var SyncBatchedLanePriority = 14; +var InputDiscreteHydrationLanePriority = 13; +var InputDiscreteLanePriority = 12; +var InputContinuousHydrationLanePriority = 11; +var InputContinuousLanePriority = 10; +var DefaultHydrationLanePriority = 9; +var DefaultLanePriority = 8; +var TransitionHydrationPriority = 7; +var TransitionPriority = 6; var RetryLanePriority = 5; var SelectiveHydrationLanePriority = 4; var IdleHydrationLanePriority = 3; @@ -5176,21 +5169,18 @@ var DefaultHydrationLane = var DefaultLanes = /* */ 3584; -var TransitionShortHydrationLane = - /* */ +var TransitionHydrationLane = + /* */ 4096; -var TransitionShortLanes = - /* */ - 122880; -var TransitionLongHydrationLane = - /* */ - 131072; -var TransitionLongLanes = - /* */ - 3932160; +var TransitionLanes = + /* */ + 4186112; var RetryLanes = /* */ 62914560; +var SomeRetryLane = + /* */ + 33554432; var SelectiveHydrationLane = /* */ 67108864; @@ -5207,7 +5197,6 @@ var OffscreenLane = /* */ 1073741824; var NoTimestamp = -1; -function setCurrentUpdateLanePriority(newLanePriority) {} // "Registers" used to "return" multiple values // Used by getHighestPriorityLanes and getNextLanes: var return_highestLanePriority = DefaultLanePriority; @@ -5259,28 +5248,16 @@ function getHighestPriorityLanes(lanes) { return defaultLanes; } - if ((lanes & TransitionShortHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionShortHydrationLanePriority; - return TransitionShortHydrationLane; - } - - var transitionShortLanes = TransitionShortLanes & lanes; - - if (transitionShortLanes !== NoLanes) { - return_highestLanePriority = TransitionShortLanePriority; - return transitionShortLanes; - } - - if ((lanes & TransitionLongHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionLongHydrationLanePriority; - return TransitionLongHydrationLane; + if ((lanes & TransitionHydrationLane) !== NoLanes) { + return_highestLanePriority = TransitionHydrationPriority; + return TransitionHydrationLane; } - var transitionLongLanes = TransitionLongLanes & lanes; + var transitionLanes = TransitionLanes & lanes; - if (transitionLongLanes !== NoLanes) { - return_highestLanePriority = TransitionLongLanePriority; - return transitionLongLanes; + if (transitionLanes !== NoLanes) { + return_highestLanePriority = TransitionPriority; + return transitionLanes; } var retryLanes = RetryLanes & lanes; @@ -5354,10 +5331,8 @@ function lanePriorityToSchedulerPriority(lanePriority) { case DefaultHydrationLanePriority: case DefaultLanePriority: - case TransitionShortHydrationLanePriority: - case TransitionShortLanePriority: - case TransitionLongHydrationLanePriority: - case TransitionLongLanePriority: + case TransitionHydrationPriority: + case TransitionPriority: case SelectiveHydrationLanePriority: case RetryLanePriority: return NormalPriority; @@ -5515,8 +5490,22 @@ function computeExpirationTime(lane, currentTime) { if (priority >= InputContinuousLanePriority) { // User interactions should expire slightly more quickly. - return currentTime + 1000; - } else if (priority >= TransitionLongLanePriority) { + // + // NOTE: This is set to the corresponding constant as in Scheduler.js. When + // we made it larger, a product metric in www regressed, suggesting there's + // a user interaction that's being starved by a series of synchronous + // updates. If that theory is correct, the proper solution is to fix the + // starvation. However, this scenario supports the idea that expiration + // times are an important safeguard when starvation does happen. + // + // Also note that, in the case of user input specifically, this will soon no + // longer be an issue because we plan to make user input synchronous by + // default (until you enter `startTransition`, of course.) + // + // If weren't planning to make these updates synchronous soon anyway, I + // would probably make this number a configurable parameter. + return currentTime + 250; + } else if (priority >= TransitionPriority) { return currentTime + 5000; } else { // Anything idle priority or lower should never expire. @@ -5582,6 +5571,9 @@ function includesNonIdleWork(lanes) { } function includesOnlyRetries(lanes) { return (lanes & RetryLanes) === lanes; +} +function includesOnlyTransitions(lanes) { + return (lanes & TransitionLanes) === lanes; } // To ensure consistency across multiple updates in the same event, this should // be a pure function, so that it always returns the same lane for given inputs. @@ -5624,9 +5616,7 @@ function findUpdateLane(lanePriority, wipLanes) { if (_lane3 === NoLane) { // If all the default lanes are already being worked on, look for a // lane in the transition range. - _lane3 = pickArbitraryLane( - (TransitionShortLanes | TransitionLongLanes) & ~wipLanes - ); + _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes); if (_lane3 === NoLane) { // All the transition lanes are taken, too. This should be very @@ -5639,9 +5629,8 @@ function findUpdateLane(lanePriority, wipLanes) { return _lane3; } - case TransitionShortLanePriority: // Should be handled by findTransitionLane instead + case TransitionPriority: // Should be handled by findTransitionLane instead - case TransitionLongLanePriority: case RetryLanePriority: // Should be handled by findRetryLane instead break; @@ -5664,54 +5653,24 @@ function findUpdateLane(lanePriority, wipLanes) { } // To ensure consistency across multiple updates in the same event, this should // be pure function, so that it always returns the same lane for given inputs. -function findTransitionLane(lanePriority, wipLanes, pendingLanes) { - if (lanePriority === TransitionShortLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var lane = pickArbitraryLane(TransitionShortLanes & ~pendingLanes); - - if (lane === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - lane = pickArbitraryLane(TransitionShortLanes & ~wipLanes); - - if (lane === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - lane = pickArbitraryLane(TransitionShortLanes); - } - } - - return lane; - } - - if (lanePriority === TransitionLongLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var _lane4 = pickArbitraryLane(TransitionLongLanes & ~pendingLanes); +function findTransitionLane(wipLanes, pendingLanes) { + // First look for lanes that are completely unclaimed, i.e. have no + // pending work. + var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); - if (_lane4 === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - _lane4 = pickArbitraryLane(TransitionLongLanes & ~wipLanes); + if (lane === NoLane) { + // If all lanes have pending work, look for a lane that isn't currently + // being worked on. + lane = pickArbitraryLane(TransitionLanes & ~wipLanes); - if (_lane4 === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - _lane4 = pickArbitraryLane(TransitionLongLanes); - } + if (lane === NoLane) { + // If everything is being worked on, pick any lane. This has the + // effect of interrupting the current work-in-progress. + lane = pickArbitraryLane(TransitionLanes); } - - return _lane4; } - { - throw Error( - "Invalid transition priority: " + - lanePriority + - ". This is a bug in React." - ); - } + return lane; } // To ensure consistency across multiple updates in the same event, this should // be pure function, so that it always returns the same lane for given inputs. @@ -5776,7 +5735,15 @@ function laneToLanes(lane) { return lane; } function createLaneMap(initial) { - return new Array(TotalLanes).fill(initial); + // Intentionally pushing one by one. + // https://v8.dev/blog/elements-kinds#avoid-creating-holes + var laneMap = []; + + for (var i = 0; i < TotalLanes; i++) { + laneMap.push(initial); + } + + return laneMap; } function markRootUpdated(root, updateLane, eventTime) { root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But @@ -5817,9 +5784,6 @@ function markRootSuspended(root, suspendedLanes) { function markRootPinged(root, pingedLanes, eventTime) { root.pingedLanes |= root.suspendedLanes & pingedLanes; } -function markRootExpired(root, expiredLanes) { - root.expiredLanes |= expiredLanes & root.pendingLanes; -} function hasDiscreteLanes(lanes) { return (lanes & InputDiscreteLanes) !== NoLanes; } @@ -5903,7 +5867,7 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, ) ) { throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); } } @@ -6032,88 +5996,40 @@ function flushSyncCallbackQueueImpl() { isFlushingSyncQueue = true; var i = 0; - try { - var _isSync = true; - var queue = syncQueue; - setCurrentUpdateLanePriority(SyncLanePriority); - runWithPriority(ImmediatePriority$1, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; - - do { - callback = callback(_isSync); - } while (callback !== null); - } - }); - syncQueue = null; - } catch (error) { - // If something throws, leave the remaining callbacks on the queue. - if (syncQueue !== null) { - syncQueue = syncQueue.slice(i + 1); - } // Resume flushing in the next tick - - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ); - throw error; - } finally { - isFlushingSyncQueue = false; + { + try { + var _isSync2 = true; + var _queue = syncQueue; + runWithPriority(ImmediatePriority$1, function() { + for (; i < _queue.length; i++) { + var callback = _queue[i]; + + do { + callback = callback(_isSync2); + } while (callback !== null); + } + }); + syncQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (syncQueue !== null) { + syncQueue = syncQueue.slice(i + 1); + } // Resume flushing in the next tick + + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ); + throw error; + } finally { + isFlushingSyncQueue = false; + } } } } -function describeFiber(fiber) { - var owner = fiber._debugOwner ? fiber._debugOwner.type : null; - var source = fiber._debugSource; - - switch (fiber.tag) { - case HostComponent: - return describeBuiltInComponentFrame(fiber.type, source, owner); - - case LazyComponent: - return describeBuiltInComponentFrame("Lazy", source, owner); - - case SuspenseComponent: - return describeBuiltInComponentFrame("Suspense", source, owner); - - case SuspenseListComponent: - return describeBuiltInComponentFrame("SuspenseList", source, owner); - - case FunctionComponent: - case IndeterminateComponent: - case SimpleMemoComponent: - return describeFunctionComponentFrame(fiber.type, source, owner); - - case ForwardRef: - return describeFunctionComponentFrame(fiber.type.render, source, owner); - - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - - case ClassComponent: - return describeClassComponentFrame(fiber.type, source, owner); - - default: - return ""; - } -} - -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - var node = workInProgress; - - do { - info += describeFiber(node); - node = node.return; - } while (node); - - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} +// TODO: this is special because it gets imported during build. +var ReactVersion = "17.0.1-4e5d7faf5"; var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root @@ -6124,6 +6040,12 @@ var ConcurrentMode = 4; var ProfileMode = 8; var DebugTracingMode = 16; +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; +var NoTransition = 0; +function requestCurrentTransition() { + return ReactCurrentBatchConfig.transition; +} + /** * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is @@ -6176,6 +6098,58 @@ function shallowEqual(objA, objB) { return true; } +function describeFiber(fiber) { + var owner = fiber._debugOwner ? fiber._debugOwner.type : null; + var source = fiber._debugSource; + + switch (fiber.tag) { + case HostComponent: + return describeBuiltInComponentFrame(fiber.type, source, owner); + + case LazyComponent: + return describeBuiltInComponentFrame("Lazy", source, owner); + + case SuspenseComponent: + return describeBuiltInComponentFrame("Suspense", source, owner); + + case SuspenseListComponent: + return describeBuiltInComponentFrame("SuspenseList", source, owner); + + case FunctionComponent: + case IndeterminateComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type, source, owner); + + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render, source, owner); + + case Block: + return describeFunctionComponentFrame(fiber.type._render, source, owner); + + case ClassComponent: + return describeClassComponentFrame(fiber.type, source, owner); + + default: + return ""; + } +} + +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + var node = workInProgress; + + do { + info += describeFiber(node); + node = node.return; + } while (node); + + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} + var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; var current = null; var isRendering = false; @@ -6404,7 +6378,7 @@ var ReactStrictModeWarnings = { error( "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + "\nPlease update the following components: %s", sortedNames @@ -6419,11 +6393,11 @@ var ReactStrictModeWarnings = { error( "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* If you're updating state whenever props change, " + "refactor your code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + "\nPlease update the following components: %s", _sortedNames ); @@ -6437,7 +6411,7 @@ var ReactStrictModeWarnings = { error( "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "\nPlease update the following components: %s", _sortedNames2 @@ -6449,7 +6423,7 @@ var ReactStrictModeWarnings = { warn( "componentWillMount has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + @@ -6467,11 +6441,11 @@ var ReactStrictModeWarnings = { warn( "componentWillReceiveProps has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* If you're updating state whenever props change, refactor your " + "code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + @@ -6486,7 +6460,7 @@ var ReactStrictModeWarnings = { warn( "componentWillUpdate has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + @@ -6559,7 +6533,7 @@ var ReactStrictModeWarnings = { "\n\nThe old API will be supported in all 16.x releases, but applications " + "using it should migrate to the new version." + "\n\nPlease update the following components: %s" + - "\n\nLearn more about this warning here: https://fb.me/react-legacy-context", + "\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context", sortedNames ); } finally { @@ -6750,8 +6724,7 @@ function propagateContextChange( // Schedule a force update on the work-in-progress. var update = createUpdate( NoTimestamp, - pickArbitraryLane(renderLanes), - null + pickArbitraryLane(renderLanes) ); update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the // update to the current fiber, too, which means it will persist even if @@ -6937,11 +6910,10 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue = clone; } } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(eventTime, lane) { var update = { eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, tag: UpdateState, payload: null, callback: null, @@ -7016,7 +6988,6 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { var clone = { eventTime: update.eventTime, lane: update.lane, - suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, @@ -7108,8 +7079,8 @@ function getStateFromUpdate( } case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = + (workInProgress.flags & ~ShouldCapture) | DidCapture; } // Intentional fallthrough @@ -7235,7 +7206,6 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { var clone = { eventTime: updateEventTime, lane: updateLane, - suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, @@ -7259,21 +7229,13 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { // it. Using NoLane works because 0 is a subset of all bitmasks, so // this will never be skipped by the check above. lane: NoLane, - suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, next: null }; newLastBaseUpdate = newLastBaseUpdate.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig); // Process this update. + } // Process this update. newState = getStateFromUpdate( workInProgress, @@ -7286,7 +7248,7 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { var callback = update.callback; if (callback !== null) { - workInProgress.effectTag |= Callback; + workInProgress.flags |= Callback; var effects = queue.effects; if (effects === null) { @@ -7378,11 +7340,6 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; -function requestCurrentSuspenseConfig() { - return ReactCurrentBatchConfig.suspense; -} - var fakeInternalInstance = {}; var isArray = Array.isArray; // React.Component uses a shared frozen object by default. // We'll use it to determine whether we need to initialize legacy refs. @@ -7507,9 +7464,8 @@ var classComponentUpdater = { enqueueSetState: function(inst, payload, callback) { var fiber = get(inst); var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.payload = payload; if (callback !== undefined && callback !== null) { @@ -7526,9 +7482,8 @@ var classComponentUpdater = { enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ReplaceState; update.payload = payload; @@ -7546,9 +7501,8 @@ var classComponentUpdater = { enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ForceUpdate; if (callback !== undefined && callback !== null) { @@ -8008,7 +7962,7 @@ function constructClassInstance(workInProgress, ctor, props) { "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + - "https://fb.me/react-unsafe-component-lifecycles", + "https://reactjs.org/link/unsafe-component-lifecycles", _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : "", @@ -8170,7 +8124,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -8232,7 +8186,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return false; @@ -8278,13 +8232,13 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the // memoized state to indicate that this work can be reused. @@ -8372,7 +8326,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -8381,7 +8335,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } @@ -8428,11 +8382,11 @@ function updateClassInstance( } if (typeof instance.componentDidUpdate === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } if (typeof instance.getSnapshotBeforeUpdate === "function") { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } else { // If an update was already in progress, we should schedule an Update @@ -8442,7 +8396,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -8451,7 +8405,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } // If shouldComponentUpdate returned false, we should still update the // memoized props/state to indicate that this work can be reused. @@ -8514,7 +8468,7 @@ var warnForMissingKey = function(child, returnFiber) {}; error( "Each child in a list should have a unique " + - '"key" prop. See https://fb.me/react-warning-keys for ' + + '"key" prop. See https://reactjs.org/link/warning-keys for ' + "more information." ); }; @@ -8552,7 +8506,7 @@ function coerceRef(returnFiber, current, element) { "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-string-ref", + "https://reactjs.org/link/strict-mode-string-ref", mixedRef ); } @@ -8571,7 +8525,7 @@ function coerceRef(returnFiber, current, element) { if (!(ownerFiber.tag === ClassComponent)) { throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); } @@ -8625,7 +8579,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + mixedRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } } @@ -8690,7 +8644,7 @@ function ChildReconciler(shouldTrackSideEffects) { } childToDelete.nextEffect = null; - childToDelete.effectTag = Deletion; + childToDelete.flags = Deletion; } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -8754,7 +8708,7 @@ function ChildReconciler(shouldTrackSideEffects) { if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -8762,7 +8716,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -8771,7 +8725,7 @@ function ChildReconciler(shouldTrackSideEffects) { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { - newFiber.effectTag = Placement; + newFiber.flags = Placement; } return newFiber; @@ -9725,12 +9679,13 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case FunctionComponent: { - var Component = returnFiber.type; - + case Block: + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { { throw Error( - (Component.displayName || Component.name || "Component") + + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); } @@ -9894,13 +9849,6 @@ function popSuspenseContext(fiber) { pop(suspenseStackCursor, fiber); } -// A non-null SuspenseState means that it is blocked for one reason or another. -// - A non-null dehydrated field means it's blocked pending hydration. -// - A non-null dehydrated field can use isSuspenseInstancePending or -// isSuspenseInstanceFallback to query the reason for being dehydrated. -// - A null dehydrated field means it's blocked by something suspending and -// we're currently showing a fallback instead. - function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { // If it was the primary children that just suspended, capture and render the // fallback. Otherwise, don't capture and bubble to the next boundary. @@ -9955,7 +9903,7 @@ function findFirstSuspended(row) { // keep track of whether it suspended or not. node.memoizedProps.revealOrder !== undefined ) { - var didSuspend = (node.effectTag & DidCapture) !== NoEffect; + var didSuspend = (node.flags & DidCapture) !== NoFlags; if (didSuspend) { return node; @@ -9985,7 +9933,7 @@ function findFirstSuspended(row) { return null; } -var NoEffect$1 = +var NoFlags$1 = /* */ 0; // Represents whether effect should fire. @@ -10209,7 +10157,7 @@ function warnOnHookMismatchInDev(currentHookName) { error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + - "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + + "For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n" + " Previous render Next render\n" + " ------------------------------------------------------\n" + "%s" + @@ -10225,7 +10173,7 @@ function warnOnHookMismatchInDev(currentHookName) { function throwInvalidHookError() { { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } } @@ -10395,7 +10343,7 @@ function renderWithHooks( } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; - workInProgress.effectTag &= ~(Passive | Update); + workInProgress.flags &= ~(Passive | Update); current.lanes = removeLanes(current.lanes, lanes); } function resetHooksAfterThrow() { @@ -10611,18 +10559,14 @@ function updateReducer(reducer, initialArg, init) { var update = first; do { - var suspenseConfig = update.suspenseConfig; var updateLane = update.lane; - var updateEventTime = update.eventTime; if (!isSubsetOfLanes(renderLanes, updateLane)) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. var clone = { - eventTime: updateEventTime, lane: updateLane, - suspenseConfig: suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, @@ -10647,26 +10591,17 @@ function updateReducer(reducer, initialArg, init) { // This update does have sufficient priority. if (newBaseQueueLast !== null) { var _clone = { - eventTime: updateEventTime, // This update is going to be committed so we never want uncommit // it. Using NoLane works because 0 is a subset of all bitmasks, so // this will never be skipped by the check above. lane: NoLane, - suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }; newBaseQueueLast = newBaseQueueLast.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); // Process this update. + } // Process this update. if (update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -10893,8 +10828,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { if (!objectIs(snapshot, maybeNewSnapshot)) { setSnapshot(maybeNewSnapshot); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var lane = requestUpdateLane(fiber); markRootMutableRead(root, lane); } // If the source mutated between render and now, // there may be state updates already scheduled from the old source. @@ -10915,8 +10849,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { try { latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var lane = requestUpdateLane(fiber); markRootMutableRead(root, lane); } catch (error) { // A selector might throw after a source mutation. @@ -11065,16 +10998,14 @@ function pushEffect(tag, create, destroy, deps) { function mountRef(initialValue) { var hook = mountWorkInProgressHook(); - var ref = { - current: initialValue - }; { - Object.seal(ref); + var _ref2 = { + current: initialValue + }; + hook.memoizedState = _ref2; + return _ref2; } - - hook.memoizedState = ref; - return ref; } function updateRef(initialValue) { @@ -11082,19 +11013,19 @@ function updateRef(initialValue) { return hook.memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, undefined, nextDeps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var destroy = undefined; @@ -11107,15 +11038,15 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - pushEffect(hookEffectTag, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, destroy, nextDeps @@ -11289,128 +11220,124 @@ function updateMemo(nextCreate, deps) { return nextValue; } -function mountDeferredValue(value, config) { +function mountDeferredValue(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function updateDeferredValue(value, config) { +function updateDeferredValue(value) { var _updateState = updateState(), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function rerenderDeferredValue(value, config) { +function rerenderDeferredValue(value) { var _rerenderState = rerenderState(), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); - runWithPriority( - priorityLevel < UserBlockingPriority$1 - ? UserBlockingPriority$1 - : priorityLevel, - function() { - setPending(true); - } - ); // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition. - runWithPriority( - priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, - function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + { + runWithPriority( + priorityLevel < UserBlockingPriority$1 + ? UserBlockingPriority$1 + : priorityLevel, + function() { + setPending(true); } - } - ); + ); + runWithPriority( + priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, + function() { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } + } + ); + } } -function mountTransition(config) { +function mountTransition() { var _mountState2 = mountState(false), isPending = _mountState2[0], - setPending = _mountState2[1]; + setPending = _mountState2[1]; // The `start` method never changes. - var start = mountCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var start = startTransition.bind(null, setPending); + var hook = mountWorkInProgressHook(); + hook.memoizedState = start; return [start, isPending]; } -function updateTransition(config) { +function updateTransition() { var _updateState2 = updateState(), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } -function rerenderTransition(config) { +function rerenderTransition() { var _rerenderState2 = rerenderState(), - isPending = _rerenderState2[0], - setPending = _rerenderState2[1]; + isPending = _rerenderState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } @@ -11474,12 +11401,9 @@ function dispatchAction(fiber, queue, action) { } var eventTime = requestEventTime(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var lane = requestUpdateLane(fiber); var update = { - eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, action: action, eagerReducer: null, eagerState: null, @@ -11605,7 +11529,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; "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" + "https://reactjs.org/link/rules-of-hooks" ); }; @@ -11689,15 +11613,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11786,15 +11710,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11883,15 +11807,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -11980,15 +11904,15 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -12088,17 +12012,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -12200,17 +12124,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -12312,17 +12236,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; @@ -12540,7 +12464,7 @@ function updateForwardRef( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12605,7 +12529,7 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, renderLanes ); @@ -12646,7 +12570,7 @@ function updateMemoComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; var newChild = createWorkInProgress(currentChild, nextProps); newChild.ref = workInProgress.ref; newChild.return = workInProgress; @@ -12729,10 +12653,7 @@ function updateSimpleMemoComponent( workInProgress, renderLanes ); - } else if ( - (current.effectTag & ForceUpdateForLegacySuspense) !== - NoEffect - ) { + } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; @@ -12841,7 +12762,7 @@ function updateMode(current, workInProgress, renderLanes) { function updateProfiler(current, workInProgress, renderLanes) { { - workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase. + workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, var stateNode = workInProgress.stateNode; @@ -12863,7 +12784,7 @@ function markRef(current, workInProgress) { (current !== null && current.ref !== ref) ) { // Schedule a Ref effect - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } } @@ -12938,7 +12859,7 @@ function updateFunctionComponent( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12991,7 +12912,7 @@ function updateClassComponent( current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); @@ -13053,7 +12974,7 @@ function finishClassComponent( ) { // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); - var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; + var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags; if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering @@ -13102,7 +13023,7 @@ function finishClassComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (current !== null && didCaptureError) { // If we're recovering from an error, reconcile without reusing any of @@ -13189,7 +13110,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - node.effectTag = (node.effectTag & ~Placement) | Hydrating; + node.flags = (node.flags & ~Placement) | Hydrating; node = node.sibling; } } else { @@ -13212,7 +13133,7 @@ function updateHostComponent(current, workInProgress, renderLanes) { if (prevProps !== null && shouldSetTextContent()) { // If we're switching from a direct text child to a normal child, or to // empty, we need to schedule the text content to be reset. - workInProgress.effectTag |= ContentReset; + workInProgress.flags |= ContentReset; } markRef(current, workInProgress); @@ -13241,7 +13162,7 @@ function mountLazyComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } var props = workInProgress.pendingProps; @@ -13375,7 +13296,7 @@ function mountIncompleteClassComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // Promote the fiber to a class and try rendering again. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` @@ -13419,7 +13340,7 @@ function mountIndeterminateComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } var props = workInProgress.pendingProps; @@ -13469,7 +13390,7 @@ function mountIndeterminateComponent( setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; { // Support for module components is deprecated and is removed behind a flag. @@ -13683,7 +13604,7 @@ function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { return { baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) }; -} +} // TODO: Probably should inline this back function shouldRemainOnFallback( suspenseContext, @@ -13719,19 +13640,19 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { { if (shouldSuspend(workInProgress)) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } } var suspenseContext = suspenseStackCursor.current; var showFallback = false; - var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; + var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags; if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. showFallback = true; - workInProgress.effectTag &= ~DidCapture; + workInProgress.flags &= ~DidCapture; } else { // Attempting the main content if (current === null || current.memoizedState !== null) { @@ -13782,9 +13703,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // But only if this has a fallback. if (nextProps.fallback !== undefined); + var nextPrimaryChildren = nextProps.children; + var nextFallbackChildren = nextProps.fallback; + if (showFallback) { - var nextPrimaryChildren = nextProps.children; - var nextFallbackChildren = nextProps.fallback; var fallbackFragment = mountSuspenseFallbackChildren( workInProgress, nextPrimaryChildren, @@ -13797,11 +13719,41 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ); workInProgress.memoizedState = SUSPENDED_MARKER; return fallbackFragment; + } else if (typeof nextProps.unstable_expectedLoadTime === "number") { + // This is a CPU-bound tree. Skip this tree and show a placeholder to + // unblock the surrounding content. Then immediately retry after the + // initial commit. + var _fallbackFragment = mountSuspenseFallbackChildren( + workInProgress, + nextPrimaryChildren, + nextFallbackChildren, + renderLanes + ); + + var _primaryChildFragment = workInProgress.child; + _primaryChildFragment.memoizedState = mountSuspenseOffscreenState( + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to + // get it started back up to attempt the next item. While in terms of + // priority this work has the same priority as this current render, it's + // not part of the same transition once the transition has committed. If + // it's sync, we still want to yield so that it can be painted. + // Conceptually, this is really the same as pinging. We can use any + // RetryLane even if it's the one currently rendering since we're leaving + // it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + + return _fallbackFragment; } else { - var _nextPrimaryChildren = nextProps.children; return mountSuspensePrimaryChildren( workInProgress, - _nextPrimaryChildren, + nextPrimaryChildren, renderLanes ); } @@ -13814,63 +13766,63 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { if (prevState !== null) { if (showFallback) { var _nextFallbackChildren2 = nextProps.fallback; - var _nextPrimaryChildren3 = nextProps.children; + var _nextPrimaryChildren2 = nextProps.children; var _fallbackChildFragment = updateSuspenseFallbackChildren( current, workInProgress, - _nextPrimaryChildren3, + _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes ); - var _primaryChildFragment2 = workInProgress.child; + var _primaryChildFragment3 = workInProgress.child; var prevOffscreenState = current.child.memoizedState; - _primaryChildFragment2.memoizedState = + _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); - _primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree( + _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree( current, renderLanes ); workInProgress.memoizedState = SUSPENDED_MARKER; return _fallbackChildFragment; } else { - var _nextPrimaryChildren4 = nextProps.children; + var _nextPrimaryChildren3 = nextProps.children; - var _primaryChildFragment3 = updateSuspensePrimaryChildren( + var _primaryChildFragment4 = updateSuspensePrimaryChildren( current, workInProgress, - _nextPrimaryChildren4, + _nextPrimaryChildren3, renderLanes ); workInProgress.memoizedState = null; - return _primaryChildFragment3; + return _primaryChildFragment4; } } else { // The current tree is not already showing a fallback. if (showFallback) { // Timed out. var _nextFallbackChildren3 = nextProps.fallback; - var _nextPrimaryChildren5 = nextProps.children; + var _nextPrimaryChildren4 = nextProps.children; var _fallbackChildFragment2 = updateSuspenseFallbackChildren( current, workInProgress, - _nextPrimaryChildren5, + _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes ); - var _primaryChildFragment4 = workInProgress.child; + var _primaryChildFragment5 = workInProgress.child; var _prevOffscreenState = current.child.memoizedState; - _primaryChildFragment4.memoizedState = + _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); - _primaryChildFragment4.childLanes = getRemainingWorkInPrimaryTree( + _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree( current, renderLanes ); // Skip the primary children, and continue working on the @@ -13881,17 +13833,17 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } else { // Still haven't timed out. Continue rendering the children, like we // normally do. - var _nextPrimaryChildren6 = nextProps.children; + var _nextPrimaryChildren5 = nextProps.children; - var _primaryChildFragment5 = updateSuspensePrimaryChildren( + var _primaryChildFragment6 = updateSuspensePrimaryChildren( current, workInProgress, - _nextPrimaryChildren6, + _nextPrimaryChildren5, renderLanes ); workInProgress.memoizedState = null; - return _primaryChildFragment5; + return _primaryChildFragment6; } } } @@ -14011,7 +13963,7 @@ function updateSuspensePrimaryChildren( if (currentFallbackChildFragment !== null) { // Delete the fallback child fragment currentFallbackChildFragment.nextEffect = null; - currentFallbackChildFragment.effectTag = Deletion; + currentFallbackChildFragment.flags = Deletion; workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; } @@ -14102,7 +14054,7 @@ function updateSuspenseFallbackChildren( ); // Needs a placement effect because the parent (the Suspense boundary) already // mounted but this is a new fiber. - fallbackChildFragment.effectTag |= Placement; + fallbackChildFragment.flags |= Placement; } fallbackChildFragment.return = workInProgress; @@ -14365,7 +14317,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }; @@ -14376,7 +14327,6 @@ function initSuspenseListRenderState( renderState.renderingStartTime = 0; renderState.last = lastContentRow; renderState.tail = tail; - renderState.tailExpiration = 0; renderState.tailMode = tailMode; renderState.lastEffect = lastEffectBeforeRendering; } @@ -14408,10 +14358,10 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { suspenseContext, ForceSuspenseFallback ); - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } else { var didSuspendBefore = - current !== null && (current.effectTag & DidCapture) !== NoEffect; + current !== null && (current.flags & DidCapture) !== NoFlags; if (didSuspendBefore) { // If we previously forced a fallback, we need to schedule work @@ -14653,7 +14603,7 @@ function updateContextConsumer(current, workInProgress, renderLanes) { setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } @@ -14736,8 +14686,8 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } current.nextEffect = null; - current.effectTag = Deletion; - newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber. + current.flags = Deletion; + newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; } @@ -14822,7 +14772,7 @@ function beginWork(current, workInProgress, renderLanes) { ); if (hasChildWork) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -14886,7 +14836,7 @@ function beginWork(current, workInProgress, renderLanes) { } case SuspenseListComponent: { - var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; + var didSuspendBefore = (current.flags & DidCapture) !== NoFlags; var _hasChildWork = includesSomeLane( renderLanes, @@ -14909,7 +14859,7 @@ function beginWork(current, workInProgress, renderLanes) { // them got retried so they'll still be blocked in the same way // as before. We can fast bail out. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } // If nothing suspended before and we're rendering the same children, // then the tail doesn't matter. Anything new that suspends will work // in the "together" mode, so we can continue from the state we had. @@ -14953,7 +14903,7 @@ function beginWork(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else { - if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) { + if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; @@ -15176,11 +15126,11 @@ function beginWork(current, workInProgress, renderLanes) { function markUpdate(workInProgress) { // Tag the fiber with an update effect. This turns a Placement into // a PlacementAndUpdate. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } function markRef$1(workInProgress) { - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } var appendAllChildren; @@ -15395,7 +15345,7 @@ function completeWork(current, workInProgress, renderLanes) { // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null // if the previous render was null (so the the container would already be empty). - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } @@ -15517,7 +15467,7 @@ function completeWork(current, workInProgress, renderLanes) { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; - if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + if ((workInProgress.flags & DidCapture) !== NoFlags) { // Something suspended. Re-render with the fallback children. workInProgress.lanes = renderLanes; // Do not reset the effect list. @@ -15582,7 +15532,7 @@ function completeWork(current, workInProgress, renderLanes) { // primary children. In mutation mode, we also need the flag to // *unhide* children that were previously hidden, so check if this // is currently timed out, too. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -15626,8 +15576,7 @@ function completeWork(current, workInProgress, renderLanes) { return null; } - var didSuspendAlready = - (workInProgress.effectTag & DidCapture) !== NoEffect; + var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags; var renderedTail = renderState.rendering; if (renderedTail === null) { @@ -15644,7 +15593,7 @@ function completeWork(current, workInProgress, renderLanes) { // findFirstSuspended. var cannotBeSuspended = renderHasNotSuspendedYet() && - (current === null || (current.effectTag & DidCapture) === NoEffect); + (current === null || (current.flags & DidCapture) === NoFlags); if (!cannotBeSuspended) { var row = workInProgress.child; @@ -15654,7 +15603,7 @@ function completeWork(current, workInProgress, renderLanes) { if (suspended !== null) { didSuspendAlready = true; - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as // part of the second pass. In that case nothing will subscribe to // its thennables. Instead, we'll transfer its thennables to the @@ -15672,7 +15621,7 @@ function completeWork(current, workInProgress, renderLanes) { if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks // to stay in place. // Reset the effect list before doing the second pass since that's now invalid. @@ -15699,6 +15648,28 @@ function completeWork(current, workInProgress, renderLanes) { row = row.sibling; } } + + if (renderState.tail !== null && now() > getRenderTargetTime()) { + // We have already passed our CPU deadline but we still have rows + // left in the tail. We'll just give up further attempts to render + // the main content and only render fallbacks. + workInProgress.flags |= DidCapture; + didSuspendAlready = true; + cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + } } else { cutOffTailIfNeeded(renderState, false); } // Next we're going to render the tail. @@ -15708,7 +15679,7 @@ function completeWork(current, workInProgress, renderLanes) { var _suspended = findFirstSuspended(renderedTail); if (_suspended !== null) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't // get lost if this row ends up dropped during a second pass. @@ -15716,7 +15687,7 @@ function completeWork(current, workInProgress, renderLanes) { if (_newThennables !== null) { workInProgress.updateQueue = _newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } cutOffTailIfNeeded(renderState, true); // This might have been modified. @@ -15740,27 +15711,31 @@ function completeWork(current, workInProgress, renderLanes) { return null; } } else if ( - // The time it took to render last row is greater than time until - // the expiration. + // The time it took to render last row is greater than the remaining + // time we have to render. So rendering one more row would likely + // exceed it. now() * 2 - renderState.renderingStartTime > - renderState.tailExpiration && + getRenderTargetTime() && renderLanes !== OffscreenLane ) { // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. // The assumption is that this is usually faster. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this - // to get it started back up to attempt the next item. If we can show - // them, then they really have the same priority as this render. - // So we'll pick it back up the very next render pass once we've had - // an opportunity to yield for paint. + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. - workInProgress.lanes = renderLanes; + workInProgress.lanes = SomeRetryLane; { - markSpawnedWork(renderLanes); + markSpawnedWork(SomeRetryLane); } } } @@ -15788,18 +15763,7 @@ function completeWork(current, workInProgress, renderLanes) { if (renderState.tail !== null) { // We still have tail rows to render. - if (renderState.tailExpiration === 0) { - // Heuristic for how long we're willing to spend rendering rows - // until we just give up and show what we have so far. - var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this - // is a per component value. It should really be since the start - // of the total render or last commit. Consider using something like - // globalMostRecentFallbackTime. That doesn't account for being - // suspended for part of the time or when it's a new render. - // It should probably use a global start time value instead. - } // Pop a row. - + // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; @@ -15853,7 +15817,7 @@ function completeWork(current, workInProgress, renderLanes) { prevIsHidden !== nextIsHidden && newProps.mode !== "unstable-defer-without-hiding" ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -15879,10 +15843,10 @@ function unwindWork(workInProgress, renderLanes) { popContext(workInProgress); } - var effectTag = workInProgress.effectTag; + var flags = workInProgress.flags; - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; if ((workInProgress.mode & ProfileMode) !== NoMode) { transferActualDuration(workInProgress); @@ -15898,15 +15862,15 @@ function unwindWork(workInProgress, renderLanes) { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); resetWorkInProgressVersions(); - var _effectTag = workInProgress.effectTag; + var _flags = workInProgress.flags; - if (!((_effectTag & DidCapture) === NoEffect)) { + if (!((_flags & DidCapture) === NoFlags)) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); } - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; return workInProgress; } @@ -15919,10 +15883,10 @@ function unwindWork(workInProgress, renderLanes) { case SuspenseComponent: { popSuspenseContext(workInProgress); - var _effectTag2 = workInProgress.effectTag; + var _flags2 = workInProgress.flags; - if (_effectTag2 & ShouldCapture) { - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. + if (_flags2 & ShouldCapture) { + workInProgress.flags = (_flags2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. if ((workInProgress.mode & ProfileMode) !== NoMode) { transferActualDuration(workInProgress); @@ -16089,7 +16053,7 @@ function logCapturedError(boundary, errorInfo) { } else { 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."; + "Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries."; } var combinedMessage = @@ -16123,7 +16087,7 @@ function logCapturedError(boundary, errorInfo) { var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); // Unmount the root by rendering null. + var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property // being called "element". @@ -16142,7 +16106,7 @@ function createRootErrorUpdate(fiber, errorInfo, lane) { } function createClassErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); + var update = createUpdate(NoTimestamp, lane); update.tag = CaptureUpdate; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; @@ -16240,7 +16204,7 @@ function throwException( rootRenderLanes ) { // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. sourceFiber.firstEffect = sourceFiber.lastEffect = null; @@ -16300,12 +16264,12 @@ function throwException( // should *not* suspend the commit. if ((_workInProgress.mode & BlockingMode) === NoMode) { - _workInProgress.effectTag |= DidCapture; - sourceFiber.effectTag |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. + _workInProgress.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. // But we shouldn't call any lifecycle methods or callbacks. Remove // all lifecycle effect tags. - sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); if (sourceFiber.tag === ClassComponent) { var currentSourceFiber = sourceFiber.alternate; @@ -16319,7 +16283,7 @@ function throwException( // When we try rendering again, we should not reuse the current fiber, // since it's known to be in an inconsistent state. Use a force update to // prevent a bail out. - var update = createUpdate(NoTimestamp, SyncLane, null); + var update = createUpdate(NoTimestamp, SyncLane); update.tag = ForceUpdate; enqueueUpdate(sourceFiber, update); } @@ -16354,8 +16318,8 @@ function throwException( // that we can show the initial loading state as quickly as possible. // // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. // // If we're already showing a fallback and it gets "retried", allowing us to show // another level, but there's still an inner boundary that would show a fallback, @@ -16371,7 +16335,7 @@ function throwException( // ensure that new initial loading states can commit as soon as possible. attachPingListener(root, wakeable, rootRenderLanes); - _workInProgress.effectTag |= ShouldCapture; + _workInProgress.flags |= ShouldCapture; _workInProgress.lanes = rootRenderLanes; return; } // This boundary already captured during this render. Continue to the next @@ -16400,7 +16364,7 @@ function throwException( switch (workInProgress.tag) { case HostRoot: { var _errorInfo = value; - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); @@ -16417,13 +16381,13 @@ function throwException( var instance = workInProgress.stateNode; if ( - (workInProgress.effectTag & DidCapture) === NoEffect && + (workInProgress.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === "function" || (instance !== null && typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance))) ) { - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; var _lane = pickArbitraryLane(rootRenderLanes); @@ -16486,7 +16450,9 @@ function safelyDetachRef(current) { if (ref !== null) { if (typeof ref === "function") { { - invokeGuardedCallback(null, ref, null, null); + { + invokeGuardedCallback(null, ref, null, null); + } if (hasCaughtError()) { var refError = clearCaughtError(); @@ -16520,7 +16486,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } case ClassComponent: { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; @@ -16587,7 +16553,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case HostRoot: { { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { var root = finishedWork.stateNode; clearContainer(root.containerInfo); } @@ -16672,7 +16638,7 @@ function commitHookEffectListMount(tag, finishedWork) { " }\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"; + "Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching"; } else { addendum = " You returned: " + destroy; } @@ -16704,10 +16670,7 @@ function schedulePassiveEffects(finishedWork) { next = _effect.next, tag = _effect.tag; - if ( - (tag & Passive$1) !== NoEffect$1 && - (tag & HasEffect) !== NoEffect$1 - ) { + if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) { enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); enqueuePendingPassiveHookEffectMount(finishedWork, effect); } @@ -16738,7 +16701,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { case ClassComponent: { var instance = finishedWork.stateNode; - if (finishedWork.effectTag & Update) { + if (finishedWork.flags & Update) { if (current === null) { // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -16896,7 +16859,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. - if (current === null && finishedWork.effectTag & Update) { + if (current === null && finishedWork.flags & Update) { var type = finishedWork.type; var props = finishedWork.memoizedProps; } @@ -17030,7 +16993,9 @@ function commitAttachRef(finishedWork) { } // Moved outside to ensure DCE works with this flag if (typeof ref === "function") { - ref(instanceToUse); + { + ref(instanceToUse); + } } else { { if (!ref.hasOwnProperty("current")) { @@ -17052,7 +17017,9 @@ function commitDetachRef(current) { if (currentRef !== null) { if (typeof currentRef === "function") { - currentRef(null); + { + currentRef(null); + } } else { currentRef.current = null; } @@ -17085,7 +17052,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { tag = _effect2.tag; if (destroy !== undefined) { - if ((tag & Passive$1) !== NoEffect$1) { + if ((tag & Passive$1) !== NoFlags$1) { enqueuePendingPassiveHookEffectUnmount(current, effect); } else { { @@ -17267,7 +17234,7 @@ function getHostSibling(fiber) { ) { // If it is not host node and, we might have a host node inside it. // Try to search down until we find one. - if (node.effectTag & Placement) { + if (node.flags & Placement) { // If we don't have a child, try the siblings instead. continue siblings; } // If we don't have a child, try the siblings instead. @@ -17281,7 +17248,7 @@ function getHostSibling(fiber) { } } // Check if this host node is stable or about to be placed. - if (!(node.effectTag & Placement)) { + if (!(node.flags & Placement)) { // Found it! return node.stateNode; } @@ -17322,8 +17289,8 @@ function commitPlacement(finishedWork) { } } - if (parentFiber.effectTag & ContentReset) { - parentFiber.effectTag &= ~ContentReset; + if (parentFiber.flags & ContentReset) { + parentFiber.flags &= ~ContentReset; } var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its @@ -17757,9 +17724,7 @@ var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root complet var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown -var workInProgressRootFatalError = null; -var workInProgressRootLatestSuspenseTimeout = NoTimestamp; -var workInProgressRootCanSuspendUsingConfig = null; // "Included" lanes refer to lanes that were worked on during this render. It's +var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's // slightly different than `renderLanes` because `renderLanes` can change as you // enter and exit an Offscreen tree. This value is the combination of all render // lanes for the entire render phase. @@ -17776,8 +17741,21 @@ var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallb // model where we don't commit new loading states in too quick succession. var globalMostRecentFallbackTime = 0; -var FALLBACK_THROTTLE_MS = 500; -var DEFAULT_TIMEOUT_MS = 5000; +var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering +// more and prefer CPU suspense heuristics instead. + +var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU +// suspense heuristics and opt out of rendering more content. + +var RENDER_TIMEOUT_MS = 500; + +function resetRenderTimer() { + workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS; +} + +function getRenderTargetTime() { + return workInProgressRootRenderTargetTime; +} var nextEffect = null; var hasUncaughtError = false; var firstUncaughtError = null; @@ -17829,7 +17807,7 @@ function requestEventTime() { currentEventTime = now(); return currentEventTime; } -function requestUpdateLane(fiber, suspenseConfig) { +function requestUpdateLane(fiber) { // Special cases var mode = fiber.mode; @@ -17858,16 +17836,9 @@ function requestUpdateLane(fiber, suspenseConfig) { currentEventWipLanes = workInProgressRootIncludedLanes; } - if (suspenseConfig !== null) { - // Use the size of the timeout as a heuristic to prioritize shorter - // transitions over longer ones. - // TODO: This will coerce numbers larger than 31 bits to 0. - var timeoutMs = suspenseConfig.timeoutMs; - var transitionLanePriority = - timeoutMs === undefined || (timeoutMs | 0) < 10000 - ? TransitionShortLanePriority - : TransitionLongLanePriority; + var isTransition = requestCurrentTransition() !== NoTransition; + if (isTransition) { if (currentEventPendingLanes !== NoLanes) { currentEventPendingLanes = mostRecentlyUpdatedRoot !== null @@ -17875,11 +17846,7 @@ function requestUpdateLane(fiber, suspenseConfig) { : NoLanes; } - return findTransitionLane( - transitionLanePriority, - currentEventWipLanes, - currentEventPendingLanes - ); + return findTransitionLane(currentEventWipLanes, currentEventPendingLanes); } // TODO: Remove this dependency on the Scheduler priority. // To do that, we're replacing it with an update lane priority. @@ -17992,6 +17959,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { // scheduleCallbackForFiber to preserve the ability to schedule a callback // without immediately flushing it. We only do this for user-initiated // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); flushSyncCallbackQueue(); } } @@ -18038,7 +18006,7 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { { if ( alternate === null && - (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect + (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags ) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } @@ -18055,7 +18023,7 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { alternate.childLanes = mergeLanes(alternate.childLanes, lane); } else { { - if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((parent.flags & (Placement | Hydrating)) !== NoFlags) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } } @@ -18141,7 +18109,7 @@ function ensureRootIsScheduled(root, currentTime) { } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. -function performConcurrentWorkOnRoot(root, didTimeout) { +function performConcurrentWorkOnRoot(root) { // Since we know we're in a React event, we can clear the current // event time. The next update will compute a new event time. currentEventTime = NoTimestamp; @@ -18176,18 +18144,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (lanes === NoLanes) { // Defensive coding. This is never expected to happen. return null; - } // TODO: We only check `didTimeout` defensively, to account for a Scheduler - // bug where `shouldYield` sometimes returns `true` even if `didTimeout` is - // true, which leads to an infinite loop. Once the bug in Scheduler is - // fixed, we can remove this, since we track expiration ourselves. - - if (didTimeout) { - // Something expired. Flush synchronously until there's no expired - // work left. - markRootExpired(root, lanes); // This will schedule a synchronous callback. - - ensureRootIsScheduled(root, now()); - return null; } var exitStatus = renderRootConcurrent(root, lanes); @@ -18237,7 +18193,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var finishedWork = root.current.alternate; root.finishedWork = finishedWork; root.finishedLanes = lanes; - finishConcurrentRender(root, finishedWork, exitStatus, lanes); + finishConcurrentRender(root, exitStatus, lanes); } ensureRootIsScheduled(root, now()); @@ -18251,7 +18207,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { return null; } -function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { +function finishConcurrentRender(root, exitStatus, lanes) { switch (exitStatus) { case RootIncomplete: case RootFatalErrored: { @@ -18320,64 +18276,36 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { case RootSuspendedWithDelay: { markRootSuspended$1(root, lanes); - if ( - // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() - ) { - // We're suspended in a state that should be avoided. We'll try to - // avoid committing it for as long as the timeouts let us. - var _nextLanes = getNextLanes(root, NoLanes); - - if (_nextLanes !== NoLanes) { - // There's additional work on this root. - break; - } - - var _suspendedLanes = root.suspendedLanes; - - if (!isSubsetOfLanes(_suspendedLanes, lanes)) { - // We should prefer to render the fallback of at the last - // suspended level. Ping the last suspended level to try - // rendering it again. - // FIXME: What if the suspended lanes are Idle? Should not restart. - var _eventTime = requestEventTime(); - - markRootPinged(root, _suspendedLanes); - break; - } + if (includesOnlyTransitions(lanes)) { + // This is a transition, so we should exit without committing a + // placeholder and without scheduling a timeout. Delay indefinitely + // until we receive more data. + break; + } + if (!shouldForceFlushFallbacksInDEV()) { + // This is not a transition, but we did trigger an avoided state. + // Schedule a placeholder to display after a short delay, using the Just + // Noticeable Difference. + // TODO: Is the JND optimization worth the added complexity? If this is + // the only reason we track the event time, then probably not. + // Consider removing. var mostRecentEventTime = getMostRecentEventTime(root, lanes); + var eventTimeMs = mostRecentEventTime; + var timeElapsedMs = now() - eventTimeMs; - var _msUntilTimeout; - - if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) { - // We have processed a suspense config whose expiration time we - // can use as the timeout. - _msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now(); - } else if (mostRecentEventTime === NoTimestamp) { - // This should never normally happen because only new updates - // cause delayed states, so we should have processed something. - // However, this could also happen in an offscreen tree. - _msUntilTimeout = 0; - } else { - // If we didn't process a suspense config, compute a JND based on - // the amount of time elapsed since the most recent event time. - var eventTimeMs = mostRecentEventTime; - var timeElapsedMs = now() - eventTimeMs; - _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; - } // Don't bother with a very short suspense time. + var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time. if (_msUntilTimeout > 10) { - // The render is suspended, it hasn't timed out, and there's no - // lower priority work to do. Instead of committing the fallback - // immediately, wait for more data to arrive. + // Instead of committing the fallback immediately, wait for more data + // to arrive. root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), _msUntilTimeout ); break; } - } // The work expired. Commit immediately. + } // Commit the placeholder. commitRoot(root); break; @@ -18385,33 +18313,6 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { case RootCompleted: { // The work completed. Ready to commit. - var _mostRecentEventTime = getMostRecentEventTime(root, lanes); - - if ( - // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() && - _mostRecentEventTime !== NoTimestamp && - workInProgressRootCanSuspendUsingConfig !== null - ) { - // If we have exceeded the minimum loading delay, which probably - // means we have shown a spinner already, we might have to suspend - // a bit longer to ensure that the spinner is shown for - // enough time. - var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay( - _mostRecentEventTime, - workInProgressRootCanSuspendUsingConfig - ); - - if (_msUntilTimeout2 > 10) { - markRootSuspended$1(root, lanes); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - _msUntilTimeout2 - ); - break; - } - } - commitRoot(root); break; } @@ -18524,6 +18425,7 @@ function batchedUpdates$1(fn, a) { if (executionContext === NoContext) { // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); flushSyncCallbackQueue(); } } @@ -18545,20 +18447,20 @@ function flushSync(fn, a) { executionContext |= BatchedContext; - try { - setCurrentUpdateLanePriority(SyncLanePriority); + { + try { + if (fn) { + return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); + } else { + return undefined; + } + } finally { + executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. + // Note that this will happen even if batchedUpdates is higher up + // the stack. - if (fn) { - return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); - } else { - return undefined; + flushSyncCallbackQueue(); } - } finally { - executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. - // Note that this will happen even if batchedUpdates is higher up - // the stack. - - flushSyncCallbackQueue(); } } function pushRenderLanes(fiber, lanes) { @@ -18601,8 +18503,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = NoTimestamp; - workInProgressRootCanSuspendUsingConfig = null; workInProgressRootSkippedLanes = NoLanes; workInProgressRootUpdatedLanes = NoLanes; workInProgressRootPingedLanes = NoLanes; @@ -18681,7 +18581,7 @@ function handleError(root, thrownValue) { } while (true); } -function pushDispatcher(root) { +function pushDispatcher() { var prevDispatcher = ReactCurrentDispatcher$2.current; ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; @@ -18716,27 +18616,6 @@ function popInteractions(prevInteractions) { function markCommitTimeOfFallback() { globalMostRecentFallbackTime = now(); } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - // Track the largest/latest timeout deadline in this batch. - // TODO: If there are two transitions in the same batch, shouldn't we - // choose the smaller one? Maybe this is because when an intermediate - // transition is superseded, we should ignore its suspense config, but - // we don't currently. - if (suspenseConfig !== null) { - // If `timeoutMs` is not specified, we default to 5 seconds. We have to - // resolve this default here because `suspenseConfig` is owned - // by userspace. - // TODO: Store this on the root instead (transition -> timeoutMs) - // TODO: Should this default to a JND instead? - var timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS; - var timeoutTime = eventTime + timeoutMs; - - if (timeoutTime > workInProgressRootLatestSuspenseTimeout) { - workInProgressRootLatestSuspenseTimeout = timeoutTime; - workInProgressRootCanSuspendUsingConfig = suspenseConfig; - } - } -} function markSkippedUpdateLanes(lane) { workInProgressRootSkippedLanes = mergeLanes( lane, @@ -18846,6 +18725,7 @@ function renderRootConcurrent(root, lanes) { // and prepare a fresh one. Otherwise we'll continue where we left off. if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + resetRenderTimer(); prepareFreshStack(root, lanes); startWorkOnPendingInteractions(root, lanes); } @@ -18929,7 +18809,7 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; // Check if the work completed or if something threw. - if ((completedWork.effectTag & Incomplete) === NoEffect) { + if ((completedWork.flags & Incomplete) === NoFlags) { setCurrentFiber(completedWork); var next = void 0; @@ -18954,7 +18834,7 @@ function completeUnitOfWork(unitOfWork) { if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete - (returnFiber.effectTag & Incomplete) === NoEffect + (returnFiber.flags & Incomplete) === NoFlags ) { // Append all the effects of the subtree and this fiber onto the effect // list of the parent. The completion order of the children affects the @@ -18976,11 +18856,11 @@ function completeUnitOfWork(unitOfWork) { // reusing children we'll schedule this effect onto itself since we're // at the end. - var effectTag = completedWork.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect + var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect // list. PerformedWork effect is read by React DevTools but shouldn't be // committed. - if (effectTag > PerformedWork) { + if (flags > PerformedWork) { if (returnFiber.lastEffect !== null) { returnFiber.lastEffect.nextEffect = completedWork; } else { @@ -19001,7 +18881,7 @@ function completeUnitOfWork(unitOfWork) { // back here again. // Since we're restarting, remove anything that is not a host effect // from the effect tag. - _next.effectTag &= HostEffectMask; + _next.flags &= HostEffectMask; workInProgress = _next; return; } @@ -19024,7 +18904,7 @@ function completeUnitOfWork(unitOfWork) { if (returnFiber !== null) { // Mark the parent fiber as incomplete and clear its effect list. returnFiber.firstEffect = returnFiber.lastEffect = null; - returnFiber.effectTag |= Incomplete; + returnFiber.flags |= Incomplete; } } @@ -19189,14 +19069,11 @@ function commitRootImpl(root, renderPriorityLevel) { workInProgressRoot = null; workInProgress = null; workInProgressRootRenderLanes = NoLanes; - } // This indicates that the last root we worked on is not the same one that - // we're committing now. This most commonly happens when a suspended root - // times out. - // Get the list of effects. + } // Get the list of effects. var firstEffect; - if (finishedWork.effectTag > PerformedWork) { + if (finishedWork.flags > PerformedWork) { // A fiber's effect list consists only of its children, not itself. So if // the root has an effect, we need to add it to the end of the list. The // resulting list is the set that would belong to the root's parent, if it @@ -19314,7 +19191,7 @@ function commitRootImpl(root, renderPriorityLevel) { popInteractions(prevInteractions); } - executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value. + executionContext = prevExecutionContext; } else { // No effects. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were @@ -19345,7 +19222,7 @@ function commitRootImpl(root, renderPriorityLevel) { var nextNextEffect = nextEffect.nextEffect; nextEffect.nextEffect = null; - if (nextEffect.effectTag & Deletion) { + if (nextEffect.flags & Deletion) { detachFiberAfterEffects(nextEffect); } @@ -19431,7 +19308,7 @@ function commitBeforeMutationEffects() { var current = nextEffect.alternate; if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - if ((nextEffect.effectTag & Deletion) !== NoEffect) { + if ((nextEffect.flags & Deletion) !== NoFlags) { if (doesFiberContain(nextEffect, focusedInstanceHandle)) { shouldFireAfterActiveInstanceBlur = true; } @@ -19447,15 +19324,15 @@ function commitBeforeMutationEffects() { } } - var effectTag = nextEffect.effectTag; + var flags = nextEffect.flags; - if ((effectTag & Snapshot) !== NoEffect) { + if ((flags & Snapshot) !== NoFlags) { setCurrentFiber(nextEffect); commitBeforeMutationLifeCycles(current, nextEffect); resetCurrentFiber(); } - if ((effectTag & Passive) !== NoEffect) { + if ((flags & Passive) !== NoFlags) { // If there are passive effects, schedule a callback to flush at // the earliest opportunity. if (!rootDoesHavePassiveEffects) { @@ -19475,13 +19352,13 @@ function commitMutationEffects(root, renderPriorityLevel) { // TODO: Should probably move the bulk of this function to commitWork. while (nextEffect !== null) { setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; + var flags = nextEffect.flags; - if (effectTag & ContentReset) { + if (flags & ContentReset) { commitResetTextContent(nextEffect); } - if (effectTag & Ref) { + if (flags & Ref) { var current = nextEffect.alternate; if (current !== null) { @@ -19492,17 +19369,16 @@ function commitMutationEffects(root, renderPriorityLevel) { // bitmap value, we remove the secondary effects from the effect tag and // switch on that value. - var primaryEffectTag = - effectTag & (Placement | Update | Deletion | Hydrating); + var primaryFlags = flags & (Placement | Update | Deletion | Hydrating); - switch (primaryEffectTag) { + switch (primaryFlags) { case Placement: { commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is // inserted, before any life-cycles like componentDidMount gets called. // TODO: findDOMNode doesn't rely on this any more but isMounted does // and isMounted is deprecated anyway so we should be able to kill this. - nextEffect.effectTag &= ~Placement; + nextEffect.flags &= ~Placement; break; } @@ -19511,7 +19387,7 @@ function commitMutationEffects(root, renderPriorityLevel) { commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is // inserted, before any life-cycles like componentDidMount gets called. - nextEffect.effectTag &= ~Placement; // Update + nextEffect.flags &= ~Placement; // Update var _current = nextEffect.alternate; commitWork(_current, nextEffect); @@ -19519,12 +19395,12 @@ function commitMutationEffects(root, renderPriorityLevel) { } case Hydrating: { - nextEffect.effectTag &= ~Hydrating; + nextEffect.flags &= ~Hydrating; break; } case HydratingAndUpdate: { - nextEffect.effectTag &= ~Hydrating; // Update + nextEffect.flags &= ~Hydrating; // Update var _current2 = nextEffect.alternate; commitWork(_current2, nextEffect); @@ -19551,15 +19427,15 @@ function commitMutationEffects(root, renderPriorityLevel) { function commitLayoutEffects(root, committedLanes) { while (nextEffect !== null) { setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; + var flags = nextEffect.flags; - if (effectTag & (Update | Callback)) { + if (flags & (Update | Callback)) { var current = nextEffect.alternate; commitLifeCycles(root, current, nextEffect); } { - if (effectTag & Ref) { + if (flags & Ref) { commitAttachRef(nextEffect); } } @@ -19578,12 +19454,8 @@ function flushPassiveEffects() { : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = NoPriority$1; - try { - setCurrentUpdateLanePriority( - schedulerPriorityToLanePriority(priorityLevel) - ); + { return runWithPriority(priorityLevel, flushPassiveEffectsImpl); - } finally { } } @@ -19604,11 +19476,11 @@ function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { pendingPassiveHookEffectsUnmount.push(effect, fiber); { - fiber.effectTag |= PassiveUnmountPendingDev; + fiber.flags |= PassiveUnmountPendingDev; var alternate = fiber.alternate; if (alternate !== null) { - alternate.effectTag |= PassiveUnmountPendingDev; + alternate.flags |= PassiveUnmountPendingDev; } } @@ -19664,11 +19536,11 @@ function flushPassiveEffectsImpl() { _effect.destroy = undefined; { - fiber.effectTag &= ~PassiveUnmountPendingDev; + fiber.flags &= ~PassiveUnmountPendingDev; var alternate = fiber.alternate; if (alternate !== null) { - alternate.effectTag &= ~PassiveUnmountPendingDev; + alternate.flags &= ~PassiveUnmountPendingDev; } } @@ -19731,7 +19603,7 @@ function flushPassiveEffectsImpl() { effect.nextEffect = null; - if (effect.effectTag & Deletion) { + if (effect.flags & Deletion) { detachFiberAfterEffects(effect); } @@ -19826,6 +19698,24 @@ function captureCommitPhaseError(sourceFiber, error) { markRootUpdated(root, SyncLane, eventTime); ensureRootIsScheduled(root, eventTime); schedulePendingInteractions(root, SyncLane); + } else { + // This component has already been unmounted. + // We can't schedule any follow up work for the root because the fiber is already unmounted, + // but we can still call the log-only boundary so the error isn't swallowed. + // + // TODO This is only a temporary bandaid for the old reconciler fork. + // We can delete this special case once the new fork is merged. + if ( + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance) + ) { + try { + instance.componentDidCatch(error, errorInfo); + } catch (errorToIgnore) { + // TODO Ignore this error? Rethrow it? + // This is kind of an edge case. + } + } } return; @@ -19940,33 +19830,6 @@ function jnd(timeElapsed) { : ceil(timeElapsed / 1960) * 1960; } -function computeMsUntilSuspenseLoadingDelay( - mostRecentEventTime, - suspenseConfig -) { - var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; - - if (busyMinDurationMs <= 0) { - return 0; - } - - var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. - - var currentTimeMs = now(); - var eventTimeMs = mostRecentEventTime; - var timeElapsed = currentTimeMs - eventTimeMs; - - if (timeElapsed <= busyDelayMs) { - // If we haven't yet waited longer than the initial delay, we don't - // have to wait any additional time. - return 0; - } - - var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`. - - return msUntilTimeout; -} - function checkForNestedUpdates() { if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { nestedUpdateCount = 0; @@ -20086,7 +19949,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { } // If there are pending passive effects unmounts for this Fiber, // we can assume that they would have prevented this update. - if ((fiber.effectTag & PassiveUnmountPendingDev) !== NoEffect) { + if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) { return; } // We show the whole stack but dedupe on the top component's name because // the problematic code almost always lies inside that component. @@ -20219,7 +20082,7 @@ function warnAboutRenderPhaseUpdatesInDEV(fiber) { error( "Cannot update a component (`%s`) while rendering a " + "different component (`%s`). To locate the bad setState() call inside `%s`, " + - "follow the stack trace as described in https://fb.me/setstate-in-render", + "follow the stack trace as described in https://reactjs.org/link/setstate-in-render", setStateComponentName, renderingComponentName, renderingComponentName @@ -20303,7 +20166,7 @@ function warnIfNotCurrentlyActingEffectsInDEV(fiber) { "/* 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", + " Learn more at https://reactjs.org/link/wrap-tests-with-act", getComponentName(fiber.type) ); } @@ -20332,7 +20195,7 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { "/* 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", + " Learn more at https://reactjs.org/link/wrap-tests-with-act", getComponentName(fiber.type) ); } finally { @@ -20368,7 +20231,7 @@ function warnIfUnmockedScheduler(fiber) { "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + - "For more info, visit https://fb.me/react-mock-scheduler" + "For more info, visit https://reactjs.org/link/mock-scheduler" ); } else { didWarnAboutUnmockedScheduler = true; @@ -20379,7 +20242,7 @@ function warnIfUnmockedScheduler(fiber) { "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + - "For more info, visit https://fb.me/react-mock-scheduler" + "For more info, visit https://reactjs.org/link/mock-scheduler" ); } } @@ -20523,16 +20386,14 @@ function finishPendingInteractions(root, committedLanes) { }); } } // `act` testing API -// -// TODO: This is mostly a copy-paste from the legacy `act`, which does not have -// access to the same internals that we do here. Some trade offs in the -// implementation no longer make sense. - -var isFlushingAct = false; function shouldForceFlushFallbacksInDEV() { - return isFlushingAct; + // Never force flush in production. This function should get stripped out. + return actingUpdatesScopeDepth > 0; } +// so we can tell if any async act() calls try to run in parallel. + +var actingUpdatesScopeDepth = 0; function detachFiberAfterEffects(fiber) { fiber.sibling = null; @@ -21014,7 +20875,7 @@ function FiberNode(tag, pendingProps, key, mode) { this.dependencies = null; this.mode = mode; // Effects - this.effectTag = NoEffect; + this.flags = NoFlags; this.nextEffect = null; this.firstEffect = null; this.lastEffect = null; @@ -21144,7 +21005,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.type = current.type; // We already have an alternate. // Reset the effect tag. - workInProgress.effectTag = NoEffect; // The effect list is no longer valid. + workInProgress.flags = NoFlags; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -21218,7 +21079,7 @@ function resetWorkInProgress(workInProgress, renderLanes) { // avoid doing another reconciliation. // Reset the effect tag but keep any Placement tags, since that's something // that child fiber is setting, not the reconciliation. - workInProgress.effectTag &= Placement; // The effect list is no longer valid. + workInProgress.flags &= Placement; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -21427,6 +21288,11 @@ function createFiberFromTypeAndProps( fiber.elementType = type; fiber.type = resolvedType; fiber.lanes = lanes; + + { + fiber._debugOwner = owner; + } + return fiber; } function createFiberFromElement(element, mode, lanes) { @@ -21579,7 +21445,7 @@ function assignFiberPropertiesInDEV(target, source) { target.memoizedState = source.memoizedState; target.dependencies = source.dependencies; target.mode = source.mode; - target.effectTag = source.effectTag; + target.flags = source.flags; target.nextEffect = source.nextEffect; target.firstEffect = source.firstEffect; target.lastEffect = source.lastEffect; @@ -21745,7 +21611,7 @@ function findHostInstanceWithWarning(component, methodName) { "%s was passed an instance of %s which is inside StrictMode. " + "Instead, add a ref directly to the element you want to reference. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", + "https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName @@ -21756,7 +21622,7 @@ function findHostInstanceWithWarning(component, methodName) { "%s was passed an instance of %s which renders StrictMode children. " + "Instead, add a ref directly to the element you want to reference. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", + "https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName @@ -21797,8 +21663,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(current$1, suspenseConfig); + var lane = requestUpdateLane(current$1); var context = getContextForSubtree(parentComponent); @@ -21822,7 +21687,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var update = createUpdate(eventTime, lane, suspenseConfig); // Caution: React DevTools currently depends on this property + var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property // being called "element". update.payload = { @@ -21872,28 +21737,102 @@ function shouldSuspend(fiber) { return shouldSuspendImpl(fiber); } var overrideHookState = null; +var overrideHookStateDeletePath = null; +var overrideHookStateRenamePath = null; var overrideProps = null; +var overridePropsDeletePath = null; +var overridePropsRenamePath = null; var scheduleUpdate = null; var setSuspenseHandler = null; { - var copyWithSetImpl = function(obj, path, idx, value) { - if (idx >= path.length) { + var copyWithDeleteImpl = function(obj, path, index) { + var key = path[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === path.length) { + if (Array.isArray(updated)) { + updated.splice(key, 1); + } else { + delete updated[key]; + } + + return updated; + } // $FlowFixMe number or string is fine here + + updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); + return updated; + }; + + var copyWithDelete = function(obj, path) { + return copyWithDeleteImpl(obj, path, 0); + }; + + var copyWithRenameImpl = function(obj, oldPath, newPath, index) { + var oldKey = oldPath[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === oldPath.length) { + var newKey = newPath[index]; // $FlowFixMe number or string is fine here + + updated[newKey] = updated[oldKey]; + + if (Array.isArray(updated)) { + updated.splice(oldKey, 1); + } else { + delete updated[oldKey]; + } + } else { + // $FlowFixMe number or string is fine here + updated[oldKey] = copyWithRenameImpl( + // $FlowFixMe number or string is fine here + obj[oldKey], + oldPath, + newPath, + index + 1 + ); + } + + return updated; + }; + + var copyWithRename = function(obj, oldPath, newPath) { + if (oldPath.length !== newPath.length) { + warn("copyWithRename() expects paths of the same length"); + + return; + } else { + for (var i = 0; i < newPath.length - 1; i++) { + if (oldPath[i] !== newPath[i]) { + warn( + "copyWithRename() expects paths to be the same except for the deepest key" + ); + + return; + } + } + } + + return copyWithRenameImpl(obj, oldPath, newPath, 0); + }; + + var copyWithSetImpl = function(obj, path, index, value) { + if (index >= path.length) { return value; } - var key = path[idx]; + var key = path[index]; var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); // $FlowFixMe number or string is fine here - updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value); + updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); return updated; }; var copyWithSet = function(obj, path, value) { return copyWithSetImpl(obj, path, 0, value); - }; // Support DevTools editable values for useState and useReducer. + }; - overrideHookState = function(fiber, id, path, value) { + var findHook = function(fiber, id) { // For now, the "id" of stateful hooks is just the stateful hook index. // This may change in the future with e.g. nested hooks. var currentHook = fiber.memoizedState; @@ -21903,10 +21842,50 @@ var setSuspenseHandler = null; id--; } - if (currentHook !== null) { - var newState = copyWithSet(currentHook.memoizedState, path, value); - currentHook.memoizedState = newState; - currentHook.baseState = newState; // We aren't actually adding an update to the queue, + return currentHook; + }; // Support DevTools editable values for useState and useReducer. + + overrideHookState = function(fiber, id, path, value) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithSet(hook.memoizedState, path, value); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateDeletePath = function(fiber, id, path) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithDelete(hook.memoizedState, path); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithRename(hook.memoizedState, oldPath, newPath); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, // because there is no update we can add for useReducer hooks that won't trigger an error. // (There's no appropriate action type for DevTools overrides.) // As a result though, React will see the scheduled update as a noop and bailout. @@ -21927,6 +21906,26 @@ var setSuspenseHandler = null; scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; + overridePropsDeletePath = function(fiber, path) { + fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsRenamePath = function(fiber, oldPath, newPath) { + fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + scheduleUpdate = function(fiber) { scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; @@ -21963,7 +21962,11 @@ function injectIntoDevTools(devToolsConfig) { rendererPackageName: devToolsConfig.rendererPackageName, rendererConfig: devToolsConfig.rendererConfig, overrideHookState: overrideHookState, + overrideHookStateDeletePath: overrideHookStateDeletePath, + overrideHookStateRenamePath: overrideHookStateRenamePath, overrideProps: overrideProps, + overridePropsDeletePath: overridePropsDeletePath, + overridePropsRenamePath: overridePropsRenamePath, setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, @@ -21980,9 +21983,6 @@ function injectIntoDevTools(devToolsConfig) { }); } -// TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.0-alpha.0"; - var emptyObject$1 = {}; { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js index d837754c50d25c..773e112c1ff12c 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js @@ -24,21 +24,7 @@ var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. -// Current owner and dispatcher used to share the same ref, -// but PR #14548 split them out to better support the react-debug-tools package. - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; -} - -if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; -} + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // by calls to these methods by a Babel plugin. // @@ -80,19 +66,12 @@ function printWarning(level, format, args) { // When changing this logic, you might want to also // update consoleWithStackDev.www.js as well. { - var hasExistingStack = - args.length > 0 && - typeof args[args.length - 1] === "string" && - args[args.length - 1].indexOf("\n in") === 0; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); - if (!hasExistingStack) { - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - - if (stack !== "") { - format += "%s"; - args = args.concat([stack]); - } + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { @@ -104,161 +83,10 @@ function printWarning(level, format, args) { // eslint-disable-next-line react-internal/no-production-logging Function.prototype.apply.call(console[level], console, argsWithFormat); - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = - "Warning: " + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - } -} - -var FunctionComponent = 0; -var ClassComponent = 1; -var IndeterminateComponent = 2; // Before we know whether it is function or class - -var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - -var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - -var HostComponent = 5; -var HostText = 6; -var Fragment = 7; -var Mode = 8; -var ContextConsumer = 9; -var ContextProvider = 10; -var ForwardRef = 11; -var Profiler = 12; -var SuspenseComponent = 13; -var MemoComponent = 14; -var SimpleMemoComponent = 15; -var LazyComponent = 16; -var IncompleteClassComponent = 17; -var DehydratedFragment = 18; -var SuspenseListComponent = 19; -var FundamentalComponent = 20; -var ScopeComponent = 21; -var Block = 22; - -function getParent(inst) { - do { - inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. - // That is depending on if we want nested subtrees (layers) to bubble - // events to their parent. We could also go through parentNode on the - // host node but that wouldn't work for React Native and doesn't let us - // do the portal feature. - } while (inst && inst.tag !== HostComponent); - - if (inst) { - return inst; - } - - return null; -} -/** - * Return the lowest common ancestor of A and B, or null if they are in - * different trees. - */ - -function getLowestCommonAncestor(instA, instB) { - var depthA = 0; - - for (var tempA = instA; tempA; tempA = getParent(tempA)) { - depthA++; - } - - var depthB = 0; - - for (var tempB = instB; tempB; tempB = getParent(tempB)) { - depthB++; - } // If A is deeper, crawl up. - - while (depthA - depthB > 0) { - instA = getParent(instA); - depthA--; - } // If B is deeper, crawl up. - - while (depthB - depthA > 0) { - instB = getParent(instB); - depthB--; - } // Walk in lockstep until we find a match. - - var depth = depthA; - - while (depth--) { - if (instA === instB || instA === instB.alternate) { - return instA; - } - - instA = getParent(instA); - instB = getParent(instB); - } - - return null; -} -/** - * Return if A is an ancestor of B. - */ - -function isAncestor(instA, instB) { - while (instB) { - if (instA === instB || instA === instB.alternate) { - return true; - } - - instB = getParent(instB); - } - - return false; -} -/** - * Return the parent instance of the passed-in instance. - */ - -function getParentInstance(inst) { - return getParent(inst); -} -/** - * Simulates the traversal of a two-phase, capture/bubble event dispatch. - */ - -function traverseTwoPhase(inst, fn, arg) { - var path = []; - - while (inst) { - path.push(inst); - inst = getParent(inst); - } - - var i; - - for (i = path.length; i-- > 0; ) { - fn(path[i], "captured", arg); - } - - for (i = 0; i < path.length; i++) { - fn(path[i], "bubbled", arg); } } -var invokeGuardedCallbackImpl = function( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { +function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -266,7 +94,9 @@ var invokeGuardedCallbackImpl = function( } catch (error) { this.onError(error); } -}; +} + +var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; { // In DEV mode, we swap out invokeGuardedCallback for a special version @@ -297,7 +127,7 @@ var invokeGuardedCallbackImpl = function( ) { var fakeNode = document.createElement("react"); - var invokeGuardedCallbackDev = function( + invokeGuardedCallbackImpl = function invokeGuardedCallbackDev( name, func, context, @@ -310,7 +140,7 @@ var invokeGuardedCallbackImpl = function( ) { // If document doesn't exist we know for sure we will crash in this method // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebookincubator/create-react-app/issues/3482 + // errors: https://github.com/facebook/create-react-app/issues/3482 // So we preemptively throw with a better message instead. if (!(typeof document !== "undefined")) { throw Error( @@ -318,7 +148,8 @@ var invokeGuardedCallbackImpl = function( ); } - var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We + var evt = document.createEvent("Event"); + var didCall = false; // Keeps track of whether the user-provided callback threw an error. We // set this to true at the beginning, then set it to false right after // calling the function. If the function errors, `didError` will never be // set to false. This strategy works even if the browser is flaky and @@ -335,13 +166,9 @@ var invokeGuardedCallbackImpl = function( var windowEventDescriptor = Object.getOwnPropertyDescriptor( window, "event" - ); // Create an event handler for our fake event. We will synchronously - // dispatch our fake event using `dispatchEvent`. Inside the handler, we - // call the user-provided callback. - - var funcArgs = Array.prototype.slice.call(arguments, 3); + ); - function callCallback() { + function restoreAfterDispatch() { // We immediately remove the callback from event listeners so that // nested `invokeGuardedCallback` calls do not clash. Otherwise, a // nested call would trigger the fake event handlers of any call higher @@ -357,7 +184,15 @@ var invokeGuardedCallbackImpl = function( ) { window.event = windowEvent; } + } // Create an event handler for our fake event. We will synchronously + // dispatch our fake event using `dispatchEvent`. Inside the handler, we + // call the user-provided callback. + + var funcArgs = Array.prototype.slice.call(arguments, 3); + function callCallback() { + didCall = true; + restoreAfterDispatch(); func.apply(context, funcArgs); didError = false; } // Create a global error event handler. We use this to capture the value @@ -412,7 +247,7 @@ var invokeGuardedCallbackImpl = function( Object.defineProperty(window, "event", windowEventDescriptor); } - if (didError) { + if (didCall && didError) { if (!didSetError) { // The callback errored, but the error event never fired. error = new Error( @@ -429,7 +264,7 @@ var invokeGuardedCallbackImpl = function( 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." + "See https://reactjs.org/link/crossorigin-error for more information." ); } @@ -437,9 +272,16 @@ var invokeGuardedCallbackImpl = function( } // Remove our event listeners window.removeEventListener("error", handleWindowError); - }; - invokeGuardedCallbackImpl = invokeGuardedCallbackDev; + if (!didCall) { + // Something went really wrong, and our event was not dispatched. + // https://github.com/facebook/react/issues/16734 + // https://github.com/facebook/react/issues/16585 + // Fall back to the production implementation. + restoreAfterDispatch(); + return invokeGuardedCallbackProd.apply(this, arguments); + } + }; } } @@ -708,293 +550,53 @@ function hasDispatches(event) { return !!event._dispatchListeners; } -function isInteractive(tag) { - return ( - tag === "button" || - tag === "input" || - tag === "select" || - tag === "textarea" - ); -} - -function shouldPreventMouseEvent(name, type, props) { - switch (name) { - case "onClick": - case "onClickCapture": - case "onDoubleClick": - case "onDoubleClickCapture": - case "onMouseDown": - case "onMouseDownCapture": - case "onMouseMove": - case "onMouseMoveCapture": - case "onMouseUp": - case "onMouseUpCapture": - case "onMouseEnter": - return !!(props.disabled && isInteractive(type)); - - default: - return false; - } -} +var EVENT_POOL_SIZE = 10; /** - * @param {object} inst The instance, which is the source of events. - * @param {string} registrationName Name of listener (e.g. `onClick`). - * @return {?function} The stored callback. + * @interface Event + * @see http://www.w3.org/TR/DOM-Level-3-Events/ */ -function getListener(inst, registrationName) { - var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not - // live here; needs to be moved to a better place soon - - var stateNode = inst.stateNode; - - if (!stateNode) { - // Work in progress (ex: onload events in incremental mode). - return null; - } - - var props = getFiberCurrentPropsFromNode(stateNode); - - if (!props) { - // Work in progress. - return null; - } - - listener = props[registrationName]; - - if (shouldPreventMouseEvent(registrationName, inst.type, props)) { +var EventInterface = { + type: null, + target: null, + // currentTarget is set when dispatching; no use in copying it here + currentTarget: function() { return null; - } - - if (!(!listener || typeof listener === "function")) { - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - } + }, + eventPhase: null, + bubbles: null, + cancelable: null, + timeStamp: function(event) { + return event.timeStamp || Date.now(); + }, + defaultPrevented: null, + isTrusted: null +}; - return listener; +function functionThatReturnsTrue() { + return true; } +function functionThatReturnsFalse() { + return false; +} /** - * Accumulates items that must not be null or undefined into the first one. This - * is used to conserve memory by avoiding array allocations, and thus sacrifices - * API cleanness. Since `current` can be null before being passed in and not - * null after this function, make sure to assign it back to `current`: + * Synthetic events are dispatched by event plugins, typically in response to a + * top-level event delegation handler. * - * `a = accumulateInto(a, b);` + * These systems should generally use pooling to reduce the frequency of garbage + * collection. The system should check `isPersistent` to determine whether the + * event should be released into the pool after being dispatched. Users that + * need a persisted event should invoke `persist`. * - * This API should be sparingly used. Try `accumulate` for something cleaner. + * Synthetic events (and subclasses) implement the DOM Level 3 Events API by + * normalizing browser quirks. Subclasses do not necessarily have to implement a + * DOM interface; custom application-specific events can also subclass this. * - * @return {*|array<*>} An accumulation of items. - */ - -function accumulateInto(current, next) { - if (!(next != null)) { - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - } - - if (current == null) { - return next; - } // Both are not empty. Warning: Never call x.concat(y) when you are not - // certain that x is an Array (x could be a string with concat method). - - if (Array.isArray(current)) { - if (Array.isArray(next)) { - current.push.apply(current, next); - return current; - } - - current.push(next); - return current; - } - - if (Array.isArray(next)) { - // A bit too dangerous to mutate `next`. - return [current].concat(next); - } - - return [current, next]; -} - -/** - * @param {array} arr an "accumulation" of items which is either an Array or - * a single item. Useful when paired with the `accumulate` module. This is a - * simple utility that allows us to reason about a collection of items, but - * handling the case when there is exactly one item (and we do not need to - * allocate an array). - * @param {function} cb Callback invoked with each element or a collection. - * @param {?} [scope] Scope used as `this` in a callback. - */ -function forEachAccumulated(arr, cb, scope) { - if (Array.isArray(arr)) { - arr.forEach(cb, scope); - } else if (arr) { - cb.call(scope, arr); - } -} - -/** - * Some event types have a notion of different registration names for different - * "phases" of propagation. This finds listeners by a given phase. - */ -function listenerAtPhase(inst, event, propagationPhase) { - var registrationName = - event.dispatchConfig.phasedRegistrationNames[propagationPhase]; - return getListener(inst, registrationName); -} -/** - * A small set of propagation patterns, each of which will accept a small amount - * of information, and generate a set of "dispatch ready event objects" - which - * are sets of events that have already been annotated with a set of dispatched - * listener functions/ids. The API is designed this way to discourage these - * propagation strategies from actually executing the dispatches, since we - * always want to collect the entire set of dispatches before executing even a - * single one. - */ - -/** - * Tags a `SyntheticEvent` with dispatched listeners. Creating this function - * here, allows us to not have to bind or create functions for each event. - * Mutating the event's members allows us to not have to create a wrapping - * "dispatch" object that pairs the event with the listener. - */ - -function accumulateDirectionalDispatches(inst, phase, event) { - { - if (!inst) { - error("Dispatching inst must not be null"); - } - } - - var listener = listenerAtPhase(inst, event, phase); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } -} -/** - * Collect dispatches (must be entirely collected before dispatching - see unit - * tests). Lazily allocate the array to conserve memory. We must loop through - * each event and perform the traversal for each one. We cannot perform a - * single traversal for the entire collection of events because each event may - * have a different target. - */ - -function accumulateTwoPhaseDispatchesSingle(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); - } -} -/** - * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. - */ - -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - var parentInst = targetInst ? getParentInstance(targetInst) : null; - traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); - } -} -/** - * Accumulates without regard to direction, does not look for phased - * registration names. Same as `accumulateDirectDispatchesSingle` but without - * requiring that the `dispatchMarker` be the same as the dispatched ID. - */ - -function accumulateDispatches(inst, ignoredDirection, event) { - if (inst && event && event.dispatchConfig.registrationName) { - var registrationName = event.dispatchConfig.registrationName; - var listener = getListener(inst, registrationName); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } - } -} -/** - * Accumulates dispatches on an `SyntheticEvent`, but only for the - * `dispatchMarker`. - * @param {SyntheticEvent} event - */ - -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - accumulateDispatches(event._targetInst, null, event); - } -} - -function accumulateTwoPhaseDispatches(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); -} -function accumulateTwoPhaseDispatchesSkipTarget(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); -} -function accumulateDirectDispatches(events) { - forEachAccumulated(events, accumulateDirectDispatchesSingle); -} - -var EVENT_POOL_SIZE = 10; -/** - * @interface Event - * @see http://www.w3.org/TR/DOM-Level-3-Events/ - */ - -var EventInterface = { - type: null, - target: null, - // currentTarget is set when dispatching; no use in copying it here - currentTarget: function() { - return null; - }, - eventPhase: null, - bubbles: null, - cancelable: null, - timeStamp: function(event) { - return event.timeStamp || Date.now(); - }, - defaultPrevented: null, - isTrusted: null -}; - -function functionThatReturnsTrue() { - return true; -} - -function functionThatReturnsFalse() { - return false; -} -/** - * Synthetic events are dispatched by event plugins, typically in response to a - * top-level event delegation handler. - * - * These systems should generally use pooling to reduce the frequency of garbage - * collection. The system should check `isPersistent` to determine whether the - * event should be released into the pool after being dispatched. Users that - * need a persisted event should invoke `persist`. - * - * Synthetic events (and subclasses) implement the DOM Level 3 Events API by - * normalizing browser quirks. Subclasses do not necessarily have to implement a - * DOM interface; custom application-specific events can also subclass this. - * - * @param {object} dispatchConfig Configuration used to dispatch this event. - * @param {*} targetInst Marker identifying the event target. - * @param {object} nativeEvent Native browser event. - * @param {DOMEventTarget} nativeEventTarget Target node. + * @param {object} dispatchConfig Configuration used to dispatch this event. + * @param {*} targetInst Marker identifying the event target. + * @param {object} nativeEvent Native browser event. + * @param {DOMEventTarget} nativeEventTarget Target node. */ function SyntheticEvent( @@ -1015,6 +617,8 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; + this._dispatchListeners = null; + this._dispatchInstances = null; var Interface = this.constructor.Interface; for (var propName in Interface) { @@ -1203,13 +807,6 @@ addEventPoolingTo(SyntheticEvent); */ function getPooledWarningPropertyDefinition(propName, getVal) { - var isFunction = typeof getVal === "function"; - return { - configurable: true, - set: set, - get: get - }; - function set(val) { var action = isFunction ? "setting the method" : "setting the property"; warn(action, "This is effectively a no-op"); @@ -1231,16 +828,28 @@ function getPooledWarningPropertyDefinition(propName, getVal) { "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + "If you must keep the original synthetic event around, use event.persist(). " + - "See https://fb.me/react-event-pooling for more information.", + "See https://reactjs.org/link/event-pooling for more information.", action, propName, result ); } } + + var isFunction = typeof getVal === "function"; + return { + configurable: true, + set: set, + get: get + }; } -function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { +function createOrGetPooledEvent( + dispatchConfig, + targetInst, + nativeEvent, + nativeInst +) { var EventConstructor = this; if (EventConstructor.eventPool.length) { @@ -1280,8 +889,8 @@ function releasePooledEvent(event) { } function addEventPoolingTo(EventConstructor) { + EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; - EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } @@ -1547,50 +1156,139 @@ function accumulate(current, next) { } /** - * Instance of element that should respond to touch/move types of interactions, - * as indicated explicitly by relevant callbacks. + * Accumulates items that must not be null or undefined into the first one. This + * is used to conserve memory by avoiding array allocations, and thus sacrifices + * API cleanness. Since `current` can be null before being passed in and not + * null after this function, make sure to assign it back to `current`: + * + * `a = accumulateInto(a, b);` + * + * This API should be sparingly used. Try `accumulate` for something cleaner. + * + * @return {*|array<*>} An accumulation of items. */ -var responderInst = null; -/** - * Count of current touches. A textInput should become responder iff the - * selection changes while there is a touch on the screen. - */ +function accumulateInto(current, next) { + if (!(next != null)) { + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } -var trackedTouchCount = 0; + if (current == null) { + return next; + } // Both are not empty. Warning: Never call x.concat(y) when you are not + // certain that x is an Array (x could be a string with concat method). -var changeResponder = function(nextResponderInst, blockHostResponder) { - var oldResponderInst = responderInst; - responderInst = nextResponderInst; + if (Array.isArray(current)) { + if (Array.isArray(next)) { + current.push.apply(current, next); + return current; + } - if (ResponderEventPlugin.GlobalResponderHandler !== null) { - ResponderEventPlugin.GlobalResponderHandler.onChange( - oldResponderInst, - nextResponderInst, - blockHostResponder - ); + current.push(next); + return current; } -}; -var eventTypes = { - /** - * On a `touchStart`/`mouseDown`, is it desired that this element become the - * responder? - */ - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" - }, - dependencies: startDependencies - }, + if (Array.isArray(next)) { + // A bit too dangerous to mutate `next`. + return [current].concat(next); + } - /** - * On a `scroll`, is it desired that this element become the responder? This - * is usually not needed, but should be used to retroactively infer that a - * `touchStart` had occurred during momentum scroll. During a momentum scroll, - * a touch start will be immediately followed by a scroll event if the view is - * currently scrolling. + return [current, next]; +} + +/** + * @param {array} arr an "accumulation" of items which is either an Array or + * a single item. Useful when paired with the `accumulate` module. This is a + * simple utility that allows us to reason about a collection of items, but + * handling the case when there is exactly one item (and we do not need to + * allocate an array). + * @param {function} cb Callback invoked with each element or a collection. + * @param {?} [scope] Scope used as `this` in a callback. + */ +function forEachAccumulated(arr, cb, scope) { + if (Array.isArray(arr)) { + arr.forEach(cb, scope); + } else if (arr) { + cb.call(scope, arr); + } +} + +var FunctionComponent = 0; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class + +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; +var DehydratedFragment = 18; +var SuspenseListComponent = 19; +var FundamentalComponent = 20; +var ScopeComponent = 21; +var Block = 22; +var OffscreenComponent = 23; +var LegacyHiddenComponent = 24; + +/** + * Instance of element that should respond to touch/move types of interactions, + * as indicated explicitly by relevant callbacks. + */ + +var responderInst = null; +/** + * Count of current touches. A textInput should become responder iff the + * selection changes while there is a touch on the screen. + */ + +var trackedTouchCount = 0; + +var changeResponder = function(nextResponderInst, blockHostResponder) { + var oldResponderInst = responderInst; + responderInst = nextResponderInst; + + if (ResponderEventPlugin.GlobalResponderHandler !== null) { + ResponderEventPlugin.GlobalResponderHandler.onChange( + oldResponderInst, + nextResponderInst, + blockHostResponder + ); + } +}; + +var eventTypes = { + /** + * On a `touchStart`/`mouseDown`, is it desired that this element become the + * responder? + */ + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" + }, + dependencies: startDependencies + }, + + /** + * On a `scroll`, is it desired that this element become the responder? This + * is usually not needed, but should be used to retroactively infer that a + * `touchStart` had occurred during momentum scroll. During a momentum scroll, + * a touch start will be immediately followed by a scroll event if the view is + * currently scrolling. * * TODO: This shouldn't bubble. */ @@ -1664,610 +1362,818 @@ var eventTypes = { registrationName: "onResponderTerminate", dependencies: [] } -}; +}; // Start of inline: the below functions were inlined from +// EventPropagator.js, as they deviated from ReactDOM's newer +// implementations. + +function getParent(inst) { + do { + inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. + // That is depending on if we want nested subtrees (layers) to bubble + // events to their parent. We could also go through parentNode on the + // host node but that wouldn't work for React Native and doesn't let us + // do the portal feature. + } while (inst && inst.tag !== HostComponent); + + if (inst) { + return inst; + } + + return null; +} /** - * - * Responder System: - * ---------------- - * - * - A global, solitary "interaction lock" on a view. - * - If a node becomes the responder, it should convey visual feedback - * immediately to indicate so, either by highlighting or moving accordingly. - * - To be the responder means, that touches are exclusively important to that - * responder view, and no other view. - * - While touches are still occurring, the responder lock can be transferred to - * a new view, but only to increasingly "higher" views (meaning ancestors of - * the current responder). - * - * Responder being granted: - * ------------------------ - * - * - Touch starts, moves, and scrolls can cause an ID to become the responder. - * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to - * the "appropriate place". - * - If nothing is currently the responder, the "appropriate place" is the - * initiating event's `targetID`. - * - If something *is* already the responder, the "appropriate place" is the - * first common ancestor of the event target and the current `responderInst`. - * - Some negotiation happens: See the timing diagram below. - * - Scrolled views automatically become responder. The reasoning is that a - * platform scroll view that isn't built on top of the responder system has - * began scrolling, and the active responder must now be notified that the - * interaction is no longer locked to it - the system has taken over. - * - * - Responder being released: - * As soon as no more touches that *started* inside of descendants of the - * *current* responderInst, an `onResponderRelease` event is dispatched to the - * current responder, and the responder lock is released. - * - * TODO: - * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that - * determines if the responder lock should remain. - * - If a view shouldn't "remain" the responder, any active touches should by - * default be considered "dead" and do not influence future negotiations or - * bubble paths. It should be as if those touches do not exist. - * -- For multitouch: Usually a translate-z will choose to "remain" responder - * after one out of many touches ended. For translate-y, usually the view - * doesn't wish to "remain" responder after one of many touches end. - * - Consider building this on top of a `stopPropagation` model similar to - * `W3C` events. - * - Ensure that `onResponderTerminate` is called on touch cancels, whether or - * not `onResponderTerminationRequest` returns `true` or `false`. - * + * Return the lowest common ancestor of A and B, or null if they are in + * different trees. */ -/* Negotiation Performed - +-----------------------+ - / \ -Process low level events to + Current Responder + wantsResponderID -determine who to perform negot-| (if any exists at all) | -iation/transition | Otherwise just pass through| --------------------------------+----------------------------+------------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchStart| | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderReject - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderStart| - | | +----------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchMove | | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderRejec| - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderMove | - | | +----------------+ - | | - | | - Some active touch started| | - inside current responder | +------------------------+ | - +------------------------->| onResponderEnd | | - | | +------------------------+ | - +---+---------+ | | - | onTouchEnd | | | - +---+---------+ | | - | | +------------------------+ | - +------------------------->| onResponderEnd | | - No active touches started| +-----------+------------+ | - inside current responder | | | - | v | - | +------------------------+ | - | | onResponderRelease | | - | +------------------------+ | - | | - + + */ +function getLowestCommonAncestor(instA, instB) { + var depthA = 0; -/** - * A note about event ordering in the `EventPluginRegistry`. - * - * Suppose plugins are injected in the following order: - * - * `[R, S, C]` - * - * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for - * `onClick` etc) and `R` is `ResponderEventPlugin`. - * - * "Deferred-Dispatched Events": - * - * - The current event plugin system will traverse the list of injected plugins, - * in order, and extract events by collecting the plugin's return value of - * `extractEvents()`. - * - These events that are returned from `extractEvents` are "deferred - * dispatched events". - * - When returned from `extractEvents`, deferred-dispatched events contain an - * "accumulation" of deferred dispatches. - * - These deferred dispatches are accumulated/collected before they are - * returned, but processed at a later time by the `EventPluginRegistry` (hence the - * name deferred). - * - * In the process of returning their deferred-dispatched events, event plugins - * themselves can dispatch events on-demand without returning them from - * `extractEvents`. Plugins might want to do this, so that they can use event - * dispatching as a tool that helps them decide which events should be extracted - * in the first place. - * - * "On-Demand-Dispatched Events": - * - * - On-demand-dispatched events are not returned from `extractEvents`. - * - On-demand-dispatched events are dispatched during the process of returning - * the deferred-dispatched events. - * - They should not have side effects. - * - They should be avoided, and/or eventually be replaced with another - * abstraction that allows event plugins to perform multiple "rounds" of event - * extraction. - * - * Therefore, the sequence of event dispatches becomes: - * - * - `R`s on-demand events (if any) (dispatched by `R` on-demand) - * - `S`s on-demand events (if any) (dispatched by `S` on-demand) - * - `C`s on-demand events (if any) (dispatched by `C` on-demand) - * - `R`s extracted events (if any) (dispatched by `EventPluginRegistry`) - * - `S`s extracted events (if any) (dispatched by `EventPluginRegistry`) - * - `C`s extracted events (if any) (dispatched by `EventPluginRegistry`) - * - * In the case of `ResponderEventPlugin`: If the `startShouldSetResponder` - * on-demand dispatch returns `true` (and some other details are satisfied) the - * `onResponderGrant` deferred dispatched event is returned from - * `extractEvents`. The sequence of dispatch executions in this case - * will appear as follows: - * - * - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand) - * - `touchStartCapture` (`EventPluginRegistry` dispatches as usual) - * - `touchStart` (`EventPluginRegistry` dispatches as usual) - * - `responderGrant/Reject` (`EventPluginRegistry` dispatches as usual) - */ - -function setResponderAndExtractTransfer( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget -) { - var shouldSetEventType = isStartish(topLevelType) - ? eventTypes.startShouldSetResponder - : isMoveish(topLevelType) - ? eventTypes.moveShouldSetResponder - : topLevelType === TOP_SELECTION_CHANGE - ? eventTypes.selectionChangeShouldSetResponder - : eventTypes.scrollShouldSetResponder; // TODO: stop one short of the current responder. - - var bubbleShouldSetFrom = !responderInst - ? targetInst - : getLowestCommonAncestor(responderInst, targetInst); // When capturing/bubbling the "shouldSet" event, we want to skip the target - // (deepest ID) if it happens to be the current responder. The reasoning: - // It's strange to get an `onMoveShouldSetResponder` when you're *already* - // the responder. - - var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst; - var shouldSetEvent = ResponderSyntheticEvent.getPooled( - shouldSetEventType, - bubbleShouldSetFrom, - nativeEvent, - nativeEventTarget - ); - shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - - if (skipOverBubbleShouldSetFrom) { - accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent); - } else { - accumulateTwoPhaseDispatches(shouldSetEvent); + for (var tempA = instA; tempA; tempA = getParent(tempA)) { + depthA++; } - var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent); + var depthB = 0; - if (!shouldSetEvent.isPersistent()) { - shouldSetEvent.constructor.release(shouldSetEvent); - } + for (var tempB = instB; tempB; tempB = getParent(tempB)) { + depthB++; + } // If A is deeper, crawl up. - if (!wantsResponderInst || wantsResponderInst === responderInst) { - return null; - } + while (depthA - depthB > 0) { + instA = getParent(instA); + depthA--; + } // If B is deeper, crawl up. - var extracted; - var grantEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderGrant, - wantsResponderInst, - nativeEvent, - nativeEventTarget - ); - grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(grantEvent); - var blockHostResponder = executeDirectDispatch(grantEvent) === true; + while (depthB - depthA > 0) { + instB = getParent(instB); + depthB--; + } // Walk in lockstep until we find a match. - if (responderInst) { - var terminationRequestEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderTerminationRequest, - responderInst, - nativeEvent, - nativeEventTarget - ); - terminationRequestEvent.touchHistory = - ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(terminationRequestEvent); - var shouldSwitch = - !hasDispatches(terminationRequestEvent) || - executeDirectDispatch(terminationRequestEvent); + var depth = depthA; - if (!terminationRequestEvent.isPersistent()) { - terminationRequestEvent.constructor.release(terminationRequestEvent); + while (depth--) { + if (instA === instB || instA === instB.alternate) { + return instA; } - if (shouldSwitch) { - var terminateEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderTerminate, - responderInst, - nativeEvent, - nativeEventTarget - ); - terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(terminateEvent); - extracted = accumulate(extracted, [grantEvent, terminateEvent]); - changeResponder(wantsResponderInst, blockHostResponder); - } else { - var rejectEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderReject, - wantsResponderInst, - nativeEvent, - nativeEventTarget - ); - rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(rejectEvent); - extracted = accumulate(extracted, rejectEvent); - } - } else { - extracted = accumulate(extracted, grantEvent); - changeResponder(wantsResponderInst, blockHostResponder); + instA = getParent(instA); + instB = getParent(instB); } - return extracted; + return null; } /** - * A transfer is a negotiation between a currently set responder and the next - * element to claim responder status. Any start event could trigger a transfer - * of responderInst. Any move event could trigger a transfer. - * - * @param {string} topLevelType Record from `BrowserEventConstants`. - * @return {boolean} True if a transfer of responder could possibly occur. + * Return if A is an ancestor of B. */ -function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { - return ( - topLevelInst && // responderIgnoreScroll: We are trying to migrate away from specifically - // tracking native scroll events here and responderIgnoreScroll indicates we - // will send topTouchCancel to handle canceling touch events instead - ((topLevelType === TOP_SCROLL && !nativeEvent.responderIgnoreScroll) || - (trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE) || - isStartish(topLevelType) || - isMoveish(topLevelType)) - ); +function isAncestor(instA, instB) { + while (instB) { + if (instA === instB || instA === instB.alternate) { + return true; + } + + instB = getParent(instB); + } + + return false; } /** - * Returns whether or not this touch end event makes it such that there are no - * longer any touches that started inside of the current `responderInst`. - * - * @param {NativeEvent} nativeEvent Native touch end event. - * @return {boolean} Whether or not this touch end event ends the responder. + * Simulates the traversal of a two-phase, capture/bubble event dispatch. */ -function noResponderTouches(nativeEvent) { - var touches = nativeEvent.touches; +function traverseTwoPhase(inst, fn, arg) { + var path = []; - if (!touches || touches.length === 0) { - return true; + while (inst) { + path.push(inst); + inst = getParent(inst); } - for (var i = 0; i < touches.length; i++) { - var activeTouch = touches[i]; - var target = activeTouch.target; - - if (target !== null && target !== undefined && target !== 0) { - // Is the original touch location inside of the current responder? - var targetInst = getInstanceFromNode(target); + var i; - if (isAncestor(responderInst, targetInst)) { - return false; - } - } + for (i = path.length; i-- > 0; ) { + fn(path[i], "captured", arg); } - return true; + for (i = 0; i < path.length; i++) { + fn(path[i], "bubbled", arg); + } } -var ResponderEventPlugin = { - /* For unit testing only */ - _getResponder: function() { - return responderInst; - }, - eventTypes: eventTypes, +function getListener(inst, registrationName) { + var stateNode = inst.stateNode; - /** - * We must be resilient to `targetInst` being `null` on `touchMove` or - * `touchEnd`. On certain platforms, this means that a native scroll has - * assumed control and the original touch targets are destroyed. - */ - extractEvents: function( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget, - eventSystemFlags - ) { - if (isStartish(topLevelType)) { - trackedTouchCount += 1; - } else if (isEndish(topLevelType)) { - if (trackedTouchCount >= 0) { - trackedTouchCount -= 1; - } else { - { - warn( - "Ended a touch event which was not counted in `trackedTouchCount`." - ); - } + if (stateNode === null) { + // Work in progress (ex: onload events in incremental mode). + return null; + } - return null; - } - } + var props = getFiberCurrentPropsFromNode(stateNode); - ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); - var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) - ? setResponderAndExtractTransfer( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget - ) - : null; // Responder may or may not have transferred on a new touch start/move. - // Regardless, whoever is the responder after any potential transfer, we - // direct all touch start/move/ends to them in the form of - // `onResponderMove/Start/End`. These will be called for *every* additional - // finger that move/start/end, dispatched directly to whoever is the - // current responder at that moment, until the responder is "released". - // - // These multiple individual change touch events are are always bookended - // by `onResponderGrant`, and one of - // (`onResponderRelease/onResponderTerminate`). + if (props === null) { + // Work in progress. + return null; + } - var isResponderTouchStart = responderInst && isStartish(topLevelType); - var isResponderTouchMove = responderInst && isMoveish(topLevelType); - var isResponderTouchEnd = responderInst && isEndish(topLevelType); - var incrementalTouch = isResponderTouchStart - ? eventTypes.responderStart - : isResponderTouchMove - ? eventTypes.responderMove - : isResponderTouchEnd - ? eventTypes.responderEnd - : null; + var listener = props[registrationName]; - if (incrementalTouch) { - var gesture = ResponderSyntheticEvent.getPooled( - incrementalTouch, - responderInst, - nativeEvent, - nativeEventTarget - ); - gesture.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(gesture); - extracted = accumulate(extracted, gesture); - } + if (!(!listener || typeof listener === "function")) { + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } - var isResponderTerminate = - responderInst && topLevelType === TOP_TOUCH_CANCEL; - var isResponderRelease = - responderInst && - !isResponderTerminate && - isEndish(topLevelType) && - noResponderTouches(nativeEvent); - var finalTouch = isResponderTerminate - ? eventTypes.responderTerminate - : isResponderRelease - ? eventTypes.responderRelease - : null; + return listener; +} - if (finalTouch) { - var finalEvent = ResponderSyntheticEvent.getPooled( - finalTouch, - responderInst, - nativeEvent, - nativeEventTarget - ); - finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(finalEvent); - extracted = accumulate(extracted, finalEvent); - changeResponder(null); - } +function listenerAtPhase(inst, event, propagationPhase) { + var registrationName = + event.dispatchConfig.phasedRegistrationNames[propagationPhase]; + return getListener(inst, registrationName); +} - return extracted; - }, - GlobalResponderHandler: null, - injection: { - /** - * @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler - * Object that handles any change in responder. Use this to inject - * integration with an existing touch handling system etc. - */ - injectGlobalResponderHandler: function(GlobalResponderHandler) { - ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; +function accumulateDirectionalDispatches(inst, phase, event) { + { + if (!inst) { + error("Dispatching inst must not be null"); } } -}; -/** - * Injectable ordering of event plugins. - */ -var eventPluginOrder = null; -/** - * Injectable mapping from names to event plugin modules. - */ + var listener = listenerAtPhase(inst, event, phase); -var namesToPlugins = {}; + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } +} /** - * Recomputes the plugin list using the injected plugins and plugin ordering. - * - * @private + * Accumulates without regard to direction, does not look for phased + * registration names. Same as `accumulateDirectDispatchesSingle` but without + * requiring that the `dispatchMarker` be the same as the dispatched ID. */ -function recomputePluginOrdering() { - if (!eventPluginOrder) { - // Wait until an `eventPluginOrder` is injected. - return; - } - - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName]; - var pluginIndex = eventPluginOrder.indexOf(pluginName); - - if (!(pluginIndex > -1)) { - throw Error( - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + - pluginName + - "`." - ); - } - - if (plugins[pluginIndex]) { - continue; - } +function accumulateDispatches(inst, ignoredDirection, event) { + if (inst && event && event.dispatchConfig.registrationName) { + var registrationName = event.dispatchConfig.registrationName; + var listener = getListener(inst, registrationName); - if (!pluginModule.extractEvents) { - throw Error( - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + - pluginName + - "` does not." + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener ); - } - - plugins[pluginIndex] = pluginModule; - var publishedEvents = pluginModule.eventTypes; - - for (var eventName in publishedEvents) { - if ( - !publishEventForPlugin( - publishedEvents[eventName], - pluginModule, - eventName - ) - ) { - throw Error( - "EventPluginRegistry: Failed to publish event `" + - eventName + - "` for plugin `" + - pluginName + - "`." - ); - } + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); } } } /** - * Publishes an event so that it can be dispatched by the supplied plugin. - * - * @param {object} dispatchConfig Dispatch configuration for the event. - * @param {object} PluginModule Plugin publishing the event. - * @return {boolean} True if the event was successfully published. - * @private + * Accumulates dispatches on an `SyntheticEvent`, but only for the + * `dispatchMarker`. + * @param {SyntheticEvent} event */ -function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { - throw Error( - "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + - eventName + - "`." - ); +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + accumulateDispatches(event._targetInst, null, event); } +} - eventNameDispatchConfigs[eventName] = dispatchConfig; - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - - if (phasedRegistrationNames) { - for (var phaseName in phasedRegistrationNames) { - if (phasedRegistrationNames.hasOwnProperty(phaseName)) { - var phasedRegistrationName = phasedRegistrationNames[phaseName]; - publishRegistrationName( - phasedRegistrationName, - pluginModule, - eventName - ); - } - } +function accumulateDirectDispatches(events) { + forEachAccumulated(events, accumulateDirectDispatchesSingle); +} - return true; - } else if (dispatchConfig.registrationName) { - publishRegistrationName( - dispatchConfig.registrationName, - pluginModule, - eventName - ); - return true; +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + var parentInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); } +} - return false; +function accumulateTwoPhaseDispatchesSkipTarget(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); } -/** - * Publishes a registration name that is used to identify dispatched events. - * - * @param {string} registrationName Registration name to add. - * @param {object} PluginModule Plugin publishing the event. - * @private - */ -function publishRegistrationName(registrationName, pluginModule, eventName) { - if (!!registrationNameModules[registrationName]) { - throw Error( - "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + - registrationName + - "`." - ); +function accumulateTwoPhaseDispatchesSingle(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); } +} - registrationNameModules[registrationName] = pluginModule; - registrationNameDependencies[registrationName] = - pluginModule.eventTypes[eventName].dependencies; +function accumulateTwoPhaseDispatches(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); +} // End of inline - { - var lowerCasedName = registrationName.toLowerCase(); - } -} /** - * Registers plugins so that they can extract and dispatch events. + * + * Responder System: + * ---------------- + * + * - A global, solitary "interaction lock" on a view. + * - If a node becomes the responder, it should convey visual feedback + * immediately to indicate so, either by highlighting or moving accordingly. + * - To be the responder means, that touches are exclusively important to that + * responder view, and no other view. + * - While touches are still occurring, the responder lock can be transferred to + * a new view, but only to increasingly "higher" views (meaning ancestors of + * the current responder). + * + * Responder being granted: + * ------------------------ + * + * - Touch starts, moves, and scrolls can cause an ID to become the responder. + * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to + * the "appropriate place". + * - If nothing is currently the responder, the "appropriate place" is the + * initiating event's `targetID`. + * - If something *is* already the responder, the "appropriate place" is the + * first common ancestor of the event target and the current `responderInst`. + * - Some negotiation happens: See the timing diagram below. + * - Scrolled views automatically become responder. The reasoning is that a + * platform scroll view that isn't built on top of the responder system has + * began scrolling, and the active responder must now be notified that the + * interaction is no longer locked to it - the system has taken over. + * + * - Responder being released: + * As soon as no more touches that *started* inside of descendants of the + * *current* responderInst, an `onResponderRelease` event is dispatched to the + * current responder, and the responder lock is released. + * + * TODO: + * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that + * determines if the responder lock should remain. + * - If a view shouldn't "remain" the responder, any active touches should by + * default be considered "dead" and do not influence future negotiations or + * bubble paths. It should be as if those touches do not exist. + * -- For multitouch: Usually a translate-z will choose to "remain" responder + * after one out of many touches ended. For translate-y, usually the view + * doesn't wish to "remain" responder after one of many touches end. + * - Consider building this on top of a `stopPropagation` model similar to + * `W3C` events. + * - Ensure that `onResponderTerminate` is called on touch cancels, whether or + * not `onResponderTerminationRequest` returns `true` or `false`. + * + */ + +/* Negotiation Performed + +-----------------------+ + / \ +Process low level events to + Current Responder + wantsResponderID +determine who to perform negot-| (if any exists at all) | +iation/transition | Otherwise just pass through| +-------------------------------+----------------------------+------------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchStart| | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderReject + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderStart| + | | +----------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchMove | | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderRejec| + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderMove | + | | +----------------+ + | | + | | + Some active touch started| | + inside current responder | +------------------------+ | + +------------------------->| onResponderEnd | | + | | +------------------------+ | + +---+---------+ | | + | onTouchEnd | | | + +---+---------+ | | + | | +------------------------+ | + +------------------------->| onResponderEnd | | + No active touches started| +-----------+------------+ | + inside current responder | | | + | v | + | +------------------------+ | + | | onResponderRelease | | + | +------------------------+ | + | | + + + */ + +/** + * A note about event ordering in the `EventPluginRegistry`. + * + * Suppose plugins are injected in the following order: + * + * `[R, S, C]` + * + * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for + * `onClick` etc) and `R` is `ResponderEventPlugin`. + * + * "Deferred-Dispatched Events": + * + * - The current event plugin system will traverse the list of injected plugins, + * in order, and extract events by collecting the plugin's return value of + * `extractEvents()`. + * - These events that are returned from `extractEvents` are "deferred + * dispatched events". + * - When returned from `extractEvents`, deferred-dispatched events contain an + * "accumulation" of deferred dispatches. + * - These deferred dispatches are accumulated/collected before they are + * returned, but processed at a later time by the `EventPluginRegistry` (hence the + * name deferred). + * + * In the process of returning their deferred-dispatched events, event plugins + * themselves can dispatch events on-demand without returning them from + * `extractEvents`. Plugins might want to do this, so that they can use event + * dispatching as a tool that helps them decide which events should be extracted + * in the first place. + * + * "On-Demand-Dispatched Events": + * + * - On-demand-dispatched events are not returned from `extractEvents`. + * - On-demand-dispatched events are dispatched during the process of returning + * the deferred-dispatched events. + * - They should not have side effects. + * - They should be avoided, and/or eventually be replaced with another + * abstraction that allows event plugins to perform multiple "rounds" of event + * extraction. + * + * Therefore, the sequence of event dispatches becomes: + * + * - `R`s on-demand events (if any) (dispatched by `R` on-demand) + * - `S`s on-demand events (if any) (dispatched by `S` on-demand) + * - `C`s on-demand events (if any) (dispatched by `C` on-demand) + * - `R`s extracted events (if any) (dispatched by `EventPluginRegistry`) + * - `S`s extracted events (if any) (dispatched by `EventPluginRegistry`) + * - `C`s extracted events (if any) (dispatched by `EventPluginRegistry`) + * + * In the case of `ResponderEventPlugin`: If the `startShouldSetResponder` + * on-demand dispatch returns `true` (and some other details are satisfied) the + * `onResponderGrant` deferred dispatched event is returned from + * `extractEvents`. The sequence of dispatch executions in this case + * will appear as follows: + * + * - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand) + * - `touchStartCapture` (`EventPluginRegistry` dispatches as usual) + * - `touchStart` (`EventPluginRegistry` dispatches as usual) + * - `responderGrant/Reject` (`EventPluginRegistry` dispatches as usual) + */ + +function setResponderAndExtractTransfer( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget +) { + var shouldSetEventType = isStartish(topLevelType) + ? eventTypes.startShouldSetResponder + : isMoveish(topLevelType) + ? eventTypes.moveShouldSetResponder + : topLevelType === TOP_SELECTION_CHANGE + ? eventTypes.selectionChangeShouldSetResponder + : eventTypes.scrollShouldSetResponder; // TODO: stop one short of the current responder. + + var bubbleShouldSetFrom = !responderInst + ? targetInst + : getLowestCommonAncestor(responderInst, targetInst); // When capturing/bubbling the "shouldSet" event, we want to skip the target + // (deepest ID) if it happens to be the current responder. The reasoning: + // It's strange to get an `onMoveShouldSetResponder` when you're *already* + // the responder. + + var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst; + var shouldSetEvent = ResponderSyntheticEvent.getPooled( + shouldSetEventType, + bubbleShouldSetFrom, + nativeEvent, + nativeEventTarget + ); + shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + + if (skipOverBubbleShouldSetFrom) { + accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent); + } else { + accumulateTwoPhaseDispatches(shouldSetEvent); + } + + var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent); + + if (!shouldSetEvent.isPersistent()) { + shouldSetEvent.constructor.release(shouldSetEvent); + } + + if (!wantsResponderInst || wantsResponderInst === responderInst) { + return null; + } + + var extracted; + var grantEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderGrant, + wantsResponderInst, + nativeEvent, + nativeEventTarget + ); + grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(grantEvent); + var blockHostResponder = executeDirectDispatch(grantEvent) === true; + + if (responderInst) { + var terminationRequestEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderTerminationRequest, + responderInst, + nativeEvent, + nativeEventTarget + ); + terminationRequestEvent.touchHistory = + ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(terminationRequestEvent); + var shouldSwitch = + !hasDispatches(terminationRequestEvent) || + executeDirectDispatch(terminationRequestEvent); + + if (!terminationRequestEvent.isPersistent()) { + terminationRequestEvent.constructor.release(terminationRequestEvent); + } + + if (shouldSwitch) { + var terminateEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderTerminate, + responderInst, + nativeEvent, + nativeEventTarget + ); + terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(terminateEvent); + extracted = accumulate(extracted, [grantEvent, terminateEvent]); + changeResponder(wantsResponderInst, blockHostResponder); + } else { + var rejectEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderReject, + wantsResponderInst, + nativeEvent, + nativeEventTarget + ); + rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(rejectEvent); + extracted = accumulate(extracted, rejectEvent); + } + } else { + extracted = accumulate(extracted, grantEvent); + changeResponder(wantsResponderInst, blockHostResponder); + } + + return extracted; +} +/** + * A transfer is a negotiation between a currently set responder and the next + * element to claim responder status. Any start event could trigger a transfer + * of responderInst. Any move event could trigger a transfer. + * + * @param {string} topLevelType Record from `BrowserEventConstants`. + * @return {boolean} True if a transfer of responder could possibly occur. + */ + +function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { + return ( + topLevelInst && // responderIgnoreScroll: We are trying to migrate away from specifically + // tracking native scroll events here and responderIgnoreScroll indicates we + // will send topTouchCancel to handle canceling touch events instead + ((topLevelType === TOP_SCROLL && !nativeEvent.responderIgnoreScroll) || + (trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE) || + isStartish(topLevelType) || + isMoveish(topLevelType)) + ); +} +/** + * Returns whether or not this touch end event makes it such that there are no + * longer any touches that started inside of the current `responderInst`. + * + * @param {NativeEvent} nativeEvent Native touch end event. + * @return {boolean} Whether or not this touch end event ends the responder. + */ + +function noResponderTouches(nativeEvent) { + var touches = nativeEvent.touches; + + if (!touches || touches.length === 0) { + return true; + } + + for (var i = 0; i < touches.length; i++) { + var activeTouch = touches[i]; + var target = activeTouch.target; + + if (target !== null && target !== undefined && target !== 0) { + // Is the original touch location inside of the current responder? + var targetInst = getInstanceFromNode(target); + + if (isAncestor(responderInst, targetInst)) { + return false; + } + } + } + + return true; +} + +var ResponderEventPlugin = { + /* For unit testing only */ + _getResponder: function() { + return responderInst; + }, + eventTypes: eventTypes, + + /** + * We must be resilient to `targetInst` being `null` on `touchMove` or + * `touchEnd`. On certain platforms, this means that a native scroll has + * assumed control and the original touch targets are destroyed. + */ + extractEvents: function( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget, + eventSystemFlags + ) { + if (isStartish(topLevelType)) { + trackedTouchCount += 1; + } else if (isEndish(topLevelType)) { + if (trackedTouchCount >= 0) { + trackedTouchCount -= 1; + } else { + { + warn( + "Ended a touch event which was not counted in `trackedTouchCount`." + ); + } + + return null; + } + } + + ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); + var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) + ? setResponderAndExtractTransfer( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget + ) + : null; // Responder may or may not have transferred on a new touch start/move. + // Regardless, whoever is the responder after any potential transfer, we + // direct all touch start/move/ends to them in the form of + // `onResponderMove/Start/End`. These will be called for *every* additional + // finger that move/start/end, dispatched directly to whoever is the + // current responder at that moment, until the responder is "released". + // + // These multiple individual change touch events are are always bookended + // by `onResponderGrant`, and one of + // (`onResponderRelease/onResponderTerminate`). + + var isResponderTouchStart = responderInst && isStartish(topLevelType); + var isResponderTouchMove = responderInst && isMoveish(topLevelType); + var isResponderTouchEnd = responderInst && isEndish(topLevelType); + var incrementalTouch = isResponderTouchStart + ? eventTypes.responderStart + : isResponderTouchMove + ? eventTypes.responderMove + : isResponderTouchEnd + ? eventTypes.responderEnd + : null; + + if (incrementalTouch) { + var gesture = ResponderSyntheticEvent.getPooled( + incrementalTouch, + responderInst, + nativeEvent, + nativeEventTarget + ); + gesture.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(gesture); + extracted = accumulate(extracted, gesture); + } + + var isResponderTerminate = + responderInst && topLevelType === TOP_TOUCH_CANCEL; + var isResponderRelease = + responderInst && + !isResponderTerminate && + isEndish(topLevelType) && + noResponderTouches(nativeEvent); + var finalTouch = isResponderTerminate + ? eventTypes.responderTerminate + : isResponderRelease + ? eventTypes.responderRelease + : null; + + if (finalTouch) { + var finalEvent = ResponderSyntheticEvent.getPooled( + finalTouch, + responderInst, + nativeEvent, + nativeEventTarget + ); + finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(finalEvent); + extracted = accumulate(extracted, finalEvent); + changeResponder(null); + } + + return extracted; + }, + GlobalResponderHandler: null, + injection: { + /** + * @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler + * Object that handles any change in responder. Use this to inject + * integration with an existing touch handling system etc. + */ + injectGlobalResponderHandler: function(GlobalResponderHandler) { + ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; + } + } +}; + +/** + * Injectable ordering of event plugins. + */ +var eventPluginOrder = null; +/** + * Injectable mapping from names to event plugin modules. + */ + +var namesToPlugins = {}; +/** + * Recomputes the plugin list using the injected plugins and plugin ordering. + * + * @private + */ + +function recomputePluginOrdering() { + if (!eventPluginOrder) { + // Wait until an `eventPluginOrder` is injected. + return; + } + + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName]; + var pluginIndex = eventPluginOrder.indexOf(pluginName); + + if (!(pluginIndex > -1)) { + throw Error( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + } + + if (plugins[pluginIndex]) { + continue; + } + + if (!pluginModule.extractEvents) { + throw Error( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + } + + plugins[pluginIndex] = pluginModule; + var publishedEvents = pluginModule.eventTypes; + + for (var eventName in publishedEvents) { + if ( + !publishEventForPlugin( + publishedEvents[eventName], + pluginModule, + eventName + ) + ) { + throw Error( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + } + } +} +/** + * Publishes an event so that it can be dispatched by the supplied plugin. + * + * @param {object} dispatchConfig Dispatch configuration for the event. + * @param {object} PluginModule Plugin publishing the event. + * @return {boolean} True if the event was successfully published. + * @private + */ + +function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { + if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { + throw Error( + "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + + eventName + + "`." + ); + } + + eventNameDispatchConfigs[eventName] = dispatchConfig; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + + if (phasedRegistrationNames) { + for (var phaseName in phasedRegistrationNames) { + if (phasedRegistrationNames.hasOwnProperty(phaseName)) { + var phasedRegistrationName = phasedRegistrationNames[phaseName]; + publishRegistrationName( + phasedRegistrationName, + pluginModule, + eventName + ); + } + } + + return true; + } else if (dispatchConfig.registrationName) { + publishRegistrationName( + dispatchConfig.registrationName, + pluginModule, + eventName + ); + return true; + } + + return false; +} +/** + * Publishes a registration name that is used to identify dispatched events. + * + * @param {string} registrationName Registration name to add. + * @param {object} PluginModule Plugin publishing the event. + * @private + */ + +function publishRegistrationName(registrationName, pluginModule, eventName) { + if (!!registrationNameModules[registrationName]) { + throw Error( + "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); + } + + registrationNameModules[registrationName] = pluginModule; + registrationNameDependencies[registrationName] = + pluginModule.eventTypes[eventName].dependencies; + + { + var lowerCasedName = registrationName.toLowerCase(); + } +} +/** + * Registers plugins so that they can extract and dispatch events. */ /** @@ -2352,20 +2258,163 @@ function injectEventPluginsByName(injectedNamesToPlugins) { } } +function getListener$1(inst, registrationName) { + var stateNode = inst.stateNode; + + if (stateNode === null) { + // Work in progress (ex: onload events in incremental mode). + return null; + } + + var props = getFiberCurrentPropsFromNode(stateNode); + + if (props === null) { + // Work in progress. + return null; + } + + var listener = props[registrationName]; + + if (!(!listener || typeof listener === "function")) { + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + + return listener; +} + var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry - .customDirectEventTypes; + .customDirectEventTypes; // Start of inline: the below functions were inlined from +// EventPropagator.js, as they deviated from ReactDOM's newer +// implementations. + +function listenerAtPhase$1(inst, event, propagationPhase) { + var registrationName = + event.dispatchConfig.phasedRegistrationNames[propagationPhase]; + return getListener$1(inst, registrationName); +} + +function accumulateDirectionalDispatches$1(inst, phase, event) { + { + if (!inst) { + error("Dispatching inst must not be null"); + } + } + + var listener = listenerAtPhase$1(inst, event, phase); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } +} + +function getParent$1(inst) { + do { + inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. + // That is depending on if we want nested subtrees (layers) to bubble + // events to their parent. We could also go through parentNode on the + // host node but that wouldn't work for React Native and doesn't let us + // do the portal feature. + } while (inst && inst.tag !== HostComponent); + + if (inst) { + return inst; + } + + return null; +} +/** + * Simulates the traversal of a two-phase, capture/bubble event dispatch. + */ + +function traverseTwoPhase$1(inst, fn, arg) { + var path = []; + + while (inst) { + path.push(inst); + inst = getParent$1(inst); + } + + var i; + + for (i = path.length; i-- > 0; ) { + fn(path[i], "captured", arg); + } + + for (i = 0; i < path.length; i++) { + fn(path[i], "bubbled", arg); + } +} + +function accumulateTwoPhaseDispatchesSingle$1(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + traverseTwoPhase$1( + event._targetInst, + accumulateDirectionalDispatches$1, + event + ); + } +} + +function accumulateTwoPhaseDispatches$1(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1); +} +/** + * Accumulates without regard to direction, does not look for phased + * registration names. Same as `accumulateDirectDispatchesSingle` but without + * requiring that the `dispatchMarker` be the same as the dispatched ID. + */ + +function accumulateDispatches$1(inst, ignoredDirection, event) { + if (inst && event && event.dispatchConfig.registrationName) { + var registrationName = event.dispatchConfig.registrationName; + var listener = getListener$1(inst, registrationName); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } + } +} +/** + * Accumulates dispatches on an `SyntheticEvent`, but only for the + * `dispatchMarker`. + * @param {SyntheticEvent} event + */ + +function accumulateDirectDispatchesSingle$1(event) { + if (event && event.dispatchConfig.registrationName) { + accumulateDispatches$1(event._targetInst, null, event); + } +} + +function accumulateDirectDispatches$1(events) { + forEachAccumulated(events, accumulateDirectDispatchesSingle$1); +} // End of inline + var ReactNativeBridgeEventPlugin = { eventTypes: {}, extractEvents: function( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ) { if (targetInst == null) { // Probably a node belonging to another renderer's tree. @@ -2389,9 +2438,9 @@ var ReactNativeBridgeEventPlugin = { ); if (bubbleDispatchConfig) { - accumulateTwoPhaseDispatches(event); + accumulateTwoPhaseDispatches$1(event); } else if (directDispatchConfig) { - accumulateDirectDispatches(event); + accumulateDirectDispatches$1(event); } else { return null; } @@ -2462,23 +2511,16 @@ function updateFiberProps(tag, props) { instanceProps.set(tag, props); } -var PLUGIN_EVENT_SYSTEM = 1; - -var enableProfilerTimer = true; -var enableFundamentalAPI = false; -var warnAboutStringRefs = false; - +// Used as a way to call batchedUpdates when we don't have a reference to // the renderer. Such as when we're dispatching events or if third party // libraries need to call batchedUpdates. Eventually, this API will go away when // everything is batched by default. We'll then have a similar API to opt-out of // scheduled work and instead do synchronous work. // Defaults - var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; var isInsideEventHandler = false; - function batchedUpdates(fn, bookkeeping) { if (isInsideEventHandler) { // If we are currently inside another batch, we need to wait until it @@ -2636,13 +2678,7 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { } batchedUpdates(function() { - runExtractedPluginEventsInBatch( - topLevelType, - inst, - nativeEvent, - target, - PLUGIN_EVENT_SYSTEM - ); + runExtractedPluginEventsInBatch(topLevelType, inst, nativeEvent, target); }); // React Native doesn't use ReactControlledComponent but if it did, here's // where it would do it. } @@ -2658,22 +2694,21 @@ function extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ) { var events = null; + var legacyPlugins = plugins; - for (var i = 0; i < plugins.length; i++) { + for (var i = 0; i < legacyPlugins.length; i++) { // Not every plugin in the ordering may be loaded at runtime. - var possiblePlugin = plugins[i]; + var possiblePlugin = legacyPlugins[i]; if (possiblePlugin) { var extractedEvents = possiblePlugin.extractEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ); if (extractedEvents) { @@ -2689,15 +2724,13 @@ function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ) { var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget, - eventSystemFlags + nativeEventTarget ); runEventsInBatch(events); } @@ -2810,37 +2843,62 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler( * If this becomes an actual Map, that will break. */ function get(key) { - return key._reactInternalFiber; + return key._reactInternals; } function set(key, value) { - key._reactInternalFiber = value; + key._reactInternals = value; } +// ATTENTION +// When adding new symbols to this file, +// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. -var hasSymbol = typeof Symbol === "function" && Symbol.for; -var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7; -var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca; -var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb; -var REACT_STRICT_MODE_TYPE = hasSymbol - ? Symbol.for("react.strict_mode") - : 0xeacc; -var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; -var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; -var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary -var REACT_CONCURRENT_MODE_TYPE = hasSymbol - ? Symbol.for("react.concurrent_mode") - : 0xeacf; -var REACT_FORWARD_REF_TYPE = hasSymbol - ? Symbol.for("react.forward_ref") - : 0xead0; -var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_SUSPENSE_LIST_TYPE = hasSymbol - ? Symbol.for("react.suspense_list") - : 0xead8; -var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; -var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; -var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 0xead9; +var REACT_ELEMENT_TYPE = 0xeac7; +var REACT_PORTAL_TYPE = 0xeaca; +var REACT_FRAGMENT_TYPE = 0xeacb; +var REACT_STRICT_MODE_TYPE = 0xeacc; +var REACT_PROFILER_TYPE = 0xead2; +var REACT_PROVIDER_TYPE = 0xeacd; +var REACT_CONTEXT_TYPE = 0xeace; +var REACT_FORWARD_REF_TYPE = 0xead0; +var REACT_SUSPENSE_TYPE = 0xead1; +var REACT_SUSPENSE_LIST_TYPE = 0xead8; +var REACT_MEMO_TYPE = 0xead3; +var REACT_LAZY_TYPE = 0xead4; +var REACT_BLOCK_TYPE = 0xead9; +var REACT_SERVER_BLOCK_TYPE = 0xeada; +var REACT_FUNDAMENTAL_TYPE = 0xead5; +var REACT_SCOPE_TYPE = 0xead7; +var REACT_OPAQUE_ID_TYPE = 0xeae0; +var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; +var REACT_OFFSCREEN_TYPE = 0xeae2; +var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; + +if (typeof Symbol === "function" && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor("react.element"); + REACT_PORTAL_TYPE = symbolFor("react.portal"); + REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); + REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); + REACT_PROFILER_TYPE = symbolFor("react.profiler"); + REACT_PROVIDER_TYPE = symbolFor("react.provider"); + REACT_CONTEXT_TYPE = symbolFor("react.context"); + REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); + REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); + REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); + REACT_MEMO_TYPE = symbolFor("react.memo"); + REACT_LAZY_TYPE = symbolFor("react.lazy"); + REACT_BLOCK_TYPE = symbolFor("react.block"); + REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); + REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); + REACT_SCOPE_TYPE = symbolFor("react.scope"); + REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); + REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); + REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); +} + var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { @@ -2859,63 +2917,6 @@ function getIteratorFn(maybeIterable) { return null; } -// TODO: Move this to "react" once we can import from externals. -var Uninitialized = -1; -var Pending = 0; -var Resolved = 1; -var Rejected = 2; - -function refineResolvedLazyComponent(lazyComponent) { - return lazyComponent._status === Resolved ? lazyComponent._result : null; -} -function initializeLazyComponentType(lazyComponent) { - if (lazyComponent._status === Uninitialized) { - var ctor = lazyComponent._result; - - if (!ctor) { - // TODO: Remove this later. THis only exists in case you use an older "react" package. - ctor = lazyComponent._ctor; - } - - var thenable = ctor(); // Transition to the next state. - - var pending = lazyComponent; - pending._status = Pending; - pending._result = thenable; - thenable.then( - function(moduleObject) { - if (lazyComponent._status === Pending) { - var defaultExport = moduleObject.default; - - { - if (defaultExport === undefined) { - error( - "lazy: Expected the result of a dynamic import() call. " + - "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. - "const MyComponent = lazy(() => imp" + - "ort('./MyComponent'))", - moduleObject - ); - } - } // Transition to the next state. - - var resolved = lazyComponent; - resolved._status = Resolved; - resolved._result = defaultExport; - } - }, - function(error) { - if (lazyComponent._status === Pending) { - // Transition to the next state. - var rejected = lazyComponent; - rejected._status = Rejected; - rejected._result = error; - } - } - ); - } -} - function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ""; return ( @@ -2988,17 +2989,18 @@ function getComponentName(type) { return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type.render); + return getComponentName(type._render); case REACT_LAZY_TYPE: { - var thenable = type; - var resolvedThenable = refineResolvedLazyComponent(thenable); + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; - if (resolvedThenable) { - return getComponentName(resolvedThenable); + try { + return getComponentName(init(payload)); + } catch (x) { + return null; } - - break; } } } @@ -3006,64 +3008,74 @@ function getComponentName(type) { return null; } +var enableProfilerTimer = true; +var enableFundamentalAPI = false; +var warnAboutStringRefs = false; +var enableNewReconciler = false; + // Don't change these two values. They're used by React Dev Tools. -var NoEffect = - /* */ +var NoFlags = + /* */ 0; var PerformedWork = - /* */ + /* */ 1; // You can change the rest (and add more). var Placement = - /* */ + /* */ 2; var Update = - /* */ + /* */ 4; var PlacementAndUpdate = - /* */ + /* */ 6; var Deletion = - /* */ + /* */ 8; var ContentReset = - /* */ + /* */ 16; var Callback = - /* */ + /* */ 32; var DidCapture = - /* */ + /* */ 64; var Ref = - /* */ + /* */ 128; var Snapshot = - /* */ + /* */ 256; var Passive = - /* */ + /* */ 512; var Hydrating = - /* */ + /* */ 1024; var HydratingAndUpdate = - /* */ - 1028; // Passive & Update & Callback & Ref & Snapshot - -var LifecycleEffectMask = - /* */ - 932; // Union of all host effects + /* */ + 1028; +var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = - /* */ - 2047; + /* */ + 4095; // These are not really side effects, but we still reuse this field. + var Incomplete = - /* */ - 2048; -var ShouldCapture = - /* */ + /* */ 4096; +var ShouldCapture = + /* */ + 8192; // TODO (effects) Remove this bit once the new reconciler is synced to the old. + +var PassiveUnmountPendingDev = + /* */ + 16384; +var ForceUpdateForLegacySuspense = + /* */ + 32768; // Static tags describe aspects of a fiber that are not specific to a render, var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -3078,7 +3090,7 @@ function getNearestMountedFiber(fiber) { do { node = nextNode; - if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((node.flags & (Placement | Hydrating)) !== NoFlags) { // This is an insertion or in-progress hydration. The nearest possible // mounted fiber is the parent but we need to continue to figure out // if that one is still mounted. @@ -3338,6 +3350,20 @@ function findCurrentHostFiber(parent) { return null; } +function doesFiberContain(parentFiber, childFiber) { + var node = childFiber; + var parentFiberAlternate = parentFiber.alternate; + + while (node !== null) { + if (node === parentFiber || node === parentFiberAlternate) { + return true; + } + + node = node.return; + } + + return false; +} // Modules provided by RN: var emptyObject = {}; @@ -3844,104 +3870,102 @@ function warnForStyleProps(props, validAttributes) { } } -var ReactNativeFiberHostComponent = - /*#__PURE__*/ - (function() { - function ReactNativeFiberHostComponent( - tag, - viewConfig, - internalInstanceHandleDEV - ) { - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; +var ReactNativeFiberHostComponent = /*#__PURE__*/ (function() { + function ReactNativeFiberHostComponent( + tag, + viewConfig, + internalInstanceHandleDEV + ) { + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; - { - this._internalFiberInstanceHandleDEV = internalInstanceHandleDEV; - } + { + this._internalFiberInstanceHandleDEV = internalInstanceHandleDEV; } + } - var _proto = ReactNativeFiberHostComponent.prototype; - - _proto.blur = function blur() { - ReactNativePrivateInterface.TextInputState.blurTextInput(this); - }; - - _proto.focus = function focus() { - ReactNativePrivateInterface.TextInputState.focusTextInput(this); - }; + var _proto = ReactNativeFiberHostComponent.prototype; - _proto.measure = function measure(callback) { - ReactNativePrivateInterface.UIManager.measure( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + _proto.blur = function blur() { + ReactNativePrivateInterface.TextInputState.blurTextInput(this); + }; - _proto.measureInWindow = function measureInWindow(callback) { - ReactNativePrivateInterface.UIManager.measureInWindow( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; + _proto.focus = function focus() { + ReactNativePrivateInterface.TextInputState.focusTextInput(this); + }; - _proto.measureLayout = function measureLayout( - relativeToNativeNode, - onSuccess, - onFail - ) /* currently unused */ - { - var relativeNode; + _proto.measure = function measure(callback) { + ReactNativePrivateInterface.UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - if (typeof relativeToNativeNode === "number") { - // Already a node handle - relativeNode = relativeToNativeNode; - } else { - var nativeNode = relativeToNativeNode; + _proto.measureInWindow = function measureInWindow(callback) { + ReactNativePrivateInterface.UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; - if (nativeNode._nativeTag) { - relativeNode = nativeNode._nativeTag; - } - } + _proto.measureLayout = function measureLayout( + relativeToNativeNode, + onSuccess, + onFail + ) /* currently unused */ + { + var relativeNode; - if (relativeNode == null) { - { - error( - "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." - ); - } + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else { + var nativeNode = relativeToNativeNode; - return; + if (nativeNode._nativeTag) { + relativeNode = nativeNode._nativeTag; } + } - ReactNativePrivateInterface.UIManager.measureLayout( - this._nativeTag, - relativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; - - _proto.setNativeProps = function setNativeProps(nativeProps) { + if (relativeNode == null) { { - warnForStyleProps(nativeProps, this.viewConfig.validAttributes); + error( + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); } - var updatePayload = create(nativeProps, this.viewConfig.validAttributes); // Avoid the overhead of bridge calls if there's no update. - // This is an expensive no-op for Android, and causes an unnecessary - // view invalidation for certain components (eg RCTTextInput) on iOS. + return; + } - if (updatePayload != null) { - ReactNativePrivateInterface.UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - updatePayload - ); - } - }; + ReactNativePrivateInterface.UIManager.measureLayout( + this._nativeTag, + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + }; + + _proto.setNativeProps = function setNativeProps(nativeProps) { + { + warnForStyleProps(nativeProps, this.viewConfig.validAttributes); + } + + var updatePayload = create(nativeProps, this.viewConfig.validAttributes); // Avoid the overhead of bridge calls if there's no update. + // This is an expensive no-op for Android, and causes an unnecessary + // view invalidation for certain components (eg RCTTextInput) on iOS. + + if (updatePayload != null) { + ReactNativePrivateInterface.UIManager.updateView( + this._nativeTag, + this.viewConfig.uiViewClassName, + updatePayload + ); + } + }; - return ReactNativeFiberHostComponent; - })(); // eslint-disable-next-line no-unused-expressions + return ReactNativeFiberHostComponent; +})(); // eslint-disable-next-line no-unused-expressions // can re-export everything from this module. @@ -4104,6 +4128,7 @@ function getPublicInstance(instance) { } function prepareForCommit(containerInfo) { // Noop + return null; } function prepareUpdate( instance, @@ -4121,9 +4146,6 @@ function resetAfterCommit(containerInfo) { var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; -function shouldDeprioritizeSubtree(type, props) { - return false; -} function shouldSetTextContent(type, props) { // TODO (bvaughn) Revisit this decision. // Always returning false simplifies the createInstance() implementation, @@ -4306,525 +4328,242 @@ function unhideInstance(instance, props) { updatePayload ); } +function clearContainer(container) { + // TODO Implement this for React Native + // UIManager does not expose a "remove all" type method. +} function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } - -var loggedTypeFailures = {}; -function checkPropTypes(typeSpecs, values, location, componentName) { - { - // $FlowFixMe This is okay but Flow doesn't know it. - var has = Function.call.bind(Object.prototype.hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - var err = Error( - (componentName || "React class") + - ": " + - location + - " type `" + - typeSpecName + - "` is invalid; " + - "it must be a function, usually from the `prop-types` package, but received `" + - typeof typeSpecs[typeSpecName] + - "`." + - "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." - ); - err.name = "Invariant Violation"; - throw err; - } - - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } - - if (error$1 && !(error$1 instanceof Error)) { - error( - "%s: type specification of %s" + - " `%s` is invalid; the type checker " + - "function must return `null` or an `Error` but returned a %s. " + - "You may have forgotten to pass an argument to the type checker " + - "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + - "shape all require an argument).", - componentName || "React class", - location, - typeSpecName, - typeof error$1 - ); - } - - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - - error("Failed %s type: %s", location, error$1.message); - } - } - } - } -} - -// Prefix measurements so that it's possible to filter them. -// Longer prefixes are hard to read in DevTools. -var reactEmoji = "\u269B"; -var warningEmoji = "\u26D4"; -var supportsUserTiming = - typeof performance !== "undefined" && - typeof performance.mark === "function" && - typeof performance.clearMarks === "function" && - typeof performance.measure === "function" && - typeof performance.clearMeasures === "function"; // Keep track of current fiber so that we know the path to unwind on pause. -// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? - -var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? -// Reusing `currentFiber` would be confusing for this because user code fiber -// can change during commit phase too, but we don't need to unwind it (since -// lifecycles in the commit phase don't resemble a tree). - -var currentPhase = null; -var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, -// so we will keep track of it, and include it in the report. -// Track commits caused by cascading updates. - -var isCommitting = false; -var hasScheduledUpdateInCurrentCommit = false; -var hasScheduledUpdateInCurrentPhase = false; -var commitCountInCurrentWorkLoop = 0; -var effectCountInCurrentCommit = 0; -// to avoid stretch the commit phase with measurement overhead. - -var labelsInCurrentCommit = new Set(); - -var formatMarkName = function(markName) { - return reactEmoji + " " + markName; -}; - -var formatLabel = function(label, warning) { - var prefix = warning ? warningEmoji + " " : reactEmoji + " "; - var suffix = warning ? " Warning: " + warning : ""; - return "" + prefix + label + suffix; -}; - -var beginMark = function(markName) { - performance.mark(formatMarkName(markName)); -}; - -var clearMark = function(markName) { - performance.clearMarks(formatMarkName(markName)); -}; - -var endMark = function(label, markName, warning) { - var formattedMarkName = formatMarkName(markName); - var formattedLabel = formatLabel(label, warning); - - try { - performance.measure(formattedLabel, formattedMarkName); - } catch (err) {} // If previous mark was missing for some reason, this will throw. - // This could only happen if React crashed in an unexpected place earlier. - // Don't pile on with more errors. - // Clear marks immediately to avoid growing buffer. - - performance.clearMarks(formattedMarkName); - performance.clearMeasures(formattedLabel); -}; - -var getFiberMarkName = function(label, debugID) { - return label + " (#" + debugID + ")"; -}; - -var getFiberLabel = function(componentName, isMounted, phase) { - if (phase === null) { - // These are composite component total time measurements. - return componentName + " [" + (isMounted ? "update" : "mount") + "]"; - } else { - // Composite component methods. - return componentName + "." + phase; - } -}; - -var beginFiberMark = function(fiber, phase) { - var componentName = getComponentName(fiber.type) || "Unknown"; - var debugID = fiber._debugID; - var isMounted = fiber.alternate !== null; - var label = getFiberLabel(componentName, isMounted, phase); - - if (isCommitting && labelsInCurrentCommit.has(label)) { - // During the commit phase, we don't show duplicate labels because - // there is a fixed overhead for every measurement, and we don't - // want to stretch the commit phase beyond necessary. - return false; - } - - labelsInCurrentCommit.add(label); - var markName = getFiberMarkName(label, debugID); - beginMark(markName); - return true; -}; - -var clearFiberMark = function(fiber, phase) { - var componentName = getComponentName(fiber.type) || "Unknown"; - var debugID = fiber._debugID; - var isMounted = fiber.alternate !== null; - var label = getFiberLabel(componentName, isMounted, phase); - var markName = getFiberMarkName(label, debugID); - clearMark(markName); -}; - -var endFiberMark = function(fiber, phase, warning) { - var componentName = getComponentName(fiber.type) || "Unknown"; - var debugID = fiber._debugID; - var isMounted = fiber.alternate !== null; - var label = getFiberLabel(componentName, isMounted, phase); - var markName = getFiberMarkName(label, debugID); - endMark(label, markName, warning); -}; - -var shouldIgnoreFiber = function(fiber) { - // Host components should be skipped in the timeline. - // We could check typeof fiber.type, but does this work with RN? - switch (fiber.tag) { - case HostRoot: - case HostComponent: - case HostText: - case HostPortal: - case Fragment: - case ContextProvider: - case ContextConsumer: - case Mode: - return true; - - default: - return false; - } -}; - -var clearPendingPhaseMeasurement = function() { - if (currentPhase !== null && currentPhaseFiber !== null) { - clearFiberMark(currentPhaseFiber, currentPhase); - } - - currentPhaseFiber = null; - currentPhase = null; - hasScheduledUpdateInCurrentPhase = false; -}; - -var pauseTimers = function() { - // Stops all currently active measurements so that they can be resumed - // if we continue in a later deferred loop from the same unit of work. - var fiber = currentFiber; - - while (fiber) { - if (fiber._debugIsCurrentlyTiming) { - endFiberMark(fiber, null, null); - } - - fiber = fiber.return; - } -}; - -var resumeTimersRecursively = function(fiber) { - if (fiber.return !== null) { - resumeTimersRecursively(fiber.return); - } - - if (fiber._debugIsCurrentlyTiming) { - beginFiberMark(fiber, null); - } -}; - -var resumeTimers = function() { - // Resumes all measurements that were active during the last deferred loop. - if (currentFiber !== null) { - resumeTimersRecursively(currentFiber); - } -}; - -function recordEffect() { - { - effectCountInCurrentCommit++; - } -} -function recordScheduleUpdate() { - { - if (isCommitting) { - hasScheduledUpdateInCurrentCommit = true; - } - - if ( - currentPhase !== null && - currentPhase !== "componentWillMount" && - currentPhase !== "componentWillReceiveProps" - ) { - hasScheduledUpdateInCurrentPhase = true; - } - } -} -function startWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // If we pause, this is the fiber to unwind from. - - currentFiber = fiber; - - if (!beginFiberMark(fiber, null)) { - return; - } - - fiber._debugIsCurrentlyTiming = true; - } +function makeClientIdInDEV(warnOnAccessInDEV) { + throw new Error("Not yet implemented"); } -function cancelWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // Remember we shouldn't complete measurement for this fiber. - // Otherwise flamechart will be deep even for small updates. - - fiber._debugIsCurrentlyTiming = false; - clearFiberMark(fiber, null); - } -} -function stopWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // If we pause, its parent is the fiber to unwind from. - - currentFiber = fiber.return; - - if (!fiber._debugIsCurrentlyTiming) { - return; - } - - fiber._debugIsCurrentlyTiming = false; - endFiberMark(fiber, null, null); - } +function preparePortalMount(portalInstance) { + // noop } -function stopFailedWorkTimer(fiber) { - { - if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { - return; - } // If we pause, its parent is the fiber to unwind from. - - currentFiber = fiber.return; - if (!fiber._debugIsCurrentlyTiming) { - return; - } - - fiber._debugIsCurrentlyTiming = false; - var warning = - fiber.tag === SuspenseComponent - ? "Rendering was suspended" - : "An error was thrown inside this error boundary"; - endFiberMark(fiber, null, warning); - } -} -function startPhaseTimer(fiber, phase) { +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; +function describeBuiltInComponentFrame(name, source, ownerFn) { { - if (!supportsUserTiming) { - return; - } - - clearPendingPhaseMeasurement(); + var ownerName = null; - if (!beginFiberMark(fiber, phase)) { - return; + if (ownerFn) { + ownerName = ownerFn.displayName || ownerFn.name || null; } - currentPhaseFiber = fiber; - currentPhase = phase; + return describeComponentFrame(name, source, ownerName); } } -function stopPhaseTimer() { - { - if (!supportsUserTiming) { - return; - } +var componentFrameCache; - if (currentPhase !== null && currentPhaseFiber !== null) { - var warning = hasScheduledUpdateInCurrentPhase - ? "Scheduled a cascading update" - : null; - endFiberMark(currentPhaseFiber, currentPhase, warning); - } - - currentPhase = null; - currentPhaseFiber = null; - } +{ + var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap(); } -function startWorkLoopTimer(nextUnitOfWork) { - { - currentFiber = nextUnitOfWork; - - if (!supportsUserTiming) { - return; - } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; - commitCountInCurrentWorkLoop = 0; // This is top level call. - // Any other measurements are performed within. +function describeComponentFrame(name, source, ownerName) { + var sourceInfo = ""; - beginMark("(React Tree Reconciliation)"); // Resume any measurements that were in progress during the last loop. + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". - resumeTimers(); - } -} -function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { - { - if (!supportsUserTiming) { - return; - } + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); - var warning = null; + if (match) { + var pathBeforeSlash = match[1]; - if (interruptedBy !== null) { - if (interruptedBy.tag === HostRoot) { - warning = "A top-level update interrupted the previous render"; - } else { - var componentName = getComponentName(interruptedBy.type) || "Unknown"; - warning = - "An update to " + componentName + " interrupted the previous render"; + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); + fileName = folderName + "/" + fileName; + } } - } else if (commitCountInCurrentWorkLoop > 1) { - warning = "There were cascading updates"; } - commitCountInCurrentWorkLoop = 0; - var label = didCompleteRoot - ? "(React Tree Reconciliation: Completed Root)" - : "(React Tree Reconciliation: Yielded)"; // Pause any measurements until the next loop. - - pauseTimers(); - endMark(label, "(React Tree Reconciliation)", warning); + sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; + } else if (ownerName) { + sourceInfo = " (created by " + ownerName + ")"; } + + return "\n in " + (name || "Unknown") + sourceInfo; } -function startCommitTimer() { - { - if (!supportsUserTiming) { - return; - } - isCommitting = true; - hasScheduledUpdateInCurrentCommit = false; - labelsInCurrentCommit.clear(); - beginMark("(Committing Changes)"); +function describeClassComponentFrame(ctor, source, ownerFn) { + { + return describeFunctionComponentFrame(ctor, source, ownerFn); } } -function stopCommitTimer() { +function describeFunctionComponentFrame(fn, source, ownerFn) { { - if (!supportsUserTiming) { - return; + if (!fn) { + return ""; } - var warning = null; + var name = fn.displayName || fn.name || null; + var ownerName = null; - if (hasScheduledUpdateInCurrentCommit) { - warning = "Lifecycle hook scheduled a cascading update"; - } else if (commitCountInCurrentWorkLoop > 0) { - warning = "Caused by a cascading update in earlier commit"; + if (ownerFn) { + ownerName = ownerFn.displayName || ownerFn.name || null; } - hasScheduledUpdateInCurrentCommit = false; - commitCountInCurrentWorkLoop++; - isCommitting = false; - labelsInCurrentCommit.clear(); - endMark("(Committing Changes)", "(Committing Changes)", warning); + return describeComponentFrame(name, source, ownerName); } } -function startCommitSnapshotEffectsTimer() { - { - if (!supportsUserTiming) { - return; - } - effectCountInCurrentCommit = 0; - beginMark("(Committing Snapshot Effects)"); +function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { + if (type == null) { + return ""; } -} -function stopCommitSnapshotEffectsTimer() { - { - if (!supportsUserTiming) { - return; + + if (typeof type === "function") { + { + return describeFunctionComponentFrame(type, source, ownerFn); } + } - var count = effectCountInCurrentCommit; - effectCountInCurrentCommit = 0; - endMark( - "(Committing Snapshot Effects: " + count + " Total)", - "(Committing Snapshot Effects)", - null - ); + if (typeof type === "string") { + return describeBuiltInComponentFrame(type, source, ownerFn); } -} -function startCommitHostEffectsTimer() { - { - if (!supportsUserTiming) { - return; - } - effectCountInCurrentCommit = 0; - beginMark("(Committing Host Effects)"); + switch (type) { + case REACT_SUSPENSE_TYPE: + return describeBuiltInComponentFrame("Suspense", source, ownerFn); + + case REACT_SUSPENSE_LIST_TYPE: + return describeBuiltInComponentFrame("SuspenseList", source, ownerFn); } -} -function stopCommitHostEffectsTimer() { - { - if (!supportsUserTiming) { - return; - } - var count = effectCountInCurrentCommit; - effectCountInCurrentCommit = 0; - endMark( - "(Committing Host Effects: " + count + " Total)", - "(Committing Host Effects)", - null - ); + if (typeof type === "object") { + switch (type.$$typeof) { + case REACT_FORWARD_REF_TYPE: + return describeFunctionComponentFrame(type.render, source, ownerFn); + + case REACT_MEMO_TYPE: + // Memo may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); + + case REACT_BLOCK_TYPE: + return describeFunctionComponentFrame(type._render, source, ownerFn); + + case REACT_LAZY_TYPE: { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + // Lazy may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV( + init(payload), + source, + ownerFn + ); + } catch (x) {} + } + } } + + return ""; } -function startCommitLifeCyclesTimer() { + +var loggedTypeFailures = {}; +var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + +function setCurrentlyValidatingElement(element) { { - if (!supportsUserTiming) { - return; + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + element._source, + owner ? owner.type : null + ); + ReactDebugCurrentFrame.setExtraStackFrame(stack); + } else { + ReactDebugCurrentFrame.setExtraStackFrame(null); } - - effectCountInCurrentCommit = 0; - beginMark("(Calling Lifecycle Methods)"); } } -function stopCommitLifeCyclesTimer() { + +function checkPropTypes(typeSpecs, values, location, componentName, element) { { - if (!supportsUserTiming) { - return; - } + // $FlowFixMe This is okay but Flow doesn't know it. + var has = Function.call.bind(Object.prototype.hasOwnProperty); - var count = effectCountInCurrentCommit; - effectCountInCurrentCommit = 0; - endMark( - "(Calling Lifecycle Methods: " + count + " Total)", - "(Calling Lifecycle Methods)", - null - ); + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== "function") { + var err = Error( + (componentName || "React class") + + ": " + + location + + " type `" + + typeSpecName + + "` is invalid; " + + "it must be a function, usually from the `prop-types` package, but received `" + + typeof typeSpecs[typeSpecName] + + "`." + + "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." + ); + err.name = "Invariant Violation"; + throw err; + } + + error$1 = typeSpecs[typeSpecName]( + values, + typeSpecName, + componentName, + location, + null, + "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" + ); + } catch (ex) { + error$1 = ex; + } + + if (error$1 && !(error$1 instanceof Error)) { + setCurrentlyValidatingElement(element); + + error( + "%s: type specification of %s" + + " `%s` is invalid; the type checker " + + "function must return `null` or an `Error` but returned a %s. " + + "You may have forgotten to pass an argument to the type checker " + + "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + + "shape all require an argument).", + componentName || "React class", + location, + typeSpecName, + typeof error$1 + ); + + setCurrentlyValidatingElement(null); + } + + if ( + error$1 instanceof Error && + !(error$1.message in loggedTypeFailures) + ) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error$1.message] = true; + setCurrentlyValidatingElement(element); + + error("Failed %s type: %s", location, error$1.message); + + setCurrentlyValidatingElement(null); + } + } + } } } @@ -5031,10 +4770,7 @@ function processChildContext(fiber, type, parentContext) { return parentContext; } - var childContext; - startPhaseTimer(fiber, "getChildContext"); - childContext = instance.getChildContext(); - stopPhaseTimer(); + var childContext = instance.getChildContext(); for (var contextKey in childContext) { if (!(contextKey in childContextTypes)) { @@ -5052,7 +4788,7 @@ function processChildContext(fiber, type, parentContext) { checkPropTypes(childContextTypes, childContext, "child context", name); } - return Object.assign({}, parentContext, {}, childContext); + return Object.assign({}, parentContext, childContext); } } @@ -5155,20 +4891,112 @@ var LegacyRoot = 0; var BlockingRoot = 1; var ConcurrentRoot = 2; +var rendererID = null; +var injectedHook = null; +var hasLoggedError = false; +var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; +function injectInternals(internals) { + if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { + // No DevTools + return false; + } + + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + + if (hook.isDisabled) { + // This isn't a real property on the hook, but it can be set to opt out + // of DevTools integration and associated warnings and logs. + // https://github.com/facebook/react/issues/3877 + return true; + } + + if (!hook.supportsFiber) { + { + error( + "The installed version of React DevTools is too old and will not work " + + "with the current version of React. Please update React DevTools. " + + "https://reactjs.org/link/react-devtools" + ); + } // DevTools exists, even though it doesn't support Fiber. + + return true; + } + + try { + rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + + injectedHook = hook; + } catch (err) { + // Catch all errors because it is unsafe to throw during initialization. + { + error("React instrumentation encountered an error: %s.", err); + } + } // DevTools exists + + return true; +} +function onScheduleRoot(root, children) { + { + if ( + injectedHook && + typeof injectedHook.onScheduleFiberRoot === "function" + ) { + try { + injectedHook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } +} +function onCommitRoot(root, priorityLevel) { + if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") { + try { + var didError = (root.current.flags & DidCapture) === DidCapture; + + if (enableProfilerTimer) { + injectedHook.onCommitFiberRoot( + rendererID, + root, + priorityLevel, + didError + ); + } else { + injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError); + } + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } +} +function onCommitUnmount(fiber) { + if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") { + try { + injectedHook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } +} + // Intentionally not named imports because Rollup would use dynamic dispatch for -var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, - Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, - Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, - Scheduler_shouldYield = Scheduler.unstable_shouldYield, - Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now = Scheduler.unstable_now, - Scheduler_getCurrentPriorityLevel = - Scheduler.unstable_getCurrentPriorityLevel, - Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, - Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, - Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, - Scheduler_LowPriority = Scheduler.unstable_LowPriority, - Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; +var Scheduler_now = Scheduler.unstable_now; { // Provide explicit error message when production+profiling bundle of e.g. @@ -5181,12 +5009,10 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, ) ) { throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); } } - -var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use // ascending numbers so we can compare them like numbers. They start at 90 to // avoid clashing with Scheduler's priorities. @@ -5197,1214 +5023,1437 @@ var LowPriority = 96; var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. var NoPriority = 90; -var shouldYield = Scheduler_shouldYield; -var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. - Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {}; -var syncQueue = null; -var immediateQueueCallbackNode = null; -var isFlushingSyncQueue = false; var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. -// This will be the case for modern browsers that support `performance.now`. In -// older browsers, Scheduler falls back to `Date.now`, which returns a Unix -// timestamp. In that case, subtract the module initialization time to simulate -// the behavior of performance.now and keep our times small enough to fit -// within 32 bits. -// TODO: Consider lifting this into Scheduler. -var now = - initialTimeMs < 10000 - ? Scheduler_now - : function() { - return Scheduler_now() - initialTimeMs; - }; -function getCurrentPriorityLevel() { - switch (Scheduler_getCurrentPriorityLevel()) { - case Scheduler_ImmediatePriority: - return ImmediatePriority; +var SyncLanePriority = 15; +var SyncBatchedLanePriority = 14; +var InputDiscreteHydrationLanePriority = 13; +var InputDiscreteLanePriority = 12; +var InputContinuousHydrationLanePriority = 11; +var InputContinuousLanePriority = 10; +var DefaultHydrationLanePriority = 9; +var DefaultLanePriority = 8; +var TransitionHydrationPriority = 7; +var TransitionPriority = 6; +var RetryLanePriority = 5; +var SelectiveHydrationLanePriority = 4; +var IdleHydrationLanePriority = 3; +var IdleLanePriority = 2; +var OffscreenLanePriority = 1; +var NoLanePriority = 0; +var TotalLanes = 31; +var NoLanes = + /* */ + 0; +var NoLane = + /* */ + 0; +var SyncLane = + /* */ + 1; +var SyncBatchedLane = + /* */ + 2; +var InputDiscreteHydrationLane = + /* */ + 4; +var InputDiscreteLanes = + /* */ + 24; +var InputContinuousHydrationLane = + /* */ + 32; +var InputContinuousLanes = + /* */ + 192; +var DefaultHydrationLane = + /* */ + 256; +var DefaultLanes = + /* */ + 3584; +var TransitionHydrationLane = + /* */ + 4096; +var TransitionLanes = + /* */ + 4186112; +var RetryLanes = + /* */ + 62914560; +var SomeRetryLane = + /* */ + 33554432; +var SelectiveHydrationLane = + /* */ + 67108864; +var NonIdleLanes = + /* */ + 134217727; +var IdleHydrationLane = + /* */ + 134217728; +var IdleLanes = + /* */ + 805306368; +var OffscreenLane = + /* */ + 1073741824; +var NoTimestamp = -1; +// Used by getHighestPriorityLanes and getNextLanes: + +var return_highestLanePriority = DefaultLanePriority; - case Scheduler_UserBlockingPriority: - return UserBlockingPriority; +function getHighestPriorityLanes(lanes) { + if ((SyncLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncLanePriority; + return SyncLane; + } - case Scheduler_NormalPriority: - return NormalPriority; + if ((SyncBatchedLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncBatchedLanePriority; + return SyncBatchedLane; + } - case Scheduler_LowPriority: - return LowPriority; + if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { + return_highestLanePriority = InputDiscreteHydrationLanePriority; + return InputDiscreteHydrationLane; + } - case Scheduler_IdlePriority: - return IdlePriority; + var inputDiscreteLanes = InputDiscreteLanes & lanes; - default: { - throw Error("Unknown priority level."); - } + if (inputDiscreteLanes !== NoLanes) { + return_highestLanePriority = InputDiscreteLanePriority; + return inputDiscreteLanes; } -} -function reactPriorityToSchedulerPriority(reactPriorityLevel) { - switch (reactPriorityLevel) { - case ImmediatePriority: - return Scheduler_ImmediatePriority; + if ((lanes & InputContinuousHydrationLane) !== NoLanes) { + return_highestLanePriority = InputContinuousHydrationLanePriority; + return InputContinuousHydrationLane; + } - case UserBlockingPriority: - return Scheduler_UserBlockingPriority; + var inputContinuousLanes = InputContinuousLanes & lanes; - case NormalPriority: - return Scheduler_NormalPriority; + if (inputContinuousLanes !== NoLanes) { + return_highestLanePriority = InputContinuousLanePriority; + return inputContinuousLanes; + } - case LowPriority: - return Scheduler_LowPriority; + if ((lanes & DefaultHydrationLane) !== NoLanes) { + return_highestLanePriority = DefaultHydrationLanePriority; + return DefaultHydrationLane; + } - case IdlePriority: - return Scheduler_IdlePriority; + var defaultLanes = DefaultLanes & lanes; - default: { - throw Error("Unknown priority level."); - } + if (defaultLanes !== NoLanes) { + return_highestLanePriority = DefaultLanePriority; + return defaultLanes; } -} -function runWithPriority(reactPriorityLevel, fn) { - var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_runWithPriority(priorityLevel, fn); -} -function scheduleCallback(reactPriorityLevel, callback, options) { - var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_scheduleCallback(priorityLevel, callback, options); -} -function scheduleSyncCallback(callback) { - // Push this callback into an internal queue. We'll flush these either in - // the next tick, or earlier if something calls `flushSyncCallbackQueue`. - if (syncQueue === null) { - syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. + if ((lanes & TransitionHydrationLane) !== NoLanes) { + return_highestLanePriority = TransitionHydrationPriority; + return TransitionHydrationLane; + } - immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ); - } else { - // Push onto existing queue. Don't need to schedule a callback because - // we already scheduled one when we created the queue. - syncQueue.push(callback); + var transitionLanes = TransitionLanes & lanes; + + if (transitionLanes !== NoLanes) { + return_highestLanePriority = TransitionPriority; + return transitionLanes; } - return fakeCallbackNode; -} -function cancelCallback(callbackNode) { - if (callbackNode !== fakeCallbackNode) { - Scheduler_cancelCallback(callbackNode); + var retryLanes = RetryLanes & lanes; + + if (retryLanes !== NoLanes) { + return_highestLanePriority = RetryLanePriority; + return retryLanes; } -} -function flushSyncCallbackQueue() { - if (immediateQueueCallbackNode !== null) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); + + if (lanes & SelectiveHydrationLane) { + return_highestLanePriority = SelectiveHydrationLanePriority; + return SelectiveHydrationLane; } - flushSyncCallbackQueueImpl(); -} + if ((lanes & IdleHydrationLane) !== NoLanes) { + return_highestLanePriority = IdleHydrationLanePriority; + return IdleHydrationLane; + } -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrancy. - isFlushingSyncQueue = true; - var i = 0; + var idleLanes = IdleLanes & lanes; - try { - var _isSync = true; - var queue = syncQueue; - runWithPriority(ImmediatePriority, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; + if (idleLanes !== NoLanes) { + return_highestLanePriority = IdleLanePriority; + return idleLanes; + } - do { - callback = callback(_isSync); - } while (callback !== null); - } - }); - syncQueue = null; - } catch (error) { - // If something throws, leave the remaining callbacks on the queue. - if (syncQueue !== null) { - syncQueue = syncQueue.slice(i + 1); - } // Resume flushing in the next tick - - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ); - throw error; - } finally { - isFlushingSyncQueue = false; - } + if ((OffscreenLane & lanes) !== NoLanes) { + return_highestLanePriority = OffscreenLanePriority; + return OffscreenLane; } -} -var NoMode = 0; -var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root -// tag instead + { + error("Should have found matching lanes. This is a bug in React."); + } // This shouldn't be reachable, but as a fallback, return the entire bitmask. -var BlockingMode = 2; -var ConcurrentMode = 4; -var ProfileMode = 8; + return_highestLanePriority = DefaultLanePriority; + return lanes; +} -// Max 31 bit integer. The max integer size in V8 for 32-bit systems. -// Math.pow(2, 30) - 1 -// 0b111111111111111111111111111111 -var MAX_SIGNED_31_BIT_INT = 1073741823; +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case ImmediatePriority: + return SyncLanePriority; -var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that -// Never work can be committed in an inconsistent state without tearing the UI. -// The main example is offscreen content, like a hidden subtree. So one possible -// name is Offscreen. However, it also includes dehydrated Suspense boundaries, -// which are inconsistent in the sense that they haven't finished yet, but -// aren't visibly inconsistent because the server rendered HTML matches what the -// hydrated tree would look like. + case UserBlockingPriority: + return InputContinuousLanePriority; -var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in -// order to be consistent. + case NormalPriority: + case LowPriority: + // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. + return DefaultLanePriority; -var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase -var Sync = MAX_SIGNED_31_BIT_INT; -var Batched = Sync - 1; -var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms. + case IdlePriority: + return IdleLanePriority; -function msToExpirationTime(ms) { - // Always subtract from the offset so that we don't clash with the magic number for NoWork. - return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); -} -function expirationTimeToMs(expirationTime) { - return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; + default: + return NoLanePriority; + } } +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case SyncLanePriority: + case SyncBatchedLanePriority: + return ImmediatePriority; -function ceiling(num, precision) { - return (((num / precision) | 0) + 1) * precision; -} + case InputDiscreteHydrationLanePriority: + case InputDiscreteLanePriority: + case InputContinuousHydrationLanePriority: + case InputContinuousLanePriority: + return UserBlockingPriority; -function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { - return ( - MAGIC_NUMBER_OFFSET - - ceiling( - MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, - bucketSizeMs / UNIT_SIZE - ) - ); -} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update -// the names to reflect. - -var LOW_PRIORITY_EXPIRATION = 5000; -var LOW_PRIORITY_BATCH_SIZE = 250; -function computeAsyncExpiration(currentTime) { - return computeExpirationBucket( - currentTime, - LOW_PRIORITY_EXPIRATION, - LOW_PRIORITY_BATCH_SIZE - ); -} -function computeSuspenseExpiration(currentTime, timeoutMs) { - // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time? - return computeExpirationBucket( - currentTime, - timeoutMs, - LOW_PRIORITY_BATCH_SIZE - ); -} // We intentionally set a higher expiration time for interactive updates in -// dev than in production. -// -// If the main thread is being blocked so long that you hit the expiration, -// it's a problem that could be solved with better scheduling. -// -// People will be more likely to notice this and fix it with the long -// expiration time in development. -// -// In production we opt for better UX at the risk of masking scheduling -// problems, by expiring fast. - -var HIGH_PRIORITY_EXPIRATION = 500; -var HIGH_PRIORITY_BATCH_SIZE = 100; -function computeInteractiveExpiration(currentTime) { - return computeExpirationBucket( - currentTime, - HIGH_PRIORITY_EXPIRATION, - HIGH_PRIORITY_BATCH_SIZE - ); -} -function inferPriorityFromExpirationTime(currentTime, expirationTime) { - if (expirationTime === Sync) { - return ImmediatePriority; - } + case DefaultHydrationLanePriority: + case DefaultLanePriority: + case TransitionHydrationPriority: + case TransitionPriority: + case SelectiveHydrationLanePriority: + case RetryLanePriority: + return NormalPriority; - if (expirationTime === Never || expirationTime === Idle) { - return IdlePriority; - } + case IdleHydrationLanePriority: + case IdleLanePriority: + case OffscreenLanePriority: + return IdlePriority; - var msUntil = - expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); + case NoLanePriority: + return NoPriority; - if (msUntil <= 0) { - return ImmediatePriority; + default: { + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); + } } +} +function getNextLanes(root, wipLanes) { + // Early bailout if there's no pending work left. + var pendingLanes = root.pendingLanes; - if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { - return UserBlockingPriority; + if (pendingLanes === NoLanes) { + return_highestLanePriority = NoLanePriority; + return NoLanes; } - if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { - return NormalPriority; - } // TODO: Handle LowPriority - // Assume anything lower has idle priority + var nextLanes = NoLanes; + var nextLanePriority = NoLanePriority; + var expiredLanes = root.expiredLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; // Check if any work has expired. - return IdlePriority; -} + if (expiredLanes !== NoLanes) { + nextLanes = expiredLanes; + nextLanePriority = return_highestLanePriority = SyncLanePriority; + } else { + // Do not work on any idle work until all the non-idle work has finished, + // even if the work is suspended. + var nonIdlePendingLanes = pendingLanes & NonIdleLanes; -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return ( - (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare - ); -} + if (nonIdlePendingLanes !== NoLanes) { + var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; -var objectIs = typeof Object.is === "function" ? Object.is : is; + if (nonIdleUnblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); + nextLanePriority = return_highestLanePriority; + } else { + var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; -var hasOwnProperty = Object.prototype.hasOwnProperty; -/** - * Performs equality by iterating through keys on an object and returning false - * when any key has values which are not strictly equal between the arguments. - * Returns true when the values of all keys are strictly equal. - */ + if (nonIdlePingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); + nextLanePriority = return_highestLanePriority; + } + } + } else { + // The only remaining work is Idle. + var unblockedLanes = pendingLanes & ~suspendedLanes; -function shallowEqual(objA, objB) { - if (objectIs(objA, objB)) { - return true; + if (unblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(unblockedLanes); + nextLanePriority = return_highestLanePriority; + } else { + if (pingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(pingedLanes); + nextLanePriority = return_highestLanePriority; + } + } + } } + if (nextLanes === NoLanes) { + // This should only be reachable if we're suspended + // TODO: Consider warning in this path if a fallback timer is not scheduled. + return NoLanes; + } // If there are higher priority lanes, we'll include them even if they + // are suspended. + + nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt + // it and we'll lose our progress. We should only do this if the new lanes are + // higher priority. + if ( - typeof objA !== "object" || - objA === null || - typeof objB !== "object" || - objB === null + wipLanes !== NoLanes && + wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't + // bother waiting until the root is complete. + (wipLanes & suspendedLanes) === NoLanes ) { - return false; - } + getHighestPriorityLanes(wipLanes); + var wipLanePriority = return_highestLanePriority; - var keysA = Object.keys(objA); - var keysB = Object.keys(objB); + if (nextLanePriority <= wipLanePriority) { + return wipLanes; + } else { + return_highestLanePriority = nextLanePriority; + } + } // Check for entangled lanes and add them to the batch. + // + // A lane is said to be entangled with another when it's not allowed to render + // in a batch that does not also include the other lane. Typically we do this + // when multiple updates have the same source, and we only want to respond to + // the most recent event from that source. + // + // Note that we apply entanglements *after* checking for partial work above. + // This means that if a lane is entangled during an interleaved event while + // it's already rendering, we won't interrupt it. This is intentional, since + // entanglement is usually "best effort": we'll try our best to render the + // lanes in the same batch, but it's not worth throwing out partially + // completed work in order to do it. + // + // For those exceptions where entanglement is semantically important, like + // useMutableSource, we should ensure that there is no partial work at the + // time we apply the entanglement. - if (keysA.length !== keysB.length) { - return false; - } // Test for A's keys different from B. + var entangledLanes = root.entangledLanes; - for (var i = 0; i < keysA.length; i++) { - if ( - !hasOwnProperty.call(objB, keysA[i]) || - !objectIs(objA[keysA[i]], objB[keysA[i]]) - ) { - return false; + if (entangledLanes !== NoLanes) { + var entanglements = root.entanglements; + var lanes = nextLanes & entangledLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + nextLanes |= entanglements[index]; + lanes &= ~lane; } } - return true; + return nextLanes; } +function getMostRecentEventTime(root, lanes) { + var eventTimes = root.eventTimes; + var mostRecentEventTime = NoTimestamp; -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; -function describeComponentFrame(name, source, ownerName) { - var sourceInfo = ""; - - if (source) { - var path = source.fileName; - var fileName = path.replace(BEFORE_SLASH_RE, ""); - - { - // In DEV, include code for a common special case: - // prefer "folder/index.js" instead of just "index.js". - if (/^index\./.test(fileName)) { - var match = path.match(BEFORE_SLASH_RE); - - if (match) { - var pathBeforeSlash = match[1]; + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var eventTime = eventTimes[index]; - if (pathBeforeSlash) { - var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); - fileName = folderName + "/" + fileName; - } - } - } + if (eventTime > mostRecentEventTime) { + mostRecentEventTime = eventTime; } - sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; - } else if (ownerName) { - sourceInfo = " (created by " + ownerName + ")"; + lanes &= ~lane; } - return "\n in " + (name || "Unknown") + sourceInfo; + return mostRecentEventTime; } -var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - -function describeFiber(fiber) { - switch (fiber.tag) { - case HostRoot: - case HostPortal: - case HostText: - case Fragment: - case ContextProvider: - case ContextConsumer: - return ""; - - default: - var owner = fiber._debugOwner; - var source = fiber._debugSource; - var name = getComponentName(fiber.type); - var ownerName = null; - - if (owner) { - ownerName = getComponentName(owner.type); - } +function computeExpirationTime(lane, currentTime) { + // TODO: Expiration heuristic is constant per lane, so could use a map. + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; - return describeComponentFrame(name, source, ownerName); + if (priority >= InputContinuousLanePriority) { + // User interactions should expire slightly more quickly. + // + // NOTE: This is set to the corresponding constant as in Scheduler.js. When + // we made it larger, a product metric in www regressed, suggesting there's + // a user interaction that's being starved by a series of synchronous + // updates. If that theory is correct, the proper solution is to fix the + // starvation. However, this scenario supports the idea that expiration + // times are an important safeguard when starvation does happen. + // + // Also note that, in the case of user input specifically, this will soon no + // longer be an issue because we plan to make user input synchronous by + // default (until you enter `startTransition`, of course.) + // + // If weren't planning to make these updates synchronous soon anyway, I + // would probably make this number a configurable parameter. + return currentTime + 250; + } else if (priority >= TransitionPriority) { + return currentTime + 5000; + } else { + // Anything idle priority or lower should never expire. + return NoTimestamp; } } -function getStackByFiberInDevAndProd(workInProgress) { - var info = ""; - var node = workInProgress; - - do { - info += describeFiber(node); - node = node.return; - } while (node); +function markStarvedLanesAsExpired(root, currentTime) { + // TODO: This gets called every time we yield. We can optimize by storing + // the earliest expiration time on the root. Then use that to quickly bail out + // of this function. + var pendingLanes = root.pendingLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; + var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their + // expiration time. If so, we'll assume the update is being starved and mark + // it as expired to force it to finish. - return info; -} -var current = null; -var isRendering = false; -function getCurrentFiberOwnerNameInDevOrNull() { - { - if (current === null) { - return null; - } + var lanes = pendingLanes; - var owner = current._debugOwner; + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var expirationTime = expirationTimes[index]; - if (owner !== null && typeof owner !== "undefined") { - return getComponentName(owner.type); + if (expirationTime === NoTimestamp) { + // Found a pending lane with no expiration time. If it's not suspended, or + // if it's pinged, assume it's CPU-bound. Compute a new expiration time + // using the current time. + if ( + (lane & suspendedLanes) === NoLanes || + (lane & pingedLanes) !== NoLanes + ) { + // Assumes timestamps are monotonically increasing. + expirationTimes[index] = computeExpirationTime(lane, currentTime); + } + } else if (expirationTime <= currentTime) { + // This lane expired + root.expiredLanes |= lane; } - } - return null; -} -function getCurrentFiberStackInDev() { - { - if (current === null) { - return ""; - } // Safe because if current fiber exists, we are reconciling, - // and it is guaranteed to be the work-in-progress version. + lanes &= ~lane; + } +} // This returns the highest priority pending lanes regardless of whether they +function getLanesToRetrySynchronouslyOnError(root) { + var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; - return getStackByFiberInDevAndProd(current); + if (everythingButOffscreen !== NoLanes) { + return everythingButOffscreen; } -} -function resetCurrentFiber() { - { - ReactDebugCurrentFrame.getCurrentStack = null; - current = null; - isRendering = false; + + if (everythingButOffscreen & OffscreenLane) { + return OffscreenLane; } + + return NoLanes; } -function setCurrentFiber(fiber) { - { - ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; - current = fiber; - isRendering = false; - } +function returnNextLanesPriority() { + return return_highestLanePriority; } -function setIsRendering(rendering) { - { - isRendering = rendering; - } +function includesNonIdleWork(lanes) { + return (lanes & NonIdleLanes) !== NoLanes; } +function includesOnlyRetries(lanes) { + return (lanes & RetryLanes) === lanes; +} +function includesOnlyTransitions(lanes) { + return (lanes & TransitionLanes) === lanes; +} // To ensure consistency across multiple updates in the same event, this should +// be a pure function, so that it always returns the same lane for given inputs. -var ReactStrictModeWarnings = { - recordUnsafeLifecycleWarnings: function(fiber, instance) {}, - flushPendingUnsafeLifecycleWarnings: function() {}, - recordLegacyContextWarning: function(fiber, instance) {}, - flushLegacyContextWarning: function() {}, - discardPendingWarnings: function() {} -}; +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case NoLanePriority: + break; -{ - var findStrictRoot = function(fiber) { - var maybeStrictRoot = null; - var node = fiber; + case SyncLanePriority: + return SyncLane; - while (node !== null) { - if (node.mode & StrictMode) { - maybeStrictRoot = node; + case SyncBatchedLanePriority: + return SyncBatchedLane; + + case InputDiscreteLanePriority: { + var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); + + if (_lane === NoLane) { + // Shift to the next priority level + return findUpdateLane(InputContinuousLanePriority, wipLanes); } - node = node.return; + return _lane; } - return maybeStrictRoot; - }; + case InputContinuousLanePriority: { + var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); - var setToSortedString = function(set) { - var array = []; - set.forEach(function(value) { - array.push(value); - }); - return array.sort().join(", "); - }; + if (_lane2 === NoLane) { + // Shift to the next priority level + return findUpdateLane(DefaultLanePriority, wipLanes); + } - var pendingComponentWillMountWarnings = []; - var pendingUNSAFE_ComponentWillMountWarnings = []; - var pendingComponentWillReceivePropsWarnings = []; - var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; - var pendingComponentWillUpdateWarnings = []; - var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. + return _lane2; + } - var didWarnAboutUnsafeLifecycles = new Set(); + case DefaultLanePriority: { + var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); - ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function( - fiber, - instance - ) { - // Dedup strategy: Warn once per component. - if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { - return; - } + if (_lane3 === NoLane) { + // If all the default lanes are already being worked on, look for a + // lane in the transition range. + _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes); - if ( - typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components. - instance.componentWillMount.__suppressDeprecationWarning !== true - ) { - pendingComponentWillMountWarnings.push(fiber); - } + if (_lane3 === NoLane) { + // All the transition lanes are taken, too. This should be very + // rare, but as a last resort, pick a default lane. This will have + // the effect of interrupting the current work-in-progress render. + _lane3 = pickArbitraryLane(DefaultLanes); + } + } - if ( - fiber.mode & StrictMode && - typeof instance.UNSAFE_componentWillMount === "function" - ) { - pendingUNSAFE_ComponentWillMountWarnings.push(fiber); + return _lane3; } - if ( - typeof instance.componentWillReceiveProps === "function" && - instance.componentWillReceiveProps.__suppressDeprecationWarning !== true - ) { - pendingComponentWillReceivePropsWarnings.push(fiber); - } + case TransitionPriority: // Should be handled by findTransitionLane instead - if ( - fiber.mode & StrictMode && - typeof instance.UNSAFE_componentWillReceiveProps === "function" - ) { - pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); - } + case RetryLanePriority: + // Should be handled by findRetryLane instead + break; - if ( - typeof instance.componentWillUpdate === "function" && - instance.componentWillUpdate.__suppressDeprecationWarning !== true - ) { - pendingComponentWillUpdateWarnings.push(fiber); - } + case IdleLanePriority: + var lane = pickArbitraryLane(IdleLanes & ~wipLanes); - if ( - fiber.mode & StrictMode && - typeof instance.UNSAFE_componentWillUpdate === "function" - ) { - pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); - } - }; + if (lane === NoLane) { + lane = pickArbitraryLane(IdleLanes); + } - ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() { - // We do an initial pass to gather component names - var componentWillMountUniqueNames = new Set(); + return lane; + } - if (pendingComponentWillMountWarnings.length > 0) { - pendingComponentWillMountWarnings.forEach(function(fiber) { - componentWillMountUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingComponentWillMountWarnings = []; - } + { + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); + } +} // To ensure consistency across multiple updates in the same event, this should +// be pure function, so that it always returns the same lane for given inputs. - var UNSAFE_componentWillMountUniqueNames = new Set(); +function findTransitionLane(wipLanes, pendingLanes) { + // First look for lanes that are completely unclaimed, i.e. have no + // pending work. + var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); - if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { - pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) { - UNSAFE_componentWillMountUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingUNSAFE_ComponentWillMountWarnings = []; + if (lane === NoLane) { + // If all lanes have pending work, look for a lane that isn't currently + // being worked on. + lane = pickArbitraryLane(TransitionLanes & ~wipLanes); + + if (lane === NoLane) { + // If everything is being worked on, pick any lane. This has the + // effect of interrupting the current work-in-progress. + lane = pickArbitraryLane(TransitionLanes); } + } - var componentWillReceivePropsUniqueNames = new Set(); + return lane; +} // To ensure consistency across multiple updates in the same event, this should +// be pure function, so that it always returns the same lane for given inputs. - if (pendingComponentWillReceivePropsWarnings.length > 0) { - pendingComponentWillReceivePropsWarnings.forEach(function(fiber) { - componentWillReceivePropsUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingComponentWillReceivePropsWarnings = []; - } +function findRetryLane(wipLanes) { + // This is a fork of `findUpdateLane` designed specifically for Suspense + // "retries" — a special update that attempts to flip a Suspense boundary + // from its placeholder state to its primary/resolved state. + var lane = pickArbitraryLane(RetryLanes & ~wipLanes); - var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); + if (lane === NoLane) { + lane = pickArbitraryLane(RetryLanes); + } - if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { - pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) { - UNSAFE_componentWillReceivePropsUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingUNSAFE_ComponentWillReceivePropsWarnings = []; - } + return lane; +} - var componentWillUpdateUniqueNames = new Set(); +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} - if (pendingComponentWillUpdateWarnings.length > 0) { - pendingComponentWillUpdateWarnings.forEach(function(fiber) { - componentWillUpdateUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingComponentWillUpdateWarnings = []; - } +function getLowestPriorityLane(lanes) { + // This finds the most significant non-zero bit. + var index = 31 - clz32(lanes); + return index < 0 ? NoLanes : 1 << index; +} - var UNSAFE_componentWillUpdateUniqueNames = new Set(); +function getEqualOrHigherPriorityLanes(lanes) { + return (getLowestPriorityLane(lanes) << 1) - 1; +} - if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { - pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) { - UNSAFE_componentWillUpdateUniqueNames.add( - getComponentName(fiber.type) || "Component" - ); - didWarnAboutUnsafeLifecycles.add(fiber.type); - }); - pendingUNSAFE_ComponentWillUpdateWarnings = []; - } // Finally, we flush all the warnings - // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' +function pickArbitraryLane(lanes) { + // This wrapper function gets inlined. Only exists so to communicate that it + // doesn't matter which bit is selected; you can pick any bit without + // affecting the algorithms where its used. Here I'm using + // getHighestPriorityLane because it requires the fewest operations. + return getHighestPriorityLane(lanes); +} - if (UNSAFE_componentWillMountUniqueNames.size > 0) { - var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); +function pickArbitraryLaneIndex(lanes) { + return 31 - clz32(lanes); +} - error( - "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + - "\nPlease update the following components: %s", - sortedNames - ); - } +function laneToIndex(lane) { + return pickArbitraryLaneIndex(lane); +} - if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { - var _sortedNames = setToSortedString( - UNSAFE_componentWillReceivePropsUniqueNames - ); +function includesSomeLane(a, b) { + return (a & b) !== NoLanes; +} +function isSubsetOfLanes(set, subset) { + return (set & subset) === subset; +} +function mergeLanes(a, b) { + return a | b; +} +function removeLanes(set, subset) { + return set & ~subset; +} // Seems redundant, but it changes the type from a single lane (used for +// updates) to a group of lanes (used for flushing work). - error( - "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + - "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "* If you're updating state whenever props change, " + - "refactor your code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + - "\nPlease update the following components: %s", - _sortedNames - ); - } +function laneToLanes(lane) { + return lane; +} +function createLaneMap(initial) { + // Intentionally pushing one by one. + // https://v8.dev/blog/elements-kinds#avoid-creating-holes + var laneMap = []; - if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { - var _sortedNames2 = setToSortedString( - UNSAFE_componentWillUpdateUniqueNames - ); + for (var i = 0; i < TotalLanes; i++) { + laneMap.push(initial); + } - error( - "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + - "and may indicate bugs in your code. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "\nPlease update the following components: %s", - _sortedNames2 - ); - } + return laneMap; +} +function markRootUpdated(root, updateLane, eventTime) { + root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But + // it's not practical to try every single possible combination. We need a + // heuristic to decide which lanes to attempt to render, and in which batches. + // For now, we use the same heuristic as in the old ExpirationTimes model: + // retry any lane at equal or lower priority, but don't try updates at higher + // priority without also including the lower priority updates. This works well + // when considering updates across different priority levels, but isn't + // sufficient for updates within the same priority, since we want to treat + // those updates as parallel. + // Unsuspend any update at equal or lower priority. - if (componentWillMountUniqueNames.size > 0) { - var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); + var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 - warn( - "componentWillMount has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + - "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + - "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + - "To rename all deprecated lifecycles to their new names, you can run " + - "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + - "\nPlease update the following components: %s", - _sortedNames3 - ); - } + root.suspendedLanes &= higherPriorityLanes; + root.pingedLanes &= higherPriorityLanes; + var eventTimes = root.eventTimes; + var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most + // recent event, and we assume time is monotonically increasing. - if (componentWillReceivePropsUniqueNames.size > 0) { - var _sortedNames4 = setToSortedString( - componentWillReceivePropsUniqueNames - ); + eventTimes[index] = eventTime; +} +function markRootSuspended(root, suspendedLanes) { + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. - warn( - "componentWillReceiveProps has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "* If you're updating state whenever props change, refactor your " + - "code to use memoization techniques or move it to " + - "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + - "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + - "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + - "To rename all deprecated lifecycles to their new names, you can run " + - "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + - "\nPlease update the following components: %s", - _sortedNames4 - ); - } + var expirationTimes = root.expirationTimes; + var lanes = suspendedLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + expirationTimes[index] = NoTimestamp; + lanes &= ~lane; + } +} +function markRootPinged(root, pingedLanes, eventTime) { + root.pingedLanes |= root.suspendedLanes & pingedLanes; +} +function hasDiscreteLanes(lanes) { + return (lanes & InputDiscreteLanes) !== NoLanes; +} +function markRootMutableRead(root, updateLane) { + root.mutableReadLanes |= updateLane & root.pendingLanes; +} +function markRootFinished(root, remainingLanes) { + var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; + root.pendingLanes = remainingLanes; // Let's try everything again - if (componentWillUpdateUniqueNames.size > 0) { - var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); + root.suspendedLanes = 0; + root.pingedLanes = 0; + root.expiredLanes &= remainingLanes; + root.mutableReadLanes &= remainingLanes; + root.entangledLanes &= remainingLanes; + var entanglements = root.entanglements; + var eventTimes = root.eventTimes; + var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work - warn( - "componentWillUpdate has been renamed, and is not recommended for use. " + - "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + - "* Move data fetching code or side effects to componentDidUpdate.\n" + - "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + - "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + - "To rename all deprecated lifecycles to their new names, you can run " + - "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + - "\nPlease update the following components: %s", - _sortedNames5 - ); - } - }; + var lanes = noLongerPendingLanes; - var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entanglements[index] = NoLanes; + eventTimes[index] = NoTimestamp; + expirationTimes[index] = NoTimestamp; + lanes &= ~lane; + } +} +function markRootEntangled(root, entangledLanes) { + root.entangledLanes |= entangledLanes; + var entanglements = root.entanglements; + var lanes = entangledLanes; - var didWarnAboutLegacyContext = new Set(); + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entanglements[index] |= entangledLanes; + lanes &= ~lane; + } +} +var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer. +// Based on: +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 - ReactStrictModeWarnings.recordLegacyContextWarning = function( - fiber, - instance +var log = Math.log; +var LN2 = Math.LN2; + +function clz32Fallback(lanes) { + if (lanes === 0) { + return 32; + } + + return (31 - ((log(lanes) / LN2) | 0)) | 0; +} + +// Intentionally not named imports because Rollup would use dynamic dispatch for +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, + Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, + Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_shouldYield = Scheduler.unstable_shouldYield, + Scheduler_requestPaint = Scheduler.unstable_requestPaint, + Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel, + Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, + Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, + Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, + Scheduler_LowPriority = Scheduler.unstable_LowPriority, + Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; + +{ + // Provide explicit error message when production+profiling bundle of e.g. + // react-dom is used with production (non-profiling) bundle of + // scheduler/tracing + if ( + !( + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null + ) ) { - var strictRoot = findStrictRoot(fiber); + throw Error( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" + ); + } +} - if (strictRoot === null) { - error( - "Expected to find a StrictMode component in a strict mode tree. " + - "This error is likely caused by a bug in React. Please file an issue." - ); +var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. - return; - } // Dedup strategy: Warn once per component. +var ImmediatePriority$1 = 99; +var UserBlockingPriority$1 = 98; +var NormalPriority$1 = 97; +var LowPriority$1 = 96; +var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only. - if (didWarnAboutLegacyContext.has(fiber.type)) { - return; - } +var NoPriority$1 = 90; +var shouldYield = Scheduler_shouldYield; +var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. + Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {}; +var syncQueue = null; +var immediateQueueCallbackNode = null; +var isFlushingSyncQueue = false; +var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. +// This will be the case for modern browsers that support `performance.now`. In +// older browsers, Scheduler falls back to `Date.now`, which returns a Unix +// timestamp. In that case, subtract the module initialization time to simulate +// the behavior of performance.now and keep our times small enough to fit +// within 32 bits. +// TODO: Consider lifting this into Scheduler. - var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); +var now = + initialTimeMs$1 < 10000 + ? Scheduler_now$1 + : function() { + return Scheduler_now$1() - initialTimeMs$1; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return ImmediatePriority$1; - if ( - fiber.type.contextTypes != null || - fiber.type.childContextTypes != null || - (instance !== null && typeof instance.getChildContext === "function") - ) { - if (warningsForRoot === undefined) { - warningsForRoot = []; - pendingLegacyContextWarning.set(strictRoot, warningsForRoot); - } + case Scheduler_UserBlockingPriority: + return UserBlockingPriority$1; - warningsForRoot.push(fiber); + case Scheduler_NormalPriority: + return NormalPriority$1; + + case Scheduler_LowPriority: + return LowPriority$1; + + case Scheduler_IdlePriority: + return IdlePriority$1; + + default: { + throw Error("Unknown priority level."); } - }; + } +} - ReactStrictModeWarnings.flushLegacyContextWarning = function() { - pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) { - if (fiberArray.length === 0) { - return; - } +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority$1: + return Scheduler_ImmediatePriority; - var firstFiber = fiberArray[0]; - var uniqueNames = new Set(); - fiberArray.forEach(function(fiber) { - uniqueNames.add(getComponentName(fiber.type) || "Component"); - didWarnAboutLegacyContext.add(fiber.type); - }); - var sortedNames = setToSortedString(uniqueNames); - var firstComponentStack = getStackByFiberInDevAndProd(firstFiber); + case UserBlockingPriority$1: + return Scheduler_UserBlockingPriority; - error( - "Legacy context API has been detected within a strict-mode tree." + - "\n\nThe old API will be supported in all 16.x releases, but applications " + - "using it should migrate to the new version." + - "\n\nPlease update the following components: %s" + - "\n\nLearn more about this warning here: https://fb.me/react-legacy-context" + - "%s", - sortedNames, - firstComponentStack - ); - }); - }; + case NormalPriority$1: + return Scheduler_NormalPriority; - ReactStrictModeWarnings.discardPendingWarnings = function() { - pendingComponentWillMountWarnings = []; - pendingUNSAFE_ComponentWillMountWarnings = []; - pendingComponentWillReceivePropsWarnings = []; - pendingUNSAFE_ComponentWillReceivePropsWarnings = []; - pendingComponentWillUpdateWarnings = []; - pendingUNSAFE_ComponentWillUpdateWarnings = []; - pendingLegacyContextWarning = new Map(); - }; -} + case LowPriority$1: + return Scheduler_LowPriority; -var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. + case IdlePriority$1: + return Scheduler_IdlePriority; -var failedBoundaries = null; -var setRefreshHandler = function(handler) { - { - resolveFamily = handler; - } -}; -function resolveFunctionForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; + default: { + throw Error("Unknown priority level."); } + } +} - var family = resolveFamily(type); +function runWithPriority(reactPriorityLevel, fn) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(priorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(priorityLevel, callback, options); +} +function scheduleSyncCallback(callback) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushSyncCallbackQueue`. + if (syncQueue === null) { + syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. - if (family === undefined) { - return type; - } // Use the latest known implementation. + immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ); + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + syncQueue.push(callback); + } - return family.current; + return fakeCallbackNode; +} +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); } } -function resolveClassForHotReloading(type) { - // No implementation differences. - return resolveFunctionForHotReloading(type); +function flushSyncCallbackQueue() { + if (immediateQueueCallbackNode !== null) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + + flushSyncCallbackQueueImpl(); } -function resolveForwardRefForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; + +function flushSyncCallbackQueueImpl() { + if (!isFlushingSyncQueue && syncQueue !== null) { + // Prevent re-entrancy. + isFlushingSyncQueue = true; + var i = 0; + + { + try { + var _isSync2 = true; + var _queue = syncQueue; + runWithPriority(ImmediatePriority$1, function() { + for (; i < _queue.length; i++) { + var callback = _queue[i]; + + do { + callback = callback(_isSync2); + } while (callback !== null); + } + }); + syncQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (syncQueue !== null) { + syncQueue = syncQueue.slice(i + 1); + } // Resume flushing in the next tick + + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ); + throw error; + } finally { + isFlushingSyncQueue = false; + } } + } +} - var family = resolveFamily(type); +// TODO: this is special because it gets imported during build. +var ReactVersion = "17.0.1-4e5d7faf5"; - if (family === undefined) { - // Check if we're dealing with a real forwardRef. Don't want to crash early. - if ( - type !== null && - type !== undefined && - typeof type.render === "function" - ) { - // ForwardRef is special because its resolved .type is an object, - // but it's possible that we only have its inner render function in the map. - // If that inner render function is different, we'll build a new forwardRef type. - var currentRender = resolveFunctionForHotReloading(type.render); +var NoMode = 0; +var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root +// tag instead - if (type.render !== currentRender) { - var syntheticType = { - $$typeof: REACT_FORWARD_REF_TYPE, - render: currentRender - }; +var BlockingMode = 2; +var ConcurrentMode = 4; +var ProfileMode = 8; +var DebugTracingMode = 16; + +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; +var NoTransition = 0; +function requestCurrentTransition() { + return ReactCurrentBatchConfig.transition; +} + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return ( + (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare + ); +} - if (type.displayName !== undefined) { - syntheticType.displayName = type.displayName; - } +var objectIs = typeof Object.is === "function" ? Object.is : is; - return syntheticType; - } - } +var hasOwnProperty = Object.prototype.hasOwnProperty; +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ - return type; - } // Use the latest known implementation. +function shallowEqual(objA, objB) { + if (objectIs(objA, objB)) { + return true; + } - return family.current; + if ( + typeof objA !== "object" || + objA === null || + typeof objB !== "object" || + objB === null + ) { + return false; } -} -function isCompatibleFamilyForHotReloading(fiber, element) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } // Test for A's keys different from B. + + for (var i = 0; i < keysA.length; i++) { + if ( + !hasOwnProperty.call(objB, keysA[i]) || + !objectIs(objA[keysA[i]], objB[keysA[i]]) + ) { return false; } + } - var prevType = fiber.elementType; - var nextType = element.type; // If we got here, we know types aren't === equal. + return true; +} - var needsCompareFamilies = false; - var $$typeofNextType = - typeof nextType === "object" && nextType !== null - ? nextType.$$typeof - : null; +function describeFiber(fiber) { + var owner = fiber._debugOwner ? fiber._debugOwner.type : null; + var source = fiber._debugSource; - switch (fiber.tag) { - case ClassComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } + switch (fiber.tag) { + case HostComponent: + return describeBuiltInComponentFrame(fiber.type, source, owner); - break; - } + case LazyComponent: + return describeBuiltInComponentFrame("Lazy", source, owner); - case FunctionComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - // We don't know the inner type yet. - // We're going to assume that the lazy inner type is stable, - // and so it is sufficient to avoid reconciling it away. - // We're not going to unwrap or actually use the new lazy type. - needsCompareFamilies = true; - } + case SuspenseComponent: + return describeBuiltInComponentFrame("Suspense", source, owner); - break; - } + case SuspenseListComponent: + return describeBuiltInComponentFrame("SuspenseList", source, owner); - case ForwardRef: { - if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } + case FunctionComponent: + case IndeterminateComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type, source, owner); - break; - } + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render, source, owner); - case MemoComponent: - case SimpleMemoComponent: { - if ($$typeofNextType === REACT_MEMO_TYPE) { - // TODO: if it was but can no longer be simple, - // we shouldn't set this. - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } + case Block: + return describeFunctionComponentFrame(fiber.type._render, source, owner); - break; - } + case ClassComponent: + return describeClassComponentFrame(fiber.type, source, owner); - default: - return false; - } // Check if both types have a family and it's the same one. + default: + return ""; + } +} - if (needsCompareFamilies) { - // Note: memo() and forwardRef() we'll compare outer rather than inner type. - // This means both of them need to be registered to preserve state. - // If we unwrapped and compared the inner types for wrappers instead, - // then we would risk falsely saying two separate memo(Foo) - // calls are equivalent because they wrap the same Foo function. - var prevFamily = resolveFamily(prevType); +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + var node = workInProgress; - if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { - return true; - } - } + do { + info += describeFiber(node); + node = node.return; + } while (node); - return false; + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; } } -function markFailedErrorBoundaryForHotReloading(fiber) { + +var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; +var current = null; +var isRendering = false; +function getCurrentFiberOwnerNameInDevOrNull() { { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; + if (current === null) { + return null; } - if (typeof WeakSet !== "function") { - return; - } + var owner = current._debugOwner; - if (failedBoundaries === null) { - failedBoundaries = new WeakSet(); + if (owner !== null && typeof owner !== "undefined") { + return getComponentName(owner.type); } - - failedBoundaries.add(fiber); } + + return null; } -var scheduleRefresh = function(root, update) { + +function getCurrentFiberStackInDev() { { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; - } + if (current === null) { + return ""; + } // Safe because if current fiber exists, we are reconciling, + // and it is guaranteed to be the work-in-progress version. - var staleFamilies = update.staleFamilies, - updatedFamilies = update.updatedFamilies; - flushPassiveEffects(); - flushSync(function() { - scheduleFibersWithFamiliesRecursively( - root.current, - updatedFamilies, - staleFamilies - ); - }); + return getStackByFiberInDevAndProd(current); } -}; -var scheduleRoot = function(root, element) { +} + +function resetCurrentFiber() { { - if (root.context !== emptyContextObject) { - // Super edge case: root has a legacy _renderSubtree context - // but we don't know the parentComponent so we can't pass it. - // Just ignore. We'll delete this with _renderSubtree code path later. - return; + ReactDebugCurrentFrame$1.getCurrentStack = null; + current = null; + isRendering = false; + } +} +function setCurrentFiber(fiber) { + { + ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; + current = fiber; + isRendering = false; + } +} +function setIsRendering(rendering) { + { + isRendering = rendering; + } +} +function getIsRendering() { + { + return isRendering; + } +} + +var ReactStrictModeWarnings = { + recordUnsafeLifecycleWarnings: function(fiber, instance) {}, + flushPendingUnsafeLifecycleWarnings: function() {}, + recordLegacyContextWarning: function(fiber, instance) {}, + flushLegacyContextWarning: function() {}, + discardPendingWarnings: function() {} +}; + +{ + var findStrictRoot = function(fiber) { + var maybeStrictRoot = null; + var node = fiber; + + while (node !== null) { + if (node.mode & StrictMode) { + maybeStrictRoot = node; + } + + node = node.return; } - flushPassiveEffects(); - syncUpdates(function() { - updateContainer(element, root, null, null); + return maybeStrictRoot; + }; + + var setToSortedString = function(set) { + var array = []; + set.forEach(function(value) { + array.push(value); }); - } -}; + return array.sort().join(", "); + }; -function scheduleFibersWithFamiliesRecursively( - fiber, - updatedFamilies, - staleFamilies -) { - { - var alternate = fiber.alternate, - child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; + var pendingComponentWillMountWarnings = []; + var pendingUNSAFE_ComponentWillMountWarnings = []; + var pendingComponentWillReceivePropsWarnings = []; + var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + var pendingComponentWillUpdateWarnings = []; + var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. + + var didWarnAboutUnsafeLifecycles = new Set(); + + ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function( + fiber, + instance + ) { + // Dedup strategy: Warn once per component. + if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { + return; + } - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; + if ( + typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components. + instance.componentWillMount.__suppressDeprecationWarning !== true + ) { + pendingComponentWillMountWarnings.push(fiber); + } - case ForwardRef: - candidateType = type.render; - break; + if ( + fiber.mode & StrictMode && + typeof instance.UNSAFE_componentWillMount === "function" + ) { + pendingUNSAFE_ComponentWillMountWarnings.push(fiber); } - if (resolveFamily === null) { - throw new Error("Expected resolveFamily to be set during hot reload."); + if ( + typeof instance.componentWillReceiveProps === "function" && + instance.componentWillReceiveProps.__suppressDeprecationWarning !== true + ) { + pendingComponentWillReceivePropsWarnings.push(fiber); } - var needsRender = false; - var needsRemount = false; + if ( + fiber.mode & StrictMode && + typeof instance.UNSAFE_componentWillReceiveProps === "function" + ) { + pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); + } - if (candidateType !== null) { - var family = resolveFamily(candidateType); + if ( + typeof instance.componentWillUpdate === "function" && + instance.componentWillUpdate.__suppressDeprecationWarning !== true + ) { + pendingComponentWillUpdateWarnings.push(fiber); + } - if (family !== undefined) { - if (staleFamilies.has(family)) { - needsRemount = true; - } else if (updatedFamilies.has(family)) { - if (tag === ClassComponent) { - needsRemount = true; - } else { - needsRender = true; - } - } - } + if ( + fiber.mode & StrictMode && + typeof instance.UNSAFE_componentWillUpdate === "function" + ) { + pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); } + }; - if (failedBoundaries !== null) { - if ( - failedBoundaries.has(fiber) || - (alternate !== null && failedBoundaries.has(alternate)) - ) { - needsRemount = true; - } + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() { + // We do an initial pass to gather component names + var componentWillMountUniqueNames = new Set(); + + if (pendingComponentWillMountWarnings.length > 0) { + pendingComponentWillMountWarnings.forEach(function(fiber) { + componentWillMountUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillMountWarnings = []; } - if (needsRemount) { - fiber._debugNeedsRemount = true; + var UNSAFE_componentWillMountUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { + pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) { + UNSAFE_componentWillMountUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillMountWarnings = []; } - if (needsRemount || needsRender) { - scheduleWork(fiber, Sync); + var componentWillReceivePropsUniqueNames = new Set(); + + if (pendingComponentWillReceivePropsWarnings.length > 0) { + pendingComponentWillReceivePropsWarnings.forEach(function(fiber) { + componentWillReceivePropsUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillReceivePropsWarnings = []; } - if (child !== null && !needsRemount) { - scheduleFibersWithFamiliesRecursively( - child, - updatedFamilies, - staleFamilies - ); + var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { + pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) { + UNSAFE_componentWillReceivePropsUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; } - if (sibling !== null) { - scheduleFibersWithFamiliesRecursively( - sibling, - updatedFamilies, - staleFamilies - ); + var componentWillUpdateUniqueNames = new Set(); + + if (pendingComponentWillUpdateWarnings.length > 0) { + pendingComponentWillUpdateWarnings.forEach(function(fiber) { + componentWillUpdateUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillUpdateWarnings = []; } - } -} -var findHostInstancesForRefresh = function(root, families) { - { - var hostInstances = new Set(); - var types = new Set( - families.map(function(family) { - return family.current; - }) - ); - findHostInstancesForMatchingFibersRecursively( - root.current, - types, - hostInstances - ); - return hostInstances; - } -}; + var UNSAFE_componentWillUpdateUniqueNames = new Set(); -function findHostInstancesForMatchingFibersRecursively( - fiber, - types, - hostInstances -) { - { - var child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; + if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { + pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) { + UNSAFE_componentWillUpdateUniqueNames.add( + getComponentName(fiber.type) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillUpdateWarnings = []; + } // Finally, we flush all the warnings + // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; + if (UNSAFE_componentWillMountUniqueNames.size > 0) { + var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); - case ForwardRef: - candidateType = type.render; - break; + error( + "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + + "\nPlease update the following components: %s", + sortedNames + ); } - var didMatch = false; + if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames = setToSortedString( + UNSAFE_componentWillReceivePropsUniqueNames + ); - if (candidateType !== null) { - if (types.has(candidateType)) { - didMatch = true; - } + error( + "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + + "and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* If you're updating state whenever props change, " + + "refactor your code to use memoization techniques or move it to " + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + + "\nPlease update the following components: %s", + _sortedNames + ); } - if (didMatch) { - // We have a match. This only drills down to the closest host components. - // There's no need to search deeper because for the purpose of giving - // visual feedback, "flashing" outermost parent rectangles is sufficient. - findHostInstancesForFiberShallowly(fiber, hostInstances); - } else { - // If there's no match, maybe there will be one further down in the child tree. - if (child !== null) { - findHostInstancesForMatchingFibersRecursively( - child, - types, - hostInstances - ); - } + if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { + var _sortedNames2 = setToSortedString( + UNSAFE_componentWillUpdateUniqueNames + ); + + error( + "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + + "and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "\nPlease update the following components: %s", + _sortedNames2 + ); + } + + if (componentWillMountUniqueNames.size > 0) { + var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); + + warn( + "componentWillMount has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + + "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames3 + ); } - if (sibling !== null) { - findHostInstancesForMatchingFibersRecursively( - sibling, - types, - hostInstances + if (componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames4 = setToSortedString( + componentWillReceivePropsUniqueNames + ); + + warn( + "componentWillReceiveProps has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* If you're updating state whenever props change, refactor your " + + "code to use memoization techniques or move it to " + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + + "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames4 ); } - } -} -function findHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var foundHostInstances = findChildHostInstancesForFiberShallowly( - fiber, - hostInstances - ); + if (componentWillUpdateUniqueNames.size > 0) { + var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); - if (foundHostInstances) { - return; - } // If we didn't find any host children, fallback to closest host parent. + warn( + "componentWillUpdate has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames5 + ); + } + }; - var node = fiber; + var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. - while (true) { - switch (node.tag) { - case HostComponent: - hostInstances.add(node.stateNode); - return; + var didWarnAboutLegacyContext = new Set(); - case HostPortal: - hostInstances.add(node.stateNode.containerInfo); - return; + ReactStrictModeWarnings.recordLegacyContextWarning = function( + fiber, + instance + ) { + var strictRoot = findStrictRoot(fiber); - case HostRoot: - hostInstances.add(node.stateNode.containerInfo); - return; - } + if (strictRoot === null) { + error( + "Expected to find a StrictMode component in a strict mode tree. " + + "This error is likely caused by a bug in React. Please file an issue." + ); - if (node.return === null) { - throw new Error("Expected to reach root first."); - } + return; + } // Dedup strategy: Warn once per component. - node = node.return; + if (didWarnAboutLegacyContext.has(fiber.type)) { + return; } - } -} -function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var node = fiber; - var foundHostInstances = false; + var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); - while (true) { - if (node.tag === HostComponent) { - // We got a match. - foundHostInstances = true; - hostInstances.add(node.stateNode); // There may still be more, so keep searching. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; + if ( + fiber.type.contextTypes != null || + fiber.type.childContextTypes != null || + (instance !== null && typeof instance.getChildContext === "function") + ) { + if (warningsForRoot === undefined) { + warningsForRoot = []; + pendingLegacyContextWarning.set(strictRoot, warningsForRoot); } - if (node === fiber) { - return foundHostInstances; + warningsForRoot.push(fiber); + } + }; + + ReactStrictModeWarnings.flushLegacyContextWarning = function() { + pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) { + if (fiberArray.length === 0) { + return; } - while (node.sibling === null) { - if (node.return === null || node.return === fiber) { - return foundHostInstances; - } + var firstFiber = fiberArray[0]; + var uniqueNames = new Set(); + fiberArray.forEach(function(fiber) { + uniqueNames.add(getComponentName(fiber.type) || "Component"); + didWarnAboutLegacyContext.add(fiber.type); + }); + var sortedNames = setToSortedString(uniqueNames); - node = node.return; - } + try { + setCurrentFiber(firstFiber); - node.sibling.return = node.return; - node = node.sibling; - } - } + error( + "Legacy context API has been detected within a strict-mode tree." + + "\n\nThe old API will be supported in all 16.x releases, but applications " + + "using it should migrate to the new version." + + "\n\nPlease update the following components: %s" + + "\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context", + sortedNames + ); + } finally { + resetCurrentFiber(); + } + }); + }; - return false; + ReactStrictModeWarnings.discardPendingWarnings = function() { + pendingComponentWillMountWarnings = []; + pendingUNSAFE_ComponentWillMountWarnings = []; + pendingComponentWillReceivePropsWarnings = []; + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + pendingComponentWillUpdateWarnings = []; + pendingUNSAFE_ComponentWillUpdateWarnings = []; + pendingLegacyContextWarning = new Map(); + }; } function resolveDefaultProps(Component, baseProps) { @@ -6424,15 +6473,11 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } -function readLazyComponentType(lazyComponent) { - initializeLazyComponentType(lazyComponent); - - if (lazyComponent._status !== Resolved) { - throw lazyComponent._result; - } - return lazyComponent._result; -} +// Max 31 bit integer. The max integer size in V8 for 32-bit systems. +// Math.pow(2, 30) - 1 +// 0b111111111111111111111111111111 +var MAX_SIGNED_31_BIT_INT = 1073741823; var valueCursor = createCursor(null); var rendererSigil; @@ -6522,28 +6567,24 @@ function calculateChangedBits(context, newValue, oldValue) { return changedBits | 0; } } -function scheduleWorkOnParentPath(parent, renderExpirationTime) { - // Update the child expiration time of all the ancestors, including - // the alternates. +function scheduleWorkOnParentPath(parent, renderLanes) { + // Update the child lanes of all the ancestors, including the alternates. var node = parent; while (node !== null) { var alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { - node.childExpirationTime = renderExpirationTime; + if (!isSubsetOfLanes(node.childLanes, renderLanes)) { + node.childLanes = mergeLanes(node.childLanes, renderLanes); - if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); } } else if ( alternate !== null && - alternate.childExpirationTime < renderExpirationTime + !isSubsetOfLanes(alternate.childLanes, renderLanes) ) { - alternate.childExpirationTime = renderExpirationTime; + alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); } else { // Neither alternate was updated, which means the rest of the // ancestor path already has sufficient priority. @@ -6557,7 +6598,7 @@ function propagateContextChange( workInProgress, context, changedBits, - renderExpirationTime + renderLanes ) { var fiber = workInProgress.child; @@ -6584,7 +6625,10 @@ function propagateContextChange( // Match! Schedule an update on this fiber. if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. - var update = createUpdate(renderExpirationTime, null); + var update = createUpdate( + NoTimestamp, + pickArbitraryLane(renderLanes) + ); update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the // update to the current fiber, too, which means it will persist even if // this render is thrown away. Since it's a race condition, not sure it's @@ -6593,24 +6637,16 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } - + fiber.lanes = mergeLanes(fiber.lanes, renderLanes); var alternate = fiber.alternate; - if ( - alternate !== null && - alternate.expirationTime < renderExpirationTime - ) { - alternate.expirationTime = renderExpirationTime; + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, renderLanes); } - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. + scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too. - if (list.expirationTime < renderExpirationTime) { - list.expirationTime = renderExpirationTime; - } // Since we already found a match, we can stop traversing the + list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the // dependency list. break; @@ -6656,7 +6692,7 @@ function propagateContextChange( fiber = nextFiber; } } -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress, renderLanes) { currentlyRenderingFiber = workInProgress; lastContextDependency = null; lastContextWithAllBitsObserved = null; @@ -6666,7 +6702,7 @@ function prepareToReadContext(workInProgress, renderExpirationTime) { var firstContext = dependencies.firstContext; if (firstContext !== null) { - if (dependencies.expirationTime >= renderExpirationTime) { + if (includesSomeLane(dependencies.lanes, renderLanes)) { // Context list has a pending update. Mark that this fiber performed work. markWorkInProgressReceivedUpdate(); } // Reset the work-in-progress list @@ -6720,7 +6756,7 @@ function readContext(context, observedBits) { lastContextDependency = contextItem; currentlyRenderingFiber.dependencies = { - expirationTime: NoWork, + lanes: NoLanes, firstContext: contextItem, responders: null }; @@ -6752,7 +6788,8 @@ var currentlyProcessingQueue; function initializeUpdateQueue(fiber) { var queue = { baseState: fiber.memoizedState, - baseQueue: null, + firstBaseUpdate: null, + lastBaseUpdate: null, shared: { pending: null }, @@ -6768,28 +6805,23 @@ function cloneUpdateQueue(current, workInProgress) { if (queue === currentQueue) { var clone = { baseState: currentQueue.baseState, - baseQueue: currentQueue.baseQueue, + firstBaseUpdate: currentQueue.firstBaseUpdate, + lastBaseUpdate: currentQueue.lastBaseUpdate, shared: currentQueue.shared, effects: currentQueue.effects }; workInProgress.updateQueue = clone; } } -function createUpdate(expirationTime, suspenseConfig) { +function createUpdate(eventTime, lane) { var update = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, + eventTime: eventTime, + lane: lane, tag: UpdateState, payload: null, callback: null, next: null }; - update.next = update; - - { - update.priority = getCurrentPriorityLevel(); - } - return update; } function enqueueUpdate(fiber, update) { @@ -6829,25 +6861,84 @@ function enqueueUpdate(fiber, update) { } } } -function enqueueCapturedUpdate(workInProgress, update) { +function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + // Captured updates are updates that are thrown by a child during the render + // phase. They should be discarded if the render is aborted. Therefore, + // we should only put them on the work-in-progress queue, not the current one. + var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. + var current = workInProgress.alternate; if (current !== null) { - // Ensure the work-in-progress queue is a clone - cloneUpdateQueue(current, workInProgress); - } // Captured updates go only on the work-in-progress queue. + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + // The work-in-progress queue is the same as current. This happens when + // we bail out on a parent fiber that then captures an error thrown by + // a child. Since we want to append the update only to the work-in + // -progress queue, we need to clone the updates. We usually clone during + // processUpdateQueue, but that didn't happen in this case because we + // skipped over the parent when we bailed out. + var newFirst = null; + var newLast = null; + var firstBaseUpdate = queue.firstBaseUpdate; + + if (firstBaseUpdate !== null) { + // Loop through the updates and clone them. + var update = firstBaseUpdate; + + do { + var clone = { + eventTime: update.eventTime, + lane: update.lane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - var queue = workInProgress.updateQueue; // Append the update to the end of the list. + if (newLast === null) { + newFirst = newLast = clone; + } else { + newLast.next = clone; + newLast = clone; + } - var last = queue.baseQueue; + update = update.next; + } while (update !== null); // Append the captured update the end of the cloned list. - if (last === null) { - queue.baseQueue = update.next = update; - update.next = update; + if (newLast === null) { + newFirst = newLast = capturedUpdate; + } else { + newLast.next = capturedUpdate; + newLast = capturedUpdate; + } + } else { + // There are no base updates. + newFirst = newLast = capturedUpdate; + } + + queue = { + baseState: currentQueue.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = queue; + return; + } + } // Append the update to the end of the list. + + var lastBaseUpdate = queue.lastBaseUpdate; + + if (lastBaseUpdate === null) { + queue.firstBaseUpdate = capturedUpdate; } else { - update.next = last.next; - last.next = update; + lastBaseUpdate.next = capturedUpdate; } + + queue.lastBaseUpdate = capturedUpdate; } function getStateFromUpdate( @@ -6881,8 +6972,8 @@ function getStateFromUpdate( } case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = + (workInProgress.flags & ~ShouldCapture) | DidCapture; } // Intentional fallthrough @@ -6923,161 +7014,163 @@ function getStateFromUpdate( return prevState; } -function processUpdateQueue( - workInProgress, - props, - instance, - renderExpirationTime -) { +function processUpdateQueue(workInProgress, props, instance, renderLanes) { // This is always non-null on a ClassComponent or HostRoot var queue = workInProgress.updateQueue; hasForceUpdate = false; { currentlyProcessingQueue = queue.shared; - } // The last rebase update that is NOT part of the base state. + } - var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. + var firstBaseUpdate = queue.firstBaseUpdate; + var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. var pendingQueue = queue.shared.pending; if (pendingQueue !== null) { - // We have new updates that haven't been processed yet. - // We'll add them to the base queue. - if (baseQueue !== null) { - // Merge the pending queue and the base queue. - var baseFirst = baseQueue.next; - var pendingFirst = pendingQueue.next; - baseQueue.next = pendingFirst; - pendingQueue.next = baseFirst; + queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first + // and last so that it's non-circular. + + var lastPendingUpdate = pendingQueue; + var firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; // Append pending updates to base queue + + if (lastBaseUpdate === null) { + firstBaseUpdate = firstPendingUpdate; + } else { + lastBaseUpdate.next = firstPendingUpdate; } - baseQueue = pendingQueue; - queue.shared.pending = null; // TODO: Pass `current` as argument + lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then + // we need to transfer the updates to that queue, too. Because the base + // queue is a singly-linked list with no cycles, we can append to both + // lists and take advantage of structural sharing. + // TODO: Pass `current` as argument var current = workInProgress.alternate; if (current !== null) { + // This is always non-null on a ClassComponent or HostRoot var currentQueue = current.updateQueue; + var currentLastBaseUpdate = currentQueue.lastBaseUpdate; - if (currentQueue !== null) { - currentQueue.baseQueue = pendingQueue; + if (currentLastBaseUpdate !== lastBaseUpdate) { + if (currentLastBaseUpdate === null) { + currentQueue.firstBaseUpdate = firstPendingUpdate; + } else { + currentLastBaseUpdate.next = firstPendingUpdate; + } + + currentQueue.lastBaseUpdate = lastPendingUpdate; } } } // These values may change as we process the queue. - if (baseQueue !== null) { - var first = baseQueue.next; // Iterate through the list of updates to compute the result. + if (firstBaseUpdate !== null) { + // Iterate through the list of updates to compute the result. + var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes + // from the original lanes. - var newState = queue.baseState; - var newExpirationTime = NoWork; + var newLanes = NoLanes; var newBaseState = null; - var newBaseQueueFirst = null; - var newBaseQueueLast = null; + var newFirstBaseUpdate = null; + var newLastBaseUpdate = null; + var update = firstBaseUpdate; + + do { + var updateLane = update.lane; + var updateEventTime = update.eventTime; - if (first !== null) { - var update = first; + if (!isSubsetOfLanes(renderLanes, updateLane)) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + eventTime: updateEventTime, + lane: updateLane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; - do { - var updateExpirationTime = update.expirationTime; + if (newLastBaseUpdate === null) { + newFirstBaseUpdate = newLastBaseUpdate = clone; + newBaseState = newState; + } else { + newLastBaseUpdate = newLastBaseUpdate.next = clone; + } // Update the remaining priority in the queue. - if (updateExpirationTime < renderExpirationTime) { - // Priority is insufficient. Skip this update. If this is the first - // skipped update, the previous update/state is the new base - // update/state. - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, + newLanes = mergeLanes(newLanes, updateLane); + } else { + // This update does have sufficient priority. + if (newLastBaseUpdate !== null) { + var _clone = { + eventTime: updateEventTime, + // This update is going to be committed so we never want uncommit + // it. Using NoLane works because 0 is a subset of all bitmasks, so + // this will never be skipped by the check above. + lane: NoLane, tag: update.tag, payload: update.payload, callback: update.callback, next: null }; + newLastBaseUpdate = newLastBaseUpdate.next = _clone; + } // Process this update. - if (newBaseQueueLast === null) { - newBaseQueueFirst = newBaseQueueLast = clone; - newBaseState = newState; - } else { - newBaseQueueLast = newBaseQueueLast.next = clone; - } // Update the remaining priority in the queue. - - if (updateExpirationTime > newExpirationTime) { - newExpirationTime = updateExpirationTime; - } - } else { - // This update does have sufficient priority. - if (newBaseQueueLast !== null) { - var _clone = { - expirationTime: Sync, - // This update is going to be committed so we never want uncommit it. - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }; - newBaseQueueLast = newBaseQueueLast.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ); // Process this update. - - newState = getStateFromUpdate( - workInProgress, - queue, - update, - newState, - props, - instance - ); - var callback = update.callback; + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; - if (callback !== null) { - workInProgress.effectTag |= Callback; - var effects = queue.effects; + if (callback !== null) { + workInProgress.flags |= Callback; + var effects = queue.effects; - if (effects === null) { - queue.effects = [update]; - } else { - effects.push(update); - } + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); } } + } - update = update.next; + update = update.next; - if (update === null || update === first) { - pendingQueue = queue.shared.pending; + if (update === null) { + pendingQueue = queue.shared.pending; - if (pendingQueue === null) { - break; - } else { - // An update was scheduled from inside a reducer. Add the new - // pending updates to the end of the list and keep processing. - update = baseQueue.next = pendingQueue.next; - pendingQueue.next = first; - queue.baseQueue = baseQueue = pendingQueue; - queue.shared.pending = null; - } + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we + // unravel them when transferring them to the base queue. + + var _firstPendingUpdate = _lastPendingUpdate.next; + _lastPendingUpdate.next = null; + update = _firstPendingUpdate; + queue.lastBaseUpdate = _lastPendingUpdate; + queue.shared.pending = null; } - } while (true); - } + } + } while (true); - if (newBaseQueueLast === null) { + if (newLastBaseUpdate === null) { newBaseState = newState; - } else { - newBaseQueueLast.next = newBaseQueueFirst; } queue.baseState = newBaseState; - queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. + queue.firstBaseUpdate = newFirstBaseUpdate; + queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. // This should be fine because the only two other things that contribute to // expiration time are props and context. We're already in the middle of the // begin phase by the time we start processing the queue, so we've already @@ -7085,8 +7178,8 @@ function processUpdateQueue( // shouldComponentUpdate is tricky; but we'll have to account for // that regardless. - markUnprocessedUpdateTime(newExpirationTime); - workInProgress.expirationTime = newExpirationTime; + markSkippedUpdateLanes(newLanes); + workInProgress.lanes = newLanes; workInProgress.memoizedState = newState; } @@ -7130,11 +7223,6 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; -function requestCurrentSuspenseConfig() { - return ReactCurrentBatchConfig.suspense; -} - var fakeInternalInstance = {}; var isArray = Array.isArray; // React.Component uses a shared frozen object by default. // We'll use it to determine whether we need to initialize legacy refs. @@ -7235,7 +7323,7 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - if (workInProgress.expirationTime === NoWork) { + if (workInProgress.lanes === NoLanes) { // Queue is always non-null for classes var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; @@ -7245,14 +7333,9 @@ var classComponentUpdater = { isMounted: isMounted, enqueueSetState: function(inst, payload, callback) { var fiber = get(inst); - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); - var update = createUpdate(expirationTime, suspenseConfig); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.payload = payload; if (callback !== undefined && callback !== null) { @@ -7264,18 +7347,13 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { - var fiber = get(inst); - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); - var update = createUpdate(expirationTime, suspenseConfig); + var fiber = get(inst); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ReplaceState; update.payload = payload; @@ -7288,18 +7366,13 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); - var update = createUpdate(expirationTime, suspenseConfig); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); update.tag = ForceUpdate; if (callback !== undefined && callback !== null) { @@ -7311,7 +7384,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } }; @@ -7327,13 +7400,11 @@ function checkShouldComponentUpdate( var instance = workInProgress.stateNode; if (typeof instance.shouldComponentUpdate === "function") { - startPhaseTimer(workInProgress, "shouldComponentUpdate"); var shouldUpdate = instance.shouldComponentUpdate( newProps, newState, nextContext ); - stopPhaseTimer(); { if (shouldUpdate === undefined) { @@ -7736,7 +7807,7 @@ function constructClassInstance(workInProgress, ctor, props) { "Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + "%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n" + "The above lifecycles should be removed. Learn more about this warning here:\n" + - "https://fb.me/react-unsafe-component-lifecycles", + "https://reactjs.org/link/unsafe-component-lifecycles", _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : "", @@ -7759,7 +7830,6 @@ function constructClassInstance(workInProgress, ctor, props) { } function callComponentWillMount(workInProgress, instance) { - startPhaseTimer(workInProgress, "componentWillMount"); var oldState = instance.state; if (typeof instance.componentWillMount === "function") { @@ -7770,8 +7840,6 @@ function callComponentWillMount(workInProgress, instance) { instance.UNSAFE_componentWillMount(); } - stopPhaseTimer(); - if (oldState !== instance.state) { { error( @@ -7793,7 +7861,6 @@ function callComponentWillReceiveProps( nextContext ) { var oldState = instance.state; - startPhaseTimer(workInProgress, "componentWillReceiveProps"); if (typeof instance.componentWillReceiveProps === "function") { instance.componentWillReceiveProps(newProps, nextContext); @@ -7803,8 +7870,6 @@ function callComponentWillReceiveProps( instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); } - stopPhaseTimer(); - if (instance.state !== oldState) { { var componentName = getComponentName(workInProgress.type) || "Component"; @@ -7825,12 +7890,7 @@ function callComponentWillReceiveProps( } } // Invokes the mount life-cycles on a previously never rendered instance. -function mountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { +function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { { checkClassInstance(workInProgress, ctor, newProps); } @@ -7880,7 +7940,7 @@ function mountClassInstance( } } - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; @@ -7904,26 +7964,16 @@ function mountClassInstance( callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - processUpdateQueue( - workInProgress, - newProps, - instance, - renderExpirationTime - ); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } -function resumeMountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { +function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; instance.props = oldProps; @@ -7969,7 +8019,7 @@ function resumeMountClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); newState = workInProgress.memoizedState; if ( @@ -7981,7 +8031,7 @@ function resumeMountClassInstance( // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return false; @@ -8017,8 +8067,6 @@ function resumeMountClassInstance( (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function") ) { - startPhaseTimer(workInProgress, "componentWillMount"); - if (typeof instance.componentWillMount === "function") { instance.componentWillMount(); } @@ -8026,18 +8074,16 @@ function resumeMountClassInstance( if (typeof instance.UNSAFE_componentWillMount === "function") { instance.UNSAFE_componentWillMount(); } - - stopPhaseTimer(); } if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the // memoized state to indicate that this work can be reused. @@ -8057,15 +8103,17 @@ function updateClassInstance( workInProgress, ctor, newProps, - renderExpirationTime + renderLanes ) { var instance = workInProgress.stateNode; cloneUpdateQueue(current, workInProgress); - var oldProps = workInProgress.memoizedProps; - instance.props = + var unresolvedOldProps = workInProgress.memoizedProps; + var oldProps = workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps); + ? unresolvedOldProps + : resolveDefaultProps(workInProgress.type, unresolvedOldProps); + instance.props = oldProps; + var unresolvedNewProps = workInProgress.pendingProps; var oldContext = instance.context; var contextType = ctor.contextType; var nextContext = emptyContextObject; @@ -8091,7 +8139,10 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if (oldProps !== newProps || oldContext !== nextContext) { + if ( + unresolvedOldProps !== unresolvedNewProps || + oldContext !== nextContext + ) { callComponentWillReceiveProps( workInProgress, instance, @@ -8104,11 +8155,11 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); newState = workInProgress.memoizedState; if ( - oldProps === newProps && + unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() @@ -8117,19 +8168,19 @@ function updateClassInstance( // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } @@ -8166,8 +8217,6 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillUpdate === "function" || typeof instance.componentWillUpdate === "function") ) { - startPhaseTimer(workInProgress, "componentWillUpdate"); - if (typeof instance.componentWillUpdate === "function") { instance.componentWillUpdate(newProps, newState, nextContext); } @@ -8175,35 +8224,33 @@ function updateClassInstance( if (typeof instance.UNSAFE_componentWillUpdate === "function") { instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); } - - stopPhaseTimer(); } if (typeof instance.componentDidUpdate === "function") { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } if (typeof instance.getSnapshotBeforeUpdate === "function") { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - oldProps !== current.memoizedProps || + unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } // If shouldComponentUpdate returned false, we should still update the // memoized props/state to indicate that this work can be reused. @@ -8225,7 +8272,7 @@ var didWarnAboutStringRefs; var ownerHasKeyUseWarning; var ownerHasFunctionTypeWarning; -var warnForMissingKey = function(child) {}; +var warnForMissingKey = function(child, returnFiber) {}; { didWarnAboutMaps = false; @@ -8240,7 +8287,7 @@ var warnForMissingKey = function(child) {}; ownerHasKeyUseWarning = {}; ownerHasFunctionTypeWarning = {}; - warnForMissingKey = function(child) { + warnForMissingKey = function(child, returnFiber) { if (child === null || typeof child !== "object") { return; } @@ -8256,21 +8303,17 @@ var warnForMissingKey = function(child) {}; } child._store.validated = true; - var currentComponentErrorInfo = - "Each child in a list should have a unique " + - '"key" prop. See https://fb.me/react-warning-keys for ' + - "more information." + - getCurrentFiberStackInDev(); + var componentName = getComponentName(returnFiber.type) || "Component"; - if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { + if (ownerHasKeyUseWarning[componentName]) { return; } - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; + ownerHasKeyUseWarning[componentName] = true; error( "Each child in a list should have a unique " + - '"key" prop. See https://fb.me/react-warning-keys for ' + + '"key" prop. See https://reactjs.org/link/warning-keys for ' + "more information." ); }; @@ -8308,9 +8351,8 @@ function coerceRef(returnFiber, current, element) { "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-string-ref%s", - mixedRef, - getStackByFiberInDevAndProd(returnFiber) + "https://reactjs.org/link/strict-mode-string-ref", + mixedRef ); } @@ -8328,7 +8370,7 @@ function coerceRef(returnFiber, current, element) { if (!(ownerFiber.tag === ClassComponent)) { throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); } @@ -8382,7 +8424,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + mixedRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } } @@ -8393,41 +8435,27 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { if (returnFiber.type !== "textarea") { - var addendum = ""; - - { - addendum = - " If you meant to render a collection of children, use an array " + - "instead." + - getCurrentFiberStackInDev(); - } - { throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - ")." + - addendum + "). If you meant to render a collection of children, use an array instead." ); } } } -function warnOnFunctionType() { +function warnOnFunctionType(returnFiber) { { - var currentComponentErrorInfo = - "Functions are not valid as a React child. This may happen if " + - "you return a Component instead of from render. " + - "Or maybe you meant to call this function rather than return it." + - getCurrentFiberStackInDev(); + var componentName = getComponentName(returnFiber.type) || "Component"; - if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { + if (ownerHasFunctionTypeWarning[componentName]) { return; } - ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; + ownerHasFunctionTypeWarning[componentName] = true; error( "Functions are not valid as a React child. This may happen if " + @@ -8435,7 +8463,7 @@ function warnOnFunctionType() { "Or maybe you meant to call this function rather than return it." ); } -} // This wrapper function exists because I expect to clone the code in each path +} // We avoid inlining this to avoid potential deopts from using try/catch. // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -8461,7 +8489,7 @@ function ChildReconciler(shouldTrackSideEffects) { } childToDelete.nextEffect = null; - childToDelete.effectTag = Deletion; + childToDelete.flags = Deletion; } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -8525,7 +8553,7 @@ function ChildReconciler(shouldTrackSideEffects) { if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -8533,7 +8561,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -8542,20 +8570,16 @@ function ChildReconciler(shouldTrackSideEffects) { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { - newFiber.effectTag = Placement; + newFiber.flags = Placement; } return newFiber; } - function updateTextNode(returnFiber, current, textContent, expirationTime) { + function updateTextNode(returnFiber, current, textContent, lanes) { if (current === null || current.tag !== HostText) { // Insert - var created = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromText(textContent, returnFiber.mode, lanes); created.return = returnFiber; return created; } else { @@ -8566,7 +8590,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateElement(returnFiber, current, element, expirationTime) { + function updateElement(returnFiber, current, element, lanes) { if (current !== null) { if ( current.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -8586,17 +8610,13 @@ function ChildReconciler(shouldTrackSideEffects) { } } // Insert - var created = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromElement(element, returnFiber.mode, lanes); created.ref = coerceRef(returnFiber, current, element); created.return = returnFiber; return created; } - function updatePortal(returnFiber, current, portal, expirationTime) { + function updatePortal(returnFiber, current, portal, lanes) { if ( current === null || current.tag !== HostPortal || @@ -8604,11 +8624,7 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) { // Insert - var created = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromPortal(portal, returnFiber.mode, lanes); created.return = returnFiber; return created; } else { @@ -8619,13 +8635,13 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateFragment(returnFiber, current, fragment, expirationTime, key) { + function updateFragment(returnFiber, current, fragment, lanes, key) { if (current === null || current.tag !== Fragment) { // Insert var created = createFiberFromFragment( fragment, returnFiber.mode, - expirationTime, + lanes, key ); created.return = returnFiber; @@ -8638,16 +8654,12 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function createChild(returnFiber, newChild, expirationTime) { + function createChild(returnFiber, newChild, lanes) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys. If the previous node is implicitly keyed // we can continue to replace it without aborting even if it is not a text // node. - var created = createFiberFromText( - "" + newChild, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromText("" + newChild, returnFiber.mode, lanes); created.return = returnFiber; return created; } @@ -8658,7 +8670,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created = createFiberFromElement( newChild, returnFiber.mode, - expirationTime + lanes ); _created.ref = coerceRef(returnFiber, null, newChild); @@ -8670,7 +8682,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created2 = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes ); _created2.return = returnFiber; @@ -8682,7 +8694,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created3 = createFiberFromFragment( newChild, returnFiber.mode, - expirationTime, + lanes, null ); @@ -8695,14 +8707,14 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } return null; } - function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { + function updateSlot(returnFiber, oldFiber, newChild, lanes) { // Update the fiber if the keys match, otherwise return null. var key = oldFiber !== null ? oldFiber.key : null; @@ -8714,12 +8726,7 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateTextNode( - returnFiber, - oldFiber, - "" + newChild, - expirationTime - ); + return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); } if (typeof newChild === "object" && newChild !== null) { @@ -8731,17 +8738,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - expirationTime, + lanes, key ); } - return updateElement( - returnFiber, - oldFiber, - newChild, - expirationTime - ); + return updateElement(returnFiber, oldFiber, newChild, lanes); } else { return null; } @@ -8749,12 +8751,7 @@ function ChildReconciler(shouldTrackSideEffects) { case REACT_PORTAL_TYPE: { if (newChild.key === key) { - return updatePortal( - returnFiber, - oldFiber, - newChild, - expirationTime - ); + return updatePortal(returnFiber, oldFiber, newChild, lanes); } else { return null; } @@ -8766,13 +8763,7 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateFragment( - returnFiber, - oldFiber, - newChild, - expirationTime, - null - ); + return updateFragment(returnFiber, oldFiber, newChild, lanes, null); } throwOnInvalidObjectType(returnFiber, newChild); @@ -8780,7 +8771,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } @@ -8792,18 +8783,13 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - expirationTime + lanes ) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys, so we neither have to check the old nor // new node for the key. If both are text nodes, they match. var matchedFiber = existingChildren.get(newIdx) || null; - return updateTextNode( - returnFiber, - matchedFiber, - "" + newChild, - expirationTime - ); + return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes); } if (typeof newChild === "object" && newChild !== null) { @@ -8819,17 +8805,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber, newChild.props.children, - expirationTime, + lanes, newChild.key ); } - return updateElement( - returnFiber, - _matchedFiber, - newChild, - expirationTime - ); + return updateElement(returnFiber, _matchedFiber, newChild, lanes); } case REACT_PORTAL_TYPE: { @@ -8838,12 +8819,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChild.key === null ? newIdx : newChild.key ) || null; - return updatePortal( - returnFiber, - _matchedFiber2, - newChild, - expirationTime - ); + return updatePortal(returnFiber, _matchedFiber2, newChild, lanes); } } @@ -8854,7 +8830,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber3, newChild, - expirationTime, + lanes, null ); } @@ -8864,7 +8840,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } @@ -8874,7 +8850,7 @@ function ChildReconciler(shouldTrackSideEffects) { * Warns if there is a duplicate or missing key */ - function warnOnInvalidKey(child, knownKeys) { + function warnOnInvalidKey(child, knownKeys, returnFiber) { { if (typeof child !== "object" || child === null) { return knownKeys; @@ -8883,7 +8859,7 @@ function ChildReconciler(shouldTrackSideEffects) { switch (child.$$typeof) { case REACT_ELEMENT_TYPE: case REACT_PORTAL_TYPE: - warnForMissingKey(child); + warnForMissingKey(child, returnFiber); var key = child.key; if (typeof key !== "string") { @@ -8921,7 +8897,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - expirationTime + lanes ) { // This algorithm can't optimize by searching from both ends since we // don't have backpointers on fibers. I'm trying to see how far we can get @@ -8944,7 +8920,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (var i = 0; i < newChildren.length; i++) { var child = newChildren[i]; - knownKeys = warnOnInvalidKey(child, knownKeys); + knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); } } @@ -8967,7 +8943,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - expirationTime + lanes ); if (newFiber === null) { @@ -9017,11 +8993,7 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; newIdx < newChildren.length; newIdx++) { - var _newFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - ); + var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes); if (_newFiber === null) { continue; @@ -9050,7 +9022,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - expirationTime + lanes ); if (_newFiber2 !== null) { @@ -9093,7 +9065,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - expirationTime + lanes ) { // This is the same implementation as reconcileChildrenArray(), // but using the iterator instead. @@ -9128,9 +9100,8 @@ function ChildReconciler(shouldTrackSideEffects) { if (newChildrenIterable.entries === iteratorFn) { if (!didWarnAboutMaps) { error( - "Using Maps as children is unsupported and will likely yield " + - "unexpected results. Convert it to a sequence/iterable of keyed " + - "ReactElements instead." + "Using Maps as children is not supported. " + + "Use an array of keyed ReactElements instead." ); } @@ -9147,7 +9118,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (; !_step.done; _step = _newChildren.next()) { var child = _step.value; - knownKeys = warnOnInvalidKey(child, knownKeys); + knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); } } } @@ -9178,12 +9149,7 @@ function ChildReconciler(shouldTrackSideEffects) { nextOldFiber = oldFiber.sibling; } - var newFiber = updateSlot( - returnFiber, - oldFiber, - step.value, - expirationTime - ); + var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); if (newFiber === null) { // TODO: This breaks on empty slots like null children. That's @@ -9232,7 +9198,7 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; !step.done; newIdx++, step = newChildren.next()) { - var _newFiber3 = createChild(returnFiber, step.value, expirationTime); + var _newFiber3 = createChild(returnFiber, step.value, lanes); if (_newFiber3 === null) { continue; @@ -9261,7 +9227,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, step.value, - expirationTime + lanes ); if (_newFiber4 !== null) { @@ -9304,7 +9270,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, textContent, - expirationTime + lanes ) { // There's no need to check for keys on text nodes since we don't have a // way to define them. @@ -9319,11 +9285,7 @@ function ChildReconciler(shouldTrackSideEffects) { // and delete the existing ones. deleteRemainingChildren(returnFiber, currentFirstChild); - var created = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromText(textContent, returnFiber.mode, lanes); created.return = returnFiber; return created; } @@ -9332,7 +9294,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, element, - expirationTime + lanes ) { var key = element.key; var child = currentFirstChild; @@ -9401,17 +9363,13 @@ function ChildReconciler(shouldTrackSideEffects) { var created = createFiberFromFragment( element.props.children, returnFiber.mode, - expirationTime, + lanes, element.key ); created.return = returnFiber; return created; } else { - var _created4 = createFiberFromElement( - element, - returnFiber.mode, - expirationTime - ); + var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); _created4.ref = coerceRef(returnFiber, currentFirstChild, element); _created4.return = returnFiber; @@ -9423,7 +9381,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, portal, - expirationTime + lanes ) { var key = portal.key; var child = currentFirstChild; @@ -9452,11 +9410,7 @@ function ChildReconciler(shouldTrackSideEffects) { child = child.sibling; } - var created = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - ); + var created = createFiberFromPortal(portal, returnFiber.mode, lanes); created.return = returnFiber; return created; } // This API will tag the children with the side-effect of the reconciliation @@ -9467,7 +9421,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ) { // This function is not recursive. // If the top level item is an array, we treat it as a set of children, @@ -9496,7 +9450,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ) ); @@ -9506,7 +9460,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ) ); } @@ -9518,7 +9472,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, "" + newChild, - expirationTime + lanes ) ); } @@ -9528,7 +9482,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); } @@ -9537,7 +9491,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); } @@ -9547,7 +9501,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(); + warnOnFunctionType(returnFiber); } } @@ -9570,12 +9524,13 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case FunctionComponent: { - var Component = returnFiber.type; - + case Block: + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { { throw Error( - (Component.displayName || Component.name || "Component") + + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); } @@ -9617,11 +9572,11 @@ function cloneChildFibers(current, workInProgress) { newChild.sibling = null; } // Reset a workInProgress child set to prepare it for a second pass. -function resetChildFibers(workInProgress, renderExpirationTime) { +function resetChildFibers(workInProgress, lanes) { var child = workInProgress.child; while (child !== null) { - resetWorkInProgress(child, renderExpirationTime); + resetWorkInProgress(child, lanes); child = child.sibling; } } @@ -9793,7 +9748,7 @@ function findFirstSuspended(row) { // keep track of whether it suspended or not. node.memoizedProps.revealOrder !== undefined ) { - var didSuspend = (node.effectTag & DidCapture) !== NoEffect; + var didSuspend = (node.flags & DidCapture) !== NoFlags; if (didSuspend) { return node; @@ -9823,18 +9778,9 @@ function findFirstSuspended(row) { return null; } -function createDeprecatedResponderListener(responder, props) { - var eventResponderListener = { - responder: responder, - props: props - }; - - { - Object.freeze(eventResponderListener); - } - - return eventResponderListener; -} +var NoFlags$1 = + /* */ + 0; // Represents whether effect should fire. var HasEffect = /* */ @@ -9847,16 +9793,113 @@ var Passive$1 = /* */ 4; -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var isHydrating = false; + +function enterHydrationState(fiber) { + { + return false; + } +} + +function prepareToHydrateHostInstance( + fiber, + rootContainerInstance, + hostContext +) { + { + { + throw Error( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } +} + +function prepareToHydrateHostTextInstance(fiber) { + { + { + throw Error( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + var shouldUpdate = hydrateTextInstance(); +} + +function popHydrationState(fiber) { + { + return false; + } +} + +function getIsHydrating() { + return isHydrating; +} + +// and should be reset before starting a new render. +// This tracks which mutable sources need to be reset after a render. + +var workInProgressSources = []; +var rendererSigil$1; + +{ + // Used to detect multiple renderers using the same mutable source. + rendererSigil$1 = {}; +} + +function markSourceAsDirty(mutableSource) { + workInProgressSources.push(mutableSource); +} +function resetWorkInProgressVersions() { + for (var i = 0; i < workInProgressSources.length; i++) { + var mutableSource = workInProgressSources[i]; + + { + mutableSource._workInProgressVersionPrimary = null; + } + } + + workInProgressSources.length = 0; +} +function getWorkInProgressVersion(mutableSource) { + { + return mutableSource._workInProgressVersionPrimary; + } +} +function setWorkInProgressVersion(mutableSource, version) { + { + mutableSource._workInProgressVersionPrimary = version; + } + + workInProgressSources.push(mutableSource); +} +function warnAboutMultipleRenderersDEV(mutableSource) { + { + { + if (mutableSource._currentPrimaryRenderer == null) { + mutableSource._currentPrimaryRenderer = rendererSigil$1; + } else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) { + error( + "Detected multiple renderers concurrently rendering the " + + "same mutable source. This is currently unsupported." + ); + } + } + } +} // Eager reads the version of a mutable source and stores it on the root. + +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; +var didWarnAboutUseOpaqueIdentifier; { + didWarnAboutUseOpaqueIdentifier = {}; didWarnAboutMismatchedHooksForComponent = new Set(); } // These are set right before calling the component. -var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from +var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from // the work-in-progress hook. var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The @@ -9870,7 +9913,12 @@ var workInProgressHook = null; // Whether an update was scheduled at any point d // finished evaluating this component. This is an optimization so we know // whether we need to clear render phase updates after a throw. -var didScheduleRenderPhaseUpdate = false; +var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This +// gets reset after each attempt. +// TODO: Maybe there's some way to consolidate this with +// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. + +var didScheduleRenderPhaseUpdateDuringThisPass = false; var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. @@ -9954,7 +10002,7 @@ function warnOnHookMismatchInDev(currentHookName) { error( "React has detected a change in the order of Hooks called by %s. " + "This will lead to bugs and errors if not fixed. " + - "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + + "For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n" + " Previous render Next render\n" + " ------------------------------------------------------\n" + "%s" + @@ -9970,7 +10018,7 @@ function warnOnHookMismatchInDev(currentHookName) { function throwInvalidHookError() { { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } } @@ -10029,9 +10077,9 @@ function renderWithHooks( Component, props, secondArg, - nextRenderExpirationTime + nextRenderLanes ) { - renderExpirationTime = nextRenderExpirationTime; + renderLanes = nextRenderLanes; currentlyRenderingFiber$1 = workInProgress; { @@ -10044,7 +10092,7 @@ function renderWithHooks( workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.expirationTime = NoWork; // The following should have already been reset + workInProgress.lanes = NoLanes; // The following should have already been reset // currentHook = null; // workInProgressHook = null; // didScheduleRenderPhaseUpdate = false; @@ -10057,28 +10105,28 @@ function renderWithHooks( { if (current !== null && current.memoizedState !== null) { - ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, // but no stateful hooks have been used. // We want to match the production code behavior (which will use HooksDispatcherOnMount), // but with the extra DEV validation to ensure hooks ordering hasn't changed. // This dispatcher does that. - ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; } else { - ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } var children = Component(props, secondArg); // Check if there was a render phase update - if (workInProgress.expirationTime === renderExpirationTime) { + if (didScheduleRenderPhaseUpdateDuringThisPass) { // Keep rendering in a loop for as long as render phase updates continue to // be scheduled. Use a counter to prevent infinite loops. var numberOfReRenders = 0; do { - workInProgress.expirationTime = NoWork; + didScheduleRenderPhaseUpdateDuringThisPass = false; if (!(numberOfReRenders < RE_RENDER_LIMIT)) { throw Error( @@ -10103,13 +10151,13 @@ function renderWithHooks( hookTypesUpdateIndexDev = -1; } - ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV; children = Component(props, secondArg); - } while (workInProgress.expirationTime === renderExpirationTime); + } while (didScheduleRenderPhaseUpdateDuringThisPass); } // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; { workInProgress._debugHookTypes = hookTypesDev; @@ -10117,7 +10165,7 @@ function renderWithHooks( // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; - renderExpirationTime = NoWork; + renderLanes = NoLanes; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -10138,18 +10186,15 @@ function renderWithHooks( return children; } -function bailoutHooks(current, workInProgress, expirationTime) { +function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; - workInProgress.effectTag &= ~(Passive | Update); - - if (current.expirationTime <= expirationTime) { - current.expirationTime = NoWork; - } + workInProgress.flags &= ~(Passive | Update); + current.lanes = removeLanes(current.lanes, lanes); } function resetHooksAfterThrow() { // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; if (didScheduleRenderPhaseUpdate) { // There were render phase updates. These are only valid for this render @@ -10171,9 +10216,11 @@ function resetHooksAfterThrow() { hook = hook.next; } + + didScheduleRenderPhaseUpdate = false; } - renderExpirationTime = NoWork; + renderLanes = NoLanes; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -10182,9 +10229,10 @@ function resetHooksAfterThrow() { hookTypesDev = null; hookTypesUpdateIndexDev = -1; currentHookNameInDev = null; + isUpdatingOpaqueValueInRenderPhase = false; } - didScheduleRenderPhaseUpdate = false; + didScheduleRenderPhaseUpdateDuringThisPass = false; } function mountWorkInProgressHook() { @@ -10331,6 +10379,17 @@ function updateReducer(reducer, initialArg, init) { pendingQueue.next = baseFirst; } + { + if (current.baseQueue !== baseQueue) { + // Internal invariant that should never happen, but feasibly could in + // the future if we implement resuming, or some form of that. + error( + "Internal error: Expected work-in-progress queue to be a clone. " + + "This is a bug in React." + ); + } + } + current.baseQueue = baseQueue = pendingQueue; queue.pending = null; } @@ -10345,15 +10404,14 @@ function updateReducer(reducer, initialArg, init) { var update = first; do { - var updateExpirationTime = update.expirationTime; + var updateLane = update.lane; - if (updateExpirationTime < renderExpirationTime) { + if (!isSubsetOfLanes(renderLanes, updateLane)) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, + lane: updateLane, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, @@ -10366,35 +10424,29 @@ function updateReducer(reducer, initialArg, init) { } else { newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. + // TODO: Don't need to accumulate this. Instead, we can remove + // renderLanes from the original lanes. - if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { - currentlyRenderingFiber$1.expirationTime = updateExpirationTime; - markUnprocessedUpdateTime(updateExpirationTime); - } + currentlyRenderingFiber$1.lanes = mergeLanes( + currentlyRenderingFiber$1.lanes, + updateLane + ); + markSkippedUpdateLanes(updateLane); } else { // This update does have sufficient priority. if (newBaseQueueLast !== null) { var _clone = { - expirationTime: Sync, - // This update is going to be committed so we never want uncommit it. - suspenseConfig: update.suspenseConfig, + // This update is going to be committed so we never want uncommit + // it. Using NoLane works because 0 is a subset of all bitmasks, so + // this will never be skipped by the check above. + lane: NoLane, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }; newBaseQueueLast = newBaseQueueLast.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reverseable value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ); // Process this update. + } // Process this update. if (update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -10479,7 +10531,252 @@ function rerenderReducer(reducer, initialArg, init) { queue.lastRenderedState = newState; } - return [newState, dispatch]; + return [newState, dispatch]; +} + +function readFromUnsubcribedMutableSource(root, source, getSnapshot) { + { + warnAboutMultipleRenderersDEV(source); + } + + var getVersion = source._getVersion; + var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render? + + var isSafeToReadFromSource = false; // Check the version first. + // If this render has already been started with a specific version, + // we can use it alone to determine if we can safely read from the source. + + var currentRenderVersion = getWorkInProgressVersion(source); + + if (currentRenderVersion !== null) { + // It's safe to read if the store hasn't been mutated since the last time + // we read something. + isSafeToReadFromSource = currentRenderVersion === version; + } else { + // If there's no version, then this is the first time we've read from the + // source during the current render pass, so we need to do a bit more work. + // What we need to determine is if there are any hooks that already + // subscribed to the source, and if so, whether there are any pending + // mutations that haven't been synchronized yet. + // + // If there are no pending mutations, then `root.mutableReadLanes` will be + // empty, and we know we can safely read. + // + // If there *are* pending mutations, we may still be able to safely read + // if the currently rendering lanes are inclusive of the pending mutation + // lanes, since that guarantees that the value we're about to read from + // the source is consistent with the values that we read during the most + // recent mutation. + isSafeToReadFromSource = isSubsetOfLanes( + renderLanes, + root.mutableReadLanes + ); + + if (isSafeToReadFromSource) { + // If it's safe to read from this source during the current render, + // store the version in case other components read from it. + // A changed version number will let those components know to throw and restart the render. + setWorkInProgressVersion(source, version); + } + } + + if (isSafeToReadFromSource) { + var snapshot = getSnapshot(source._source); + + { + if (typeof snapshot === "function") { + error( + "Mutable source should not return a function as the snapshot value. " + + "Functions may close over mutable values and cause tearing." + ); + } + } + + return snapshot; + } else { + // This handles the special case of a mutable source being shared between renderers. + // In that case, if the source is mutated between the first and second renderer, + // The second renderer don't know that it needs to reset the WIP version during unwind, + // (because the hook only marks sources as dirty if it's written to their WIP version). + // That would cause this tear check to throw again and eventually be visible to the user. + // We can avoid this infinite loop by explicitly marking the source as dirty. + // + // This can lead to tearing in the first renderer when it resumes, + // but there's nothing we can do about that (short of throwing here and refusing to continue the render). + markSourceAsDirty(source); + + { + throw Error( + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." + ); + } + } +} + +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = getWorkInProgressRoot(); + + if (!(root !== null)) { + throw Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var getVersion = source._getVersion; + var version = getVersion(source._source); + var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const + + var _dispatcher$useState = dispatcher.useState(function() { + return readFromUnsubcribedMutableSource(root, source, getSnapshot); + }), + currentSnapshot = _dispatcher$useState[0], + setSnapshot = _dispatcher$useState[1]; + + var snapshot = currentSnapshot; // Grab a handle to the state hook as well. + // We use it to clear the pending update queue if we have a new source. + + var stateHook = workInProgressHook; + var memoizedState = hook.memoizedState; + var refs = memoizedState.refs; + var prevGetSnapshot = refs.getSnapshot; + var prevSource = memoizedState.source; + var prevSubscribe = memoizedState.subscribe; + var fiber = currentlyRenderingFiber$1; + hook.memoizedState = { + refs: refs, + source: source, + subscribe: subscribe + }; // Sync the values needed by our subscription handler after each commit. + + dispatcher.useEffect( + function() { + refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes, + // but this hook recreates the queue in certain cases to avoid updates from stale sources. + // handleChange() below needs to reference the dispatch function without re-subscribing, + // so we use a ref to ensure that it always has the latest version. + + refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now. + + var maybeNewVersion = getVersion(source._source); + + if (!objectIs(version, maybeNewVersion)) { + var maybeNewSnapshot = getSnapshot(source._source); + + { + if (typeof maybeNewSnapshot === "function") { + error( + "Mutable source should not return a function as the snapshot value. " + + "Functions may close over mutable values and cause tearing." + ); + } + } + + if (!objectIs(snapshot, maybeNewSnapshot)) { + setSnapshot(maybeNewSnapshot); + var lane = requestUpdateLane(fiber); + markRootMutableRead(root, lane); + } // If the source mutated between render and now, + // there may be state updates already scheduled from the old source. + // Entangle the updates so that they render in the same batch. + + markRootEntangled(root, root.mutableReadLanes); + } + }, + [getSnapshot, source, subscribe] + ); // If we got a new source or subscribe function, re-subscribe in a passive effect. + + dispatcher.useEffect( + function() { + var handleChange = function() { + var latestGetSnapshot = refs.getSnapshot; + var latestSetSnapshot = refs.setSnapshot; + + try { + latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. + + var lane = requestUpdateLane(fiber); + markRootMutableRead(root, lane); + } catch (error) { + // A selector might throw after a source mutation. + // e.g. it might try to read from a part of the store that no longer exists. + // In this case we should still schedule an update with React. + // Worst case the selector will throw again and then an error boundary will handle it. + latestSetSnapshot(function() { + throw error; + }); + } + }; + + var unsubscribe = subscribe(source._source, handleChange); + + { + if (typeof unsubscribe !== "function") { + error( + "Mutable source subscribe function must return an unsubscribe function." + ); + } + } + + return unsubscribe; + }, + [source, subscribe] + ); // If any of the inputs to useMutableSource change, reading is potentially unsafe. + // + // If either the source or the subscription have changed we can't can't trust the update queue. + // Maybe the source changed in a way that the old subscription ignored but the new one depends on. + // + // If the getSnapshot function changed, we also shouldn't rely on the update queue. + // It's possible that the underlying source was mutated between the when the last "change" event fired, + // and when the current render (with the new getSnapshot function) is processed. + // + // In both cases, we need to throw away pending updates (since they are no longer relevant) + // and treat reading from the source as we do in the mount case. + + if ( + !objectIs(prevGetSnapshot, getSnapshot) || + !objectIs(prevSource, source) || + !objectIs(prevSubscribe, subscribe) + ) { + // Create a new queue and setState method, + // So if there are interleaved updates, they get pushed to the older queue. + // When this becomes current, the previous queue and dispatch method will be discarded, + // including any interleaving updates that occur. + var newQueue = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }; + newQueue.dispatch = setSnapshot = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + newQueue + ); + stateHook.queue = newQueue; + stateHook.baseQueue = null; + snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot); + stateHook.memoizedState = stateHook.baseState = snapshot; + } + + return snapshot; +} + +function mountMutableSource(source, getSnapshot, subscribe) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = { + refs: { + getSnapshot: getSnapshot, + setSnapshot: null + }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); +} + +function updateMutableSource(source, getSnapshot, subscribe) { + var hook = updateWorkInProgressHook(); + return useMutableSource(hook, source, getSnapshot, subscribe); } function mountState(initialState) { @@ -10546,16 +10843,14 @@ function pushEffect(tag, create, destroy, deps) { function mountRef(initialValue) { var hook = mountWorkInProgressHook(); - var ref = { - current: initialValue - }; { - Object.seal(ref); + var _ref2 = { + current: initialValue + }; + hook.memoizedState = _ref2; + return _ref2; } - - hook.memoizedState = ref; - return ref; } function updateRef(initialValue) { @@ -10563,19 +10858,19 @@ function updateRef(initialValue) { return hook.memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, undefined, nextDeps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var destroy = undefined; @@ -10588,15 +10883,15 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - pushEffect(hookEffectTag, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - HasEffect | hookEffectTag, + HasEffect | hookFlags, create, destroy, nextDeps @@ -10770,129 +11065,175 @@ function updateMemo(nextCreate, deps) { return nextValue; } -function mountDeferredValue(value, config) { +function mountDeferredValue(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function updateDeferredValue(value, config) { +function updateDeferredValue(value) { var _updateState = updateState(), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function rerenderDeferredValue(value, config) { +function rerenderDeferredValue(value) { var _rerenderState = rerenderState(), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); - runWithPriority( - priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, - function() { - setPending(true); - } - ); - runWithPriority( - priorityLevel > NormalPriority ? NormalPriority : priorityLevel, - function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; - try { - setPending(false); - callback(); - } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + { + runWithPriority( + priorityLevel < UserBlockingPriority$1 + ? UserBlockingPriority$1 + : priorityLevel, + function() { + setPending(true); } - } - ); + ); + runWithPriority( + priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, + function() { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } + } + ); + } } -function mountTransition(config) { +function mountTransition() { var _mountState2 = mountState(false), isPending = _mountState2[0], - setPending = _mountState2[1]; + setPending = _mountState2[1]; // The `start` method never changes. - var start = mountCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var start = startTransition.bind(null, setPending); + var hook = mountWorkInProgressHook(); + hook.memoizedState = start; return [start, isPending]; } -function updateTransition(config) { +function updateTransition() { var _updateState2 = updateState(), - isPending = _updateState2[0], - setPending = _updateState2[1]; + isPending = _updateState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } -function rerenderTransition(config) { +function rerenderTransition() { var _rerenderState2 = rerenderState(), - isPending = _rerenderState2[0], - setPending = _rerenderState2[1]; + isPending = _rerenderState2[0]; - var start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config - ]); + var hook = updateWorkInProgressHook(); + var start = hook.memoizedState; return [start, isPending]; } +var isUpdatingOpaqueValueInRenderPhase = false; +function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { + { + return isUpdatingOpaqueValueInRenderPhase; + } +} + +function warnOnOpaqueIdentifierAccessInDEV(fiber) { + { + // TODO: Should warn in effects and callbacks, too + var name = getComponentName(fiber.type) || "Unknown"; + + if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) { + error( + "The object passed back from useOpaqueIdentifier is meant to be " + + "passed through to attributes only. Do not read the " + + "value directly." + ); + + didWarnAboutUseOpaqueIdentifier[name] = true; + } + } +} + +function mountOpaqueIdentifier() { + var makeId = makeClientIdInDEV.bind( + null, + warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1) + ); + + { + var _id = makeId(); + + mountState(_id); + return _id; + } +} + +function updateOpaqueIdentifier() { + var id = updateState()[0]; + return id; +} + +function rerenderOpaqueIdentifier() { + var id = rerenderState()[0]; + return id; +} + function dispatchAction(fiber, queue, action) { { if (typeof arguments[3] === "function") { @@ -10904,25 +11245,15 @@ function dispatchAction(fiber, queue, action) { } } - var currentTime = requestCurrentTimeForUpdate(); - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - fiber, - suspenseConfig - ); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); var update = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, + lane: lane, action: action, eagerReducer: null, eagerState: null, next: null - }; - - { - update.priority = getCurrentPriorityLevel(); - } // Append the update to the end of the list. + }; // Append the update to the end of the list. var pending = queue.pending; @@ -10944,13 +11275,11 @@ function dispatchAction(fiber, queue, action) { // This is a render phase update. Stash it in a lazily-created map of // queue -> linked list of updates. After this render pass, we'll restart // and apply the stashed updates on top of the work-in-progress hook. - didScheduleRenderPhaseUpdate = true; - update.expirationTime = renderExpirationTime; - currentlyRenderingFiber$1.expirationTime = renderExpirationTime; + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; } else { if ( - fiber.expirationTime === NoWork && - (alternate === null || alternate.expirationTime === NoWork) + fiber.lanes === NoLanes && + (alternate === null || alternate.lanes === NoLanes) ) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the @@ -10961,8 +11290,8 @@ function dispatchAction(fiber, queue, action) { var prevDispatcher; { - prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { @@ -10986,7 +11315,7 @@ function dispatchAction(fiber, queue, action) { // Suppress the error. It will throw again in the render phase. } finally { { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } } } @@ -11000,18 +11329,10 @@ function dispatchAction(fiber, queue, action) { } } - scheduleWork(fiber, expirationTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } -function mountEventListener(event) { - return undefined; -} - -function updateEventListener(event) { - return undefined; -} - var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -11024,10 +11345,11 @@ var ContextOnlyDispatcher = { useRef: throwInvalidHookError, useState: throwInvalidHookError, useDebugValue: throwInvalidHookError, - useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useEvent: throwInvalidHookError + useMutableSource: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, + unstable_isNewReconciler: enableNewReconciler }; var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; @@ -11052,7 +11374,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; "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" + "https://reactjs.org/link/rules-of-hooks" ); }; @@ -11093,25 +11415,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; mountHookTypesDev(); checkDepsAreArrayDev(deps); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11122,13 +11444,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11136,26 +11458,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - mountHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; mountHookTypesDev(); - return mountEventListener(); - } + return mountMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + mountHookTypesDev(); + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function(context, observedBits) { @@ -11189,25 +11512,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11218,13 +11541,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11232,26 +11555,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return mountEventListener(); - } + return mountMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + updateHookTypesDev(); + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; HooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -11285,25 +11609,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11314,13 +11638,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11328,26 +11652,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateEventListener(); - } + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + updateHookTypesDev(); + return updateOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; HooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -11381,25 +11706,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11410,13 +11735,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11424,26 +11749,27 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; - updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); - }, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { currentHookNameInDev = "useDeferredValue"; updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition: function(config) { + useTransition: function() { currentHookNameInDev = "useTransition"; updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateEventListener(); - } + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; + updateHookTypesDev(); + return rerenderOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function(context, observedBits) { @@ -11484,26 +11810,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11516,13 +11842,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11531,30 +11857,31 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; + useDeferredValue: function(value) { + currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); mountHookTypesDev(); - return createDeprecatedResponderListener(responder, props); + return mountDeferredValue(value); }, - useDeferredValue: function(value, config) { - currentHookNameInDev = "useDeferredValue"; + useTransition: function() { + currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountTransition(); }, - useTransition: function(config) { - currentHookNameInDev = "useTransition"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountTransition(config); + return mountMutableSource(source, getSnapshot, subscribe); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountEventListener(); - } + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -11595,26 +11922,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11627,13 +11954,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11642,30 +11969,31 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; + useDeferredValue: function(value) { + currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); + return updateDeferredValue(value); }, - useDeferredValue: function(value, config) { - currentHookNameInDev = "useDeferredValue"; + useTransition: function() { + currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateTransition(); }, - useTransition: function(config) { - currentHookNameInDev = "useTransition"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateTransition(config); + return updateMutableSource(source, getSnapshot, subscribe); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateEventListener(); - } + return updateOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -11706,26 +12034,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11738,13 +12066,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11753,30 +12081,31 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateDebugValue(); }, - useResponder: function(responder, props) { - currentHookNameInDev = "useResponder"; + useDeferredValue: function(value) { + currentHookNameInDev = "useDeferredValue"; warnInvalidHookAccess(); updateHookTypesDev(); - return createDeprecatedResponderListener(responder, props); + return rerenderDeferredValue(value); }, - useDeferredValue: function(value, config) { - currentHookNameInDev = "useDeferredValue"; + useTransition: function() { + currentHookNameInDev = "useTransition"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderTransition(); }, - useTransition: function(config) { - currentHookNameInDev = "useTransition"; + useMutableSource: function(source, getSnapshot, subscribe) { + currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderTransition(config); + return updateMutableSource(source, getSnapshot, subscribe); }, - useEvent: function(event) { - currentHookNameInDev = "useEvent"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateEventListener(); - } + return rerenderOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler }; } @@ -11817,40 +12146,15 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } } -function enterHydrationState(fiber) { - { - return false; - } -} - -function prepareToHydrateHostInstance( - fiber, - rootContainerInstance, - hostContext -) { - { - { - throw Error( - "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } -} - -function prepareToHydrateHostTextInstance(fiber) { - { - { - throw Error( - "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - var shouldUpdate = hydrateTextInstance(); -} +function transferActualDuration(fiber) { + // Transfer time spent rendering these children so we don't lose it + // after we rerender. This is used as a helper in special cases + // where we should count the work of multiple passes. + var child = fiber.child; -function popHydrationState(fiber) { - { - return false; + while (child) { + fiber.actualDuration += child.actualDuration; + child = child.sibling; } } @@ -11876,12 +12180,7 @@ var didWarnAboutTailOptions; didWarnAboutTailOptions = {}; } -function reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime -) { +function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { if (current === null) { // If this is a fresh new component that hasn't been rendered yet, we // won't update its child set by applying minimal side-effects. Instead, @@ -11891,7 +12190,7 @@ function reconcileChildren( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); } else { // If the current child is the same as the work in progress, it means that @@ -11903,7 +12202,7 @@ function reconcileChildren( workInProgress, current.child, nextChildren, - renderExpirationTime + renderLanes ); } } @@ -11912,7 +12211,7 @@ function forceUnmountCurrentAndReconcile( current, workInProgress, nextChildren, - renderExpirationTime + renderLanes ) { // This function is fork of reconcileChildren. It's used in cases where we // want to reconcile without matching against the existing set. This has the @@ -11926,7 +12225,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, current.child, null, - renderExpirationTime + renderLanes ); // In the second pass, we mount the new children. The trick here is that we // pass null in place of where we usually pass the current child set. This has // the effect of remounting all children regardless of whether their @@ -11936,7 +12235,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); } @@ -11945,7 +12244,7 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens after the first render suspends. @@ -11971,7 +12270,7 @@ function updateForwardRef( var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent var nextChildren; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); { ReactCurrentOwner$1.current = workInProgress; @@ -11982,28 +12281,19 @@ function updateForwardRef( render, nextProps, ref, - renderExpirationTime + renderLanes ); setIsRendering(false); } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderExpirationTime); - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + bailoutHooks(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12012,8 +12302,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (current === null) { var type = Component.type; @@ -12043,8 +12333,8 @@ function updateMemoComponent( workInProgress, resolvedType, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -12067,9 +12357,9 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, - renderExpirationTime + renderLanes ); child.ref = workInProgress.ref; child.return = workInProgress; @@ -12095,7 +12385,7 @@ function updateMemoComponent( var currentChild = current.child; // This is always exactly one child - if (updateExpirationTime < renderExpirationTime) { + if (!includesSomeLane(updateLanes, renderLanes)) { // This will be the props with resolved defaultProps, // unlike current.memoizedProps which will be the unresolved ones. var prevProps = currentChild.memoizedProps; // Default to shallow comparison @@ -12104,15 +12394,11 @@ function updateMemoComponent( compare = compare !== null ? compare : shallowEqual; if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; var newChild = createWorkInProgress(currentChild, nextProps); newChild.ref = workInProgress.ref; newChild.return = workInProgress; @@ -12125,8 +12411,8 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens when the inner render suspends. @@ -12141,19 +12427,27 @@ function updateSimpleMemoComponent( // We warn when you define propTypes on lazy() // so let's just skip over it to find memo() outer wrapper. // Inner props for memo are validated later. - outerMemoType = refineResolvedLazyComponent(outerMemoType); - } + var lazyComponent = outerMemoType; + var payload = lazyComponent._payload; + var init = lazyComponent._init; - var outerPropTypes = outerMemoType && outerMemoType.propTypes; - - if (outerPropTypes) { - checkPropTypes( - outerPropTypes, - nextProps, // Resolved (SimpleMemoComponent has no defaultProps) - "prop", - getComponentName(outerMemoType) - ); - } // Inner propTypes will be validated in the function component path. + try { + outerMemoType = init(payload); + } catch (x) { + outerMemoType = null; + } // Inner propTypes will be validated in the function component path. + + var outerPropTypes = outerMemoType && outerMemoType.propTypes; + + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + nextProps, // Resolved (SimpleMemoComponent has no defaultProps) + "prop", + getComponentName(outerMemoType) + ); + } + } } } @@ -12167,10 +12461,10 @@ function updateSimpleMemoComponent( ) { didReceiveUpdate = false; - if (updateExpirationTime < renderExpirationTime) { - // The pending update priority was cleared at the beginning of - // beginWork. We're about to bail out, but there might be additional - // updates at a lower priority. Usually, the priority level of the + if (!includesSomeLane(renderLanes, updateLanes)) { + // The pending lanes were cleared at the beginning of beginWork. We're + // about to bail out, but there might be other lanes that weren't + // included in the current render. Usually, the priority level of the // remaining updates is accumlated during the evaluation of the // component (i.e. when processing the update queue). But since since // we're bailing out early *without* evaluating the component, we need @@ -12181,12 +12475,16 @@ function updateSimpleMemoComponent( // contains hooks. // TODO: Move the reset at in beginWork out of the common path so that // this is no longer necessary. - workInProgress.expirationTime = current.expirationTime; + workInProgress.lanes = current.lanes; return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); + } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { + // This is a special case that only exists for legacy mode. + // See https://github.com/facebook/react/pull/19216. + didReceiveUpdate = true; } } } @@ -12196,35 +12494,103 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ); } -function updateFragment(current, workInProgress, renderExpirationTime) { +function updateOffscreenComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + var prevState = current !== null ? current.memoizedState : null; + + if ( + nextProps.mode === "hidden" || + nextProps.mode === "unstable-defer-without-hiding" + ) { + if ((workInProgress.mode & ConcurrentMode) === NoMode) { + // In legacy sync mode, don't defer the subtree. Render it now. + // TODO: Figure out what we should do in Blocking mode. + var nextState = { + baseLanes: NoLanes + }; + workInProgress.memoizedState = nextState; + pushRenderLanes(workInProgress, renderLanes); + } else if (!includesSomeLane(renderLanes, OffscreenLane)) { + var nextBaseLanes; + + if (prevState !== null) { + var prevBaseLanes = prevState.baseLanes; + nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes); + } else { + nextBaseLanes = renderLanes; + } // Schedule this fiber to re-render at offscreen priority. Then bailout. + + { + markSpawnedWork(OffscreenLane); + } + + workInProgress.lanes = workInProgress.childLanes = laneToLanes( + OffscreenLane + ); + var _nextState = { + baseLanes: nextBaseLanes + }; + workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway + // to avoid a push/pop misalignment. + + pushRenderLanes(workInProgress, nextBaseLanes); + return null; + } else { + // Rendering at offscreen, so we can clear the base lanes. + var _nextState2 = { + baseLanes: NoLanes + }; + workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. + + var subtreeRenderLanes = + prevState !== null ? prevState.baseLanes : renderLanes; + pushRenderLanes(workInProgress, subtreeRenderLanes); + } + } else { + var _subtreeRenderLanes; + + if (prevState !== null) { + _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state + + workInProgress.memoizedState = null; + } else { + // We weren't previously hidden, and we still aren't, so there's nothing + // special to do. Need to push to the stack regardless, though, to avoid + // a push/pop misalignment. + _subtreeRenderLanes = renderLanes; + } + + pushRenderLanes(workInProgress, _subtreeRenderLanes); + } + + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; +} // Note: These happen to have identical begin phases, for now. We shouldn't hold +// ourselves to this constraint, though. If the behavior diverges, we should +// fork the function. + +var updateLegacyHiddenComponent = updateOffscreenComponent; + +function updateFragment(current, workInProgress, renderLanes) { var nextChildren = workInProgress.pendingProps; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } -function updateMode(current, workInProgress, renderExpirationTime) { +function updateMode(current, workInProgress, renderLanes) { var nextChildren = workInProgress.pendingProps.children; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } -function updateProfiler(current, workInProgress, renderExpirationTime) { +function updateProfiler(current, workInProgress, renderLanes) { { - workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase. + workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, var stateNode = workInProgress.stateNode; @@ -12234,12 +12600,7 @@ function updateProfiler(current, workInProgress, renderExpirationTime) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12251,7 +12612,7 @@ function markRef(current, workInProgress) { (current !== null && current.ref !== ref) ) { // Schedule a Ref effect - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } } @@ -12260,7 +12621,7 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -12287,7 +12648,7 @@ function updateFunctionComponent( } var nextChildren; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); { ReactCurrentOwner$1.current = workInProgress; @@ -12298,28 +12659,19 @@ function updateFunctionComponent( Component, nextProps, context, - renderExpirationTime + renderLanes ); setIsRendering(false); } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderExpirationTime); - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + bailoutHooks(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12328,7 +12680,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -12358,7 +12710,7 @@ function updateClassComponent( hasContext = false; } - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); var instance = workInProgress.stateNode; var shouldUpdate; @@ -12371,16 +12723,11 @@ function updateClassComponent( current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); + mountClassInstance(workInProgress, Component, nextProps, renderLanes); shouldUpdate = true; } else if (current === null) { // In a resume, we'll already have an instance we can reuse. @@ -12388,7 +12735,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ); } else { shouldUpdate = updateClassInstance( @@ -12396,7 +12743,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ); } @@ -12406,13 +12753,13 @@ function updateClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ); { var inst = workInProgress.stateNode; - if (inst.props !== nextProps) { + if (shouldUpdate && inst.props !== nextProps) { if (!didWarnAboutReassigningProps) { error( "It looks like %s is reassigning its own `this.props` while rendering. " + @@ -12434,11 +12781,11 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ) { // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); - var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; + var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags; if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering @@ -12446,11 +12793,7 @@ function finishClassComponent( invalidateContextProvider(workInProgress, Component, false); } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } var instance = workInProgress.stateNode; // Rerender @@ -12481,7 +12824,7 @@ function finishClassComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (current !== null && didCaptureError) { // If we're recovering from an error, reconcile without reusing any of @@ -12492,15 +12835,10 @@ function finishClassComponent( current, workInProgress, nextChildren, - renderExpirationTime + renderLanes ); } else { - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); } // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. @@ -12530,7 +12868,7 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } -function updateHostRoot(current, workInProgress, renderExpirationTime) { +function updateHostRoot(current, workInProgress, renderLanes) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; @@ -12544,32 +12882,24 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) { var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); + processUpdateQueue(workInProgress, nextProps, null, renderLanes); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". var nextChildren = nextState.element; if (nextChildren === prevChildren) { - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } var root = workInProgress.stateNode; if (root.hydrate && enterHydrationState()) { - // If we don't have any current children this might be the first pass. - // We always try to hydrate. If this isn't a hydration pass there won't - // be any children to hydrate which is effectively the same thing as - // not hydrating. var child = mountChildFibers( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); workInProgress.child = child; var node = child; @@ -12581,24 +12911,19 @@ function updateHostRoot(current, workInProgress, renderExpirationTime) { // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - node.effectTag = (node.effectTag & ~Placement) | Hydrating; + node.flags = (node.flags & ~Placement) | Hydrating; node = node.sibling; } } else { // Otherwise reset hydration state in case we aborted and resumed another // root. - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); } return workInProgress.child; } -function updateHostComponent(current, workInProgress, renderExpirationTime) { +function updateHostComponent(current, workInProgress, renderLanes) { pushHostContext(workInProgress); var type = workInProgress.type; @@ -12609,30 +12934,11 @@ function updateHostComponent(current, workInProgress, renderExpirationTime) { if (prevProps !== null && shouldSetTextContent()) { // If we're switching from a direct text child to a normal child, or to // empty, we need to schedule the text content to be reset. - workInProgress.effectTag |= ContentReset; - } - - markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden. - - if ( - workInProgress.mode & ConcurrentMode && - renderExpirationTime !== Never && - shouldDeprioritizeSubtree() - ) { - { - markSpawnedWork(Never); - } // Schedule this fiber to re-render at offscreen priority. Then bailout. - - workInProgress.expirationTime = workInProgress.childExpirationTime = Never; - return null; + workInProgress.flags |= ContentReset; } - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + markRef(current, workInProgress); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -12646,8 +12952,8 @@ function mountLazyComponent( _current, workInProgress, elementType, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (_current !== null) { // A lazy component only mounts if it suspended inside a non- @@ -12657,18 +12963,17 @@ function mountLazyComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } - var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet. - // Cancel and resume right after we know the tag. - - cancelWorkTimer(workInProgress); - var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type. + var props = workInProgress.pendingProps; + var lazyComponent = elementType; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + var Component = init(payload); // Store the unwrapped component in the type. workInProgress.type = Component; var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component)); - startWorkTimer(workInProgress); var resolvedProps = resolveDefaultProps(Component, props); var child; @@ -12686,7 +12991,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderExpirationTime + renderLanes ); return child; } @@ -12703,7 +13008,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderExpirationTime + renderLanes ); return child; } @@ -12720,7 +13025,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderExpirationTime + renderLanes ); return child; } @@ -12746,8 +13051,8 @@ function mountLazyComponent( workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); return child; } @@ -12782,7 +13087,7 @@ function mountIncompleteClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { if (_current !== null) { // An incomplete component only mounts if it suspended inside a non- @@ -12792,7 +13097,7 @@ function mountIncompleteClassComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // Promote the fiber to a class and try rendering again. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` @@ -12808,22 +13113,17 @@ function mountIncompleteClassComponent( } else { hasContext = false; } - - prepareToReadContext(workInProgress, renderExpirationTime); - constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); + + prepareToReadContext(workInProgress, renderLanes); + constructClassInstance(workInProgress, Component, nextProps); + mountClassInstance(workInProgress, Component, nextProps, renderLanes); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderExpirationTime + renderLanes ); } @@ -12831,7 +13131,7 @@ function mountIndeterminateComponent( _current, workInProgress, Component, - renderExpirationTime + renderLanes ) { if (_current !== null) { // An indeterminate component only mounts if it suspended inside a non- @@ -12841,7 +13141,7 @@ function mountIndeterminateComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } var props = workInProgress.pendingProps; @@ -12852,7 +13152,7 @@ function mountIndeterminateComponent( context = getMaskedContext(workInProgress, unmaskedContext); } - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); var value; { @@ -12878,6 +13178,7 @@ function mountIndeterminateComponent( ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); } + setIsRendering(true); ReactCurrentOwner$1.current = workInProgress; value = renderWithHooks( null, @@ -12885,34 +13186,65 @@ function mountIndeterminateComponent( Component, props, context, - renderExpirationTime + renderLanes ); + setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; + + { + // Support for module components is deprecated and is removed behind a flag. + // Whether or not it would crash later, we want to show a good message in DEV first. + if ( + typeof value === "object" && + value !== null && + typeof value.render === "function" && + value.$$typeof === undefined + ) { + var _componentName = getComponentName(Component) || "Unknown"; + + if (!didWarnAboutModulePatternComponent[_componentName]) { + error( + "The <%s /> component appears to be a function component that returns a class instance. " + + "Change %s to a class that extends React.Component instead. " + + "If you can't use a class try assigning the prototype on the function as a workaround. " + + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + + "cannot be called with `new` by React.", + _componentName, + _componentName, + _componentName + ); + + didWarnAboutModulePatternComponent[_componentName] = true; + } + } + } if ( + // Run these checks in production only if the flag is off. + // Eventually we'll delete this branch altogether. typeof value === "object" && value !== null && typeof value.render === "function" && value.$$typeof === undefined ) { { - var _componentName = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutModulePatternComponent[_componentName]) { + if (!didWarnAboutModulePatternComponent[_componentName2]) { error( "The <%s /> component appears to be a function component that returns a class instance. " + "Change %s to a class that extends React.Component instead. " + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + "cannot be called with `new` by React.", - _componentName, - _componentName, - _componentName + _componentName2, + _componentName2, + _componentName2 ); - didWarnAboutModulePatternComponent[_componentName] = true; + didWarnAboutModulePatternComponent[_componentName2] = true; } } // Proceed under the assumption that this is a class instance @@ -12947,20 +13279,20 @@ function mountIndeterminateComponent( } adoptClassInstance(workInProgress, value); - mountClassInstance(workInProgress, Component, props, renderExpirationTime); + mountClassInstance(workInProgress, Component, props, renderLanes); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderExpirationTime + renderLanes ); } else { // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; - reconcileChildren(null, workInProgress, value, renderExpirationTime); + reconcileChildren(null, workInProgress, value, renderLanes); { validateFunctionComponentInDev(workInProgress, Component); @@ -13009,15 +13341,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { } if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName2 = getComponentName(Component) || "Unknown"; + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) { error( "%s: Function components do not support getDerivedStateFromProps.", - _componentName2 + _componentName3 ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true; } } @@ -13025,15 +13357,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName3 = getComponentName(Component) || "Unknown"; + var _componentName4 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) { error( "%s: Function components do not support contextType.", - _componentName3 + _componentName4 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true; } } } @@ -13041,41 +13373,68 @@ function validateFunctionComponentInDev(workInProgress, Component) { var SUSPENDED_MARKER = { dehydrated: null, - retryTime: NoWork + retryLane: NoLane }; -function shouldRemainOnFallback(suspenseContext, current, workInProgress) { - // If the context is telling us that we should show a fallback, and we're not - // already showing content, then we should show the fallback instead. - return ( - hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && - (current === null || current.memoizedState !== null) - ); +function mountSuspenseOffscreenState(renderLanes) { + return { + baseLanes: renderLanes + }; } -function updateSuspenseComponent( +function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { + return { + baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) + }; +} // TODO: Probably should inline this back + +function shouldRemainOnFallback( + suspenseContext, current, workInProgress, - renderExpirationTime + renderLanes ) { - var mode = workInProgress.mode; + // If we're already showing a fallback, there are cases where we need to + // remain on that fallback regardless of whether the content has resolved. + // For example, SuspenseList coordinates when nested content appears. + if (current !== null) { + var suspenseState = current.memoizedState; + + if (suspenseState === null) { + // Currently showing content. Don't hide it, even if ForceSuspenseFallack + // is true. More precise name might be "ForceRemainSuspenseFallback". + // Note: This is a factoring smell. Can't remain on a fallback if there's + // no fallback to remain on. + return false; + } + } // Not currently showing content. Consult the Suspense context. + + return hasSuspenseContext(suspenseContext, ForceSuspenseFallback); +} + +function getRemainingWorkInPrimaryTree(current, renderLanes) { + // TODO: Should not remove render lanes that were pinged during this render + return removeLanes(current.childLanes, renderLanes); +} + +function updateSuspenseComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. { if (shouldSuspend(workInProgress)) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } } var suspenseContext = suspenseStackCursor.current; - var nextDidTimeout = false; - var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; + var showFallback = false; + var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags; if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. - nextDidTimeout = true; - workInProgress.effectTag &= ~DidCapture; + showFallback = true; + workInProgress.flags &= ~DidCapture; } else { // Attempting the main content if (current === null || current.memoizedState !== null) { @@ -13097,290 +13456,411 @@ function updateSuspenseComponent( } suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); - pushSuspenseContext(workInProgress, suspenseContext); // This next part is a bit confusing. If the children timeout, we switch to - // showing the fallback children in place of the "primary" children. - // However, we don't want to delete the primary children because then their - // state will be lost (both the React state and the host state, e.g. - // uncontrolled form inputs). Instead we keep them mounted and hide them. - // Both the fallback children AND the primary children are rendered at the - // same time. Once the primary children are un-suspended, we can delete - // the fallback children — don't need to preserve their state. + pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense + // boundary's children. This involves some custom reconcilation logic. Two + // main reasons this is so complicated. // - // The two sets of children are siblings in the host environment, but - // semantically, for purposes of reconciliation, they are two separate sets. - // So we store them using two fragment fibers. + // First, Legacy Mode has different semantics for backwards compatibility. The + // primary tree will commit in an inconsistent state, so when we do the + // second pass to render the fallback, we do some exceedingly, uh, clever + // hacks to make that not totally break. Like transferring effects and + // deletions from hidden tree. In Concurrent Mode, it's much simpler, + // because we bailout on the primary tree completely and leave it in its old + // state, no effects. Same as what we do for Offscreen (except that + // Offscreen doesn't have the first render pass). // - // However, we want to avoid allocating extra fibers for every placeholder. - // They're only necessary when the children time out, because that's the - // only time when both sets are mounted. + // Second is hydration. During hydration, the Suspense fiber has a slightly + // different layout, where the child points to a dehydrated fragment, which + // contains the DOM rendered by the server. // - // So, the extra fragment fibers are only used if the children time out. - // Otherwise, we render the primary children directly. This requires some - // custom reconciliation logic to preserve the state of the primary - // children. It's essentially a very basic form of re-parenting. + // Third, even if you set all that aside, Suspense is like error boundaries in + // that we first we try to render one tree, and if that fails, we render again + // and switch to a different tree. Like a try/catch block. So we have to track + // which branch we're currently rendering. Ideally we would model this using + // a stack. if (current === null) { + // Initial mount // If we're currently hydrating, try to hydrate this boundary. // But only if this has a fallback. - if (nextProps.fallback !== undefined); // This is the initial mount. This branch is pretty simple because there's - // no previous state that needs to be preserved. + if (nextProps.fallback !== undefined); - if (nextDidTimeout) { - // Mount separate fragments for primary and fallback children. - var nextFallbackChildren = nextProps.fallback; - var primaryChildFragment = createFiberFromFragment( - null, - mode, - NoWork, - null - ); - primaryChildFragment.return = workInProgress; - - if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, we commit the effects from the - // partially completed, timed-out tree, too. - var progressedState = workInProgress.memoizedState; - var progressedPrimaryChild = - progressedState !== null - ? workInProgress.child.child - : workInProgress.child; - primaryChildFragment.child = progressedPrimaryChild; - var progressedChild = progressedPrimaryChild; - - while (progressedChild !== null) { - progressedChild.return = primaryChildFragment; - progressedChild = progressedChild.sibling; - } - } + var nextPrimaryChildren = nextProps.children; + var nextFallbackChildren = nextProps.fallback; - var fallbackChildFragment = createFiberFromFragment( + if (showFallback) { + var fallbackFragment = mountSuspenseFallbackChildren( + workInProgress, + nextPrimaryChildren, nextFallbackChildren, - mode, - renderExpirationTime, - null + renderLanes + ); + var primaryChildFragment = workInProgress.child; + primaryChildFragment.memoizedState = mountSuspenseOffscreenState( + renderLanes ); - fallbackChildFragment.return = workInProgress; - primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the - // fallback children. - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = primaryChildFragment; - return fallbackChildFragment; + return fallbackFragment; + } else if (typeof nextProps.unstable_expectedLoadTime === "number") { + // This is a CPU-bound tree. Skip this tree and show a placeholder to + // unblock the surrounding content. Then immediately retry after the + // initial commit. + var _fallbackFragment = mountSuspenseFallbackChildren( + workInProgress, + nextPrimaryChildren, + nextFallbackChildren, + renderLanes + ); + + var _primaryChildFragment = workInProgress.child; + _primaryChildFragment.memoizedState = mountSuspenseOffscreenState( + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to + // get it started back up to attempt the next item. While in terms of + // priority this work has the same priority as this current render, it's + // not part of the same transition once the transition has committed. If + // it's sync, we still want to yield so that it can be painted. + // Conceptually, this is really the same as pinging. We can use any + // RetryLane even if it's the one currently rendering since we're leaving + // it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + + return _fallbackFragment; } else { - // Mount the primary children without an intermediate fragment fiber. - var nextPrimaryChildren = nextProps.children; - workInProgress.memoizedState = null; - return (workInProgress.child = mountChildFibers( + return mountSuspensePrimaryChildren( workInProgress, - null, nextPrimaryChildren, - renderExpirationTime - )); + renderLanes + ); } } else { - // This is an update. This branch is more complicated because we need to - // ensure the state of the primary children is preserved. + // This is an update. + // If the current fiber has a SuspenseState, that means it's already showing + // a fallback. var prevState = current.memoizedState; if (prevState !== null) { - // wrapped in a fragment fiber. - - var currentPrimaryChildFragment = current.child; - var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; - - if (nextDidTimeout) { - // Still timed out. Reuse the current primary children by cloning - // its fragment. We're going to skip over these entirely. + if (showFallback) { var _nextFallbackChildren2 = nextProps.fallback; + var _nextPrimaryChildren2 = nextProps.children; - var _primaryChildFragment2 = createWorkInProgress( - currentPrimaryChildFragment, - currentPrimaryChildFragment.pendingProps + var _fallbackChildFragment = updateSuspenseFallbackChildren( + current, + workInProgress, + _nextPrimaryChildren2, + _nextFallbackChildren2, + renderLanes ); - _primaryChildFragment2.return = workInProgress; - - if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, we commit the effects from the - // partially completed, timed-out tree, too. - var _progressedState = workInProgress.memoizedState; - - var _progressedPrimaryChild = - _progressedState !== null - ? workInProgress.child.child - : workInProgress.child; - - if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { - _primaryChildFragment2.child = _progressedPrimaryChild; - var _progressedChild2 = _progressedPrimaryChild; - - while (_progressedChild2 !== null) { - _progressedChild2.return = _primaryChildFragment2; - _progressedChild2 = _progressedChild2.sibling; - } - } - } // Because primaryChildFragment is a new fiber that we're inserting as the - // parent of a new tree, we need to set its treeBaseDuration. - - if (workInProgress.mode & ProfileMode) { - // treeBaseDuration is the sum of all the child tree base durations. - var _treeBaseDuration = 0; - var _hiddenChild = _primaryChildFragment2.child; + var _primaryChildFragment3 = workInProgress.child; + var prevOffscreenState = current.child.memoizedState; + _primaryChildFragment3.memoizedState = + prevOffscreenState === null + ? mountSuspenseOffscreenState(renderLanes) + : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); + _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree( + current, + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return _fallbackChildFragment; + } else { + var _nextPrimaryChildren3 = nextProps.children; - while (_hiddenChild !== null) { - _treeBaseDuration += _hiddenChild.treeBaseDuration; - _hiddenChild = _hiddenChild.sibling; - } + var _primaryChildFragment4 = updateSuspensePrimaryChildren( + current, + workInProgress, + _nextPrimaryChildren3, + renderLanes + ); - _primaryChildFragment2.treeBaseDuration = _treeBaseDuration; - } // Clone the fallback child fragment, too. These we'll continue - // working on. + workInProgress.memoizedState = null; + return _primaryChildFragment4; + } + } else { + // The current tree is not already showing a fallback. + if (showFallback) { + // Timed out. + var _nextFallbackChildren3 = nextProps.fallback; + var _nextPrimaryChildren4 = nextProps.children; - var _fallbackChildFragment2 = createWorkInProgress( - currentFallbackChildFragment, - _nextFallbackChildren2 + var _fallbackChildFragment2 = updateSuspenseFallbackChildren( + current, + workInProgress, + _nextPrimaryChildren4, + _nextFallbackChildren3, + renderLanes ); - _fallbackChildFragment2.return = workInProgress; - _primaryChildFragment2.sibling = _fallbackChildFragment2; - _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the + var _primaryChildFragment5 = workInProgress.child; + var _prevOffscreenState = current.child.memoizedState; + _primaryChildFragment5.memoizedState = + _prevOffscreenState === null + ? mountSuspenseOffscreenState(renderLanes) + : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); + _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree( + current, + renderLanes + ); // Skip the primary children, and continue working on the // fallback children. workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = _primaryChildFragment2; return _fallbackChildFragment2; } else { - // No longer suspended. Switch back to showing the primary children, - // and remove the intermediate fragment fiber. - var _nextPrimaryChildren = nextProps.children; - var currentPrimaryChild = currentPrimaryChildFragment.child; - var primaryChild = reconcileChildFibers( + // Still haven't timed out. Continue rendering the children, like we + // normally do. + var _nextPrimaryChildren5 = nextProps.children; + + var _primaryChildFragment6 = updateSuspensePrimaryChildren( + current, workInProgress, - currentPrimaryChild, - _nextPrimaryChildren, - renderExpirationTime - ); // If this render doesn't suspend, we need to delete the fallback - // children. Wait until the complete phase, after we've confirmed the - // fallback is no longer needed. - // TODO: Would it be better to store the fallback fragment on - // the stateNode? - // Continue rendering the children, like we normally do. + _nextPrimaryChildren5, + renderLanes + ); workInProgress.memoizedState = null; - return (workInProgress.child = primaryChild); + return _primaryChildFragment6; } - } else { - // The current tree has not already timed out. That means the primary - // children are not wrapped in a fragment fiber. - var _currentPrimaryChild = current.child; + } + } +} - if (nextDidTimeout) { - // Timed out. Wrap the children in a fragment fiber to keep them - // separate from the fallback children. - var _nextFallbackChildren3 = nextProps.fallback; +function mountSuspensePrimaryChildren( + workInProgress, + primaryChildren, + renderLanes +) { + var mode = workInProgress.mode; + var primaryChildProps = { + mode: "visible", + children: primaryChildren + }; + var primaryChildFragment = createFiberFromOffscreen( + primaryChildProps, + mode, + renderLanes, + null + ); + primaryChildFragment.return = workInProgress; + workInProgress.child = primaryChildFragment; + return primaryChildFragment; +} - var _primaryChildFragment3 = createFiberFromFragment( - // It shouldn't matter what the pending props are because we aren't - // going to render this fragment. - null, - mode, - NoWork, - null - ); +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode; + var progressedPrimaryFragment = workInProgress.child; + var primaryChildProps = { + mode: "hidden", + children: primaryChildren + }; + var primaryChildFragment; + var fallbackChildFragment; + + if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) { + // In legacy mode, we commit the primary tree as if it successfully + // completed, even though it's in an inconsistent state. + primaryChildFragment = progressedPrimaryFragment; + primaryChildFragment.childLanes = NoLanes; + primaryChildFragment.pendingProps = primaryChildProps; + + if (workInProgress.mode & ProfileMode) { + // Reset the durations from the first pass so they aren't included in the + // final amounts. This seems counterintuitive, since we're intentionally + // not measuring part of the render phase, but this makes it match what we + // do in Concurrent Mode. + primaryChildFragment.actualDuration = 0; + primaryChildFragment.actualStartTime = -1; + primaryChildFragment.selfBaseDuration = 0; + primaryChildFragment.treeBaseDuration = 0; + } + + fallbackChildFragment = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + } else { + primaryChildFragment = createFiberFromOffscreen( + primaryChildProps, + mode, + NoLanes, + null + ); + fallbackChildFragment = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + } - _primaryChildFragment3.return = workInProgress; - _primaryChildFragment3.child = _currentPrimaryChild; + primaryChildFragment.return = workInProgress; + fallbackChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; +} - if (_currentPrimaryChild !== null) { - _currentPrimaryChild.return = _primaryChildFragment3; - } // Even though we're creating a new fiber, there are no new children, - // because we're reusing an already mounted tree. So we don't need to - // schedule a placement. - // primaryChildFragment.effectTag |= Placement; +function createWorkInProgressOffscreenFiber(current, offscreenProps) { + // The props argument to `createWorkInProgress` is `any` typed, so we use this + // wrapper function to constrain it. + return createWorkInProgress(current, offscreenProps); +} - if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, we commit the effects from the - // partially completed, timed-out tree, too. - var _progressedState2 = workInProgress.memoizedState; +function updateSuspensePrimaryChildren( + current, + workInProgress, + primaryChildren, + renderLanes +) { + var currentPrimaryChildFragment = current.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + var primaryChildFragment = createWorkInProgressOffscreenFiber( + currentPrimaryChildFragment, + { + mode: "visible", + children: primaryChildren + } + ); - var _progressedPrimaryChild2 = - _progressedState2 !== null - ? workInProgress.child.child - : workInProgress.child; + if ((workInProgress.mode & BlockingMode) === NoMode) { + primaryChildFragment.lanes = renderLanes; + } - _primaryChildFragment3.child = _progressedPrimaryChild2; - var _progressedChild3 = _progressedPrimaryChild2; + primaryChildFragment.return = workInProgress; + primaryChildFragment.sibling = null; - while (_progressedChild3 !== null) { - _progressedChild3.return = _primaryChildFragment3; - _progressedChild3 = _progressedChild3.sibling; - } - } // Because primaryChildFragment is a new fiber that we're inserting as the - // parent of a new tree, we need to set its treeBaseDuration. + if (currentFallbackChildFragment !== null) { + // Delete the fallback child fragment + currentFallbackChildFragment.nextEffect = null; + currentFallbackChildFragment.flags = Deletion; + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; + } - if (workInProgress.mode & ProfileMode) { - // treeBaseDuration is the sum of all the child tree base durations. - var _treeBaseDuration2 = 0; - var _hiddenChild2 = _primaryChildFragment3.child; + workInProgress.child = primaryChildFragment; + return primaryChildFragment; +} - while (_hiddenChild2 !== null) { - _treeBaseDuration2 += _hiddenChild2.treeBaseDuration; - _hiddenChild2 = _hiddenChild2.sibling; - } +function updateSuspenseFallbackChildren( + current, + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode; + var currentPrimaryChildFragment = current.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + var primaryChildProps = { + mode: "hidden", + children: primaryChildren + }; + var primaryChildFragment; - _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2; - } // Create a fragment from the fallback children, too. + if ( + // In legacy mode, we commit the primary tree as if it successfully + // completed, even though it's in an inconsistent state. + (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was + // already cloned. In legacy mode, the only case where this isn't true is + // when DevTools forces us to display a fallback; we skip the first render + // pass entirely and go straight to rendering the fallback. (In Concurrent + // Mode, SuspenseList can also trigger this scenario, but this is a legacy- + // only codepath.) + workInProgress.child !== currentPrimaryChildFragment + ) { + var progressedPrimaryFragment = workInProgress.child; + primaryChildFragment = progressedPrimaryFragment; + primaryChildFragment.childLanes = NoLanes; + primaryChildFragment.pendingProps = primaryChildProps; + + if (workInProgress.mode & ProfileMode) { + // Reset the durations from the first pass so they aren't included in the + // final amounts. This seems counterintuitive, since we're intentionally + // not measuring part of the render phase, but this makes it match what we + // do in Concurrent Mode. + primaryChildFragment.actualDuration = 0; + primaryChildFragment.actualStartTime = -1; + primaryChildFragment.selfBaseDuration = + currentPrimaryChildFragment.selfBaseDuration; + primaryChildFragment.treeBaseDuration = + currentPrimaryChildFragment.treeBaseDuration; + } // The fallback fiber was added as a deletion effect during the first pass. + // However, since we're going to remain on the fallback, we no longer want + // to delete it. So we need to remove it from the list. Deletions are stored + // on the same list as effects. We want to keep the effects from the primary + // tree. So we copy the primary child fragment's effect list, which does not + // include the fallback deletion effect. + + var progressedLastEffect = primaryChildFragment.lastEffect; + + if (progressedLastEffect !== null) { + workInProgress.firstEffect = primaryChildFragment.firstEffect; + workInProgress.lastEffect = progressedLastEffect; + progressedLastEffect.nextEffect = null; + } else { + // TODO: Reset this somewhere else? Lol legacy mode is so weird. + workInProgress.firstEffect = workInProgress.lastEffect = null; + } + } else { + primaryChildFragment = createWorkInProgressOffscreenFiber( + currentPrimaryChildFragment, + primaryChildProps + ); + } - var _fallbackChildFragment3 = createFiberFromFragment( - _nextFallbackChildren3, - mode, - renderExpirationTime, - null - ); + var fallbackChildFragment; - _fallbackChildFragment3.return = workInProgress; - _primaryChildFragment3.sibling = _fallbackChildFragment3; - _fallbackChildFragment3.effectTag |= Placement; - _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the - // fallback children. + if (currentFallbackChildFragment !== null) { + fallbackChildFragment = createWorkInProgress( + currentFallbackChildFragment, + fallbackChildren + ); + } else { + fallbackChildFragment = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); // Needs a placement effect because the parent (the Suspense boundary) already + // mounted but this is a new fiber. - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = _primaryChildFragment3; - return _fallbackChildFragment3; - } else { - // Still haven't timed out. Continue rendering the children, like we - // normally do. - workInProgress.memoizedState = null; - var _nextPrimaryChildren2 = nextProps.children; - return (workInProgress.child = reconcileChildFibers( - workInProgress, - _currentPrimaryChild, - _nextPrimaryChildren2, - renderExpirationTime - )); - } - } + fallbackChildFragment.flags |= Placement; } -} -function scheduleWorkOnFiber(fiber, renderExpirationTime) { - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } + fallbackChildFragment.return = workInProgress; + primaryChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; +} +function scheduleWorkOnFiber(fiber, renderLanes) { + fiber.lanes = mergeLanes(fiber.lanes, renderLanes); var alternate = fiber.alternate; - if (alternate !== null && alternate.expirationTime < renderExpirationTime) { - alternate.expirationTime = renderExpirationTime; + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, renderLanes); } - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + scheduleWorkOnParentPath(fiber.return, renderLanes); } function propagateSuspenseContextChange( workInProgress, firstChild, - renderExpirationTime + renderLanes ) { // Mark any Suspense boundaries with fallbacks as having work to do. // If they were previously forced into fallbacks, they may now be able @@ -13392,7 +13872,7 @@ function propagateSuspenseContextChange( var state = node.memoizedState; if (state !== null) { - scheduleWorkOnFiber(node, renderExpirationTime); + scheduleWorkOnFiber(node, renderLanes); } } else if (node.tag === SuspenseListComponent) { // If the tail is hidden there might not be an Suspense boundaries @@ -13400,7 +13880,7 @@ function propagateSuspenseContextChange( // list itself. // We don't have to traverse to the children of the list since // the list will propagate the change when it rerenders. - scheduleWorkOnFiber(node, renderExpirationTime); + scheduleWorkOnFiber(node, renderLanes); } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -13619,7 +14099,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }; @@ -13630,7 +14109,6 @@ function initSuspenseListRenderState( renderState.renderingStartTime = 0; renderState.last = lastContentRow; renderState.tail = tail; - renderState.tailExpiration = 0; renderState.tailMode = tailMode; renderState.lastEffect = lastEffectBeforeRendering; } @@ -13642,11 +14120,7 @@ function initSuspenseListRenderState( // in fallback state. Then we render each row in the tail one-by-one. // That happens in the completeWork phase without going back to beginWork. -function updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime -) { +function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var revealOrder = nextProps.revealOrder; var tailMode = nextProps.tail; @@ -13654,7 +14128,7 @@ function updateSuspenseListComponent( validateRevealOrder(revealOrder); validateTailOptions(tailMode, revealOrder); validateSuspenseListChildren(newChildren, revealOrder); - reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); + reconcileChildren(current, workInProgress, newChildren, renderLanes); var suspenseContext = suspenseStackCursor.current; var shouldForceFallback = hasSuspenseContext( suspenseContext, @@ -13666,10 +14140,10 @@ function updateSuspenseListComponent( suspenseContext, ForceSuspenseFallback ); - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } else { var didSuspendBefore = - current !== null && (current.effectTag & DidCapture) !== NoEffect; + current !== null && (current.flags & DidCapture) !== NoFlags; if (didSuspendBefore) { // If we previously forced a fallback, we need to schedule work @@ -13678,7 +14152,7 @@ function updateSuspenseListComponent( propagateSuspenseContextChange( workInProgress, workInProgress.child, - renderExpirationTime + renderLanes ); } @@ -13688,7 +14162,7 @@ function updateSuspenseListComponent( pushSuspenseContext(workInProgress, suspenseContext); if ((workInProgress.mode & BlockingMode) === NoMode) { - // Outside of blocking mode, SuspenseList doesn't work so we just + // In legacy mode, SuspenseList doesn't work so we just // use make it a noop by treating it as the default revealOrder. workInProgress.memoizedState = null; } else { @@ -13778,7 +14252,7 @@ function updateSuspenseListComponent( return workInProgress.child; } -function updatePortalComponent(current, workInProgress, renderExpirationTime) { +function updatePortalComponent(current, workInProgress, renderLanes) { pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); var nextChildren = workInProgress.pendingProps; @@ -13792,21 +14266,18 @@ function updatePortalComponent(current, workInProgress, renderExpirationTime) { workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ); } else { - reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); } return workInProgress.child; } -function updateContextProvider(current, workInProgress, renderExpirationTime) { +var hasWarnedAboutUsingNoValuePropOnContextProvider = false; + +function updateContextProvider(current, workInProgress, renderLanes) { var providerType = workInProgress.type; var context = providerType._context; var newProps = workInProgress.pendingProps; @@ -13814,6 +14285,16 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) { var newValue = newProps.value; { + if (!("value" in newProps)) { + if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { + hasWarnedAboutUsingNoValuePropOnContextProvider = true; + + error( + "The `value` prop is required for the ``. Did you misspell it or forget to pass it?" + ); + } + } + var providerPropTypes = workInProgress.type.propTypes; if (providerPropTypes) { @@ -13833,29 +14314,24 @@ function updateContextProvider(current, workInProgress, renderExpirationTime) { return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); } } else { // The context value changed. Search for matching consumers and schedule // them to update. - propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime - ); + propagateContextChange(workInProgress, context, changedBits, renderLanes); } } var newChildren = newProps.children; - reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); + reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } var hasWarnedAboutUsingContextAsConsumer = false; -function updateContextConsumer(current, workInProgress, renderExpirationTime) { +function updateContextConsumer(current, workInProgress, renderLanes) { var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In // DEV mode, we create a separate object for Context.Consumer that acts // like a proxy to Context. This proxy object adds unnecessary code in PROD @@ -13898,7 +14374,7 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) { } } - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); var newValue = readContext(context, newProps.unstable_observedBits); var newChildren; @@ -13909,8 +14385,8 @@ function updateContextConsumer(current, workInProgress, renderExpirationTime) { setIsRendering(false); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } @@ -13918,13 +14394,7 @@ function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } -function bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime -) { - cancelWorkTimer(workInProgress); - +function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { if (current !== null) { // Reuse previous dependencies workInProgress.dependencies = current.dependencies; @@ -13935,15 +14405,9 @@ function bailoutOnAlreadyFinishedWork( stopProfilerTimerIfRunning(); } - var updateExpirationTime = workInProgress.expirationTime; - - if (updateExpirationTime !== NoWork) { - markUnprocessedUpdateTime(updateExpirationTime); - } // Check if the children have any pending work. + markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work. - var childExpirationTime = workInProgress.childExpirationTime; - - if (childExpirationTime < renderExpirationTime) { + if (!includesSomeLane(renderLanes, workInProgress.childLanes)) { // The children don't have any work either. We can skip them. // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. @@ -14004,15 +14468,15 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } current.nextEffect = null; - current.effectTag = Deletion; - newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber. + current.flags = Deletion; + newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; } } -function beginWork(current, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; +function beginWork(current, workInProgress, renderLanes) { + var updateLanes = workInProgress.lanes; { if (workInProgress._debugNeedsRemount && current !== null) { @@ -14026,7 +14490,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, - workInProgress.expirationTime + workInProgress.lanes ) ); } @@ -14044,7 +14508,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { // If props or context changed, mark the fiber as having performed work. // This may be unset if the props are determined to be equal later (memo). didReceiveUpdate = true; - } else if (updateExpirationTime < renderExpirationTime) { + } else if (!includesSomeLane(renderLanes, updateLanes)) { didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering // the begin phase. There's still some bookkeeping we that needs to be done // in this optimized path, mostly pushing stuff onto the stack. @@ -14056,20 +14520,6 @@ function beginWork(current, workInProgress, renderExpirationTime) { case HostComponent: pushHostContext(workInProgress); - - if ( - workInProgress.mode & ConcurrentMode && - renderExpirationTime !== Never && - shouldDeprioritizeSubtree(workInProgress.type) - ) { - { - markSpawnedWork(Never); - } // Schedule this fiber to re-render at offscreen priority. Then bailout. - - workInProgress.expirationTime = workInProgress.childExpirationTime = Never; - return null; - } - break; case ClassComponent: { @@ -14098,11 +14548,13 @@ function beginWork(current, workInProgress, renderExpirationTime) { case Profiler: { // Profiler should only call onRender when one of its descendants actually rendered. - var hasChildWork = - workInProgress.childExpirationTime >= renderExpirationTime; + var hasChildWork = includesSomeLane( + renderLanes, + workInProgress.childLanes + ); if (hasChildWork) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -14122,21 +14574,19 @@ function beginWork(current, workInProgress, renderExpirationTime) { // child fragment. var primaryChildFragment = workInProgress.child; - var primaryChildExpirationTime = - primaryChildFragment.childExpirationTime; + var primaryChildLanes = primaryChildFragment.childLanes; - if ( - primaryChildExpirationTime !== NoWork && - primaryChildExpirationTime >= renderExpirationTime - ) { + if (includesSomeLane(renderLanes, primaryChildLanes)) { // The primary children have pending work. Use the normal path // to attempt to render the primary children again. return updateSuspenseComponent( current, workInProgress, - renderExpirationTime + renderLanes ); } else { + // The primary child fragment does not have pending work marked + // on it pushSuspenseContext( workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current) @@ -14146,7 +14596,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { var child = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); if (child !== null) { @@ -14168,10 +14618,12 @@ function beginWork(current, workInProgress, renderExpirationTime) { } case SuspenseListComponent: { - var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; + var didSuspendBefore = (current.flags & DidCapture) !== NoFlags; - var _hasChildWork = - workInProgress.childExpirationTime >= renderExpirationTime; + var _hasChildWork = includesSomeLane( + renderLanes, + workInProgress.childLanes + ); if (didSuspendBefore) { if (_hasChildWork) { @@ -14183,13 +14635,13 @@ function beginWork(current, workInProgress, renderExpirationTime) { return updateSuspenseListComponent( current, workInProgress, - renderExpirationTime + renderLanes ); } // If none of the children had any work, that means that none of // them got retried so they'll still be blocked in the same way // as before. We can fast bail out. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } // If nothing suspended before and we're rendering the same children, // then the tail doesn't matter. Anything new that suspends will work // in the "together" mode, so we can continue from the state we had. @@ -14201,6 +14653,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { // update in the past but didn't complete it. renderState.rendering = null; renderState.tail = null; + renderState.lastEffect = null; } pushSuspenseContext(workInProgress, suspenseStackCursor.current); @@ -14214,19 +14667,35 @@ function beginWork(current, workInProgress, renderExpirationTime) { return null; } } + + case OffscreenComponent: + case LegacyHiddenComponent: { + // Need to check if the tree still needs to be deferred. This is + // almost identical to the logic used in the normal update path, + // so we'll just enter that. The only difference is we'll bail out + // at the next level instead of this one, because the child props + // have not changed. Which is fine. + // TODO: Probably should refactor `beginWork` to split the bailout + // path from the normal path. I'm tempted to do a labeled break here + // but I won't :) + workInProgress.lanes = NoLanes; + return updateOffscreenComponent(current, workInProgress, renderLanes); + } } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else { - // An update was scheduled on this fiber, but there are no new props - // nor legacy context. Set this to false. If an update queue or context - // consumer produces a changed value, it will set this to true. Otherwise, - // the component will assume the children have not changed and bail out. - didReceiveUpdate = false; + if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { + // This is a special case that only exists for legacy mode. + // See https://github.com/facebook/react/pull/19216. + didReceiveUpdate = true; + } else { + // An update was scheduled on this fiber, but there are no new props + // nor legacy context. Set this to false. If an update queue or context + // consumer produces a changed value, it will set this to true. Otherwise, + // the component will assume the children have not changed and bail out. + didReceiveUpdate = false; + } } } else { didReceiveUpdate = false; @@ -14236,7 +14705,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { // sometimes bails out later in the begin phase. This indicates that we should // move this assignment out of the common path and into each branch. - workInProgress.expirationTime = NoWork; + workInProgress.lanes = NoLanes; switch (workInProgress.tag) { case IndeterminateComponent: { @@ -14244,7 +14713,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.type, - renderExpirationTime + renderLanes ); } @@ -14254,8 +14723,8 @@ function beginWork(current, workInProgress, renderExpirationTime) { current, workInProgress, elementType, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -14271,7 +14740,7 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _Component, resolvedProps, - renderExpirationTime + renderLanes ); } @@ -14289,32 +14758,24 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _Component2, _resolvedProps, - renderExpirationTime + renderLanes ); } case HostRoot: - return updateHostRoot(current, workInProgress, renderExpirationTime); + return updateHostRoot(current, workInProgress, renderLanes); case HostComponent: - return updateHostComponent(current, workInProgress, renderExpirationTime); + return updateHostComponent(current, workInProgress, renderLanes); case HostText: return updateHostText(); case SuspenseComponent: - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseComponent(current, workInProgress, renderLanes); case HostPortal: - return updatePortalComponent( - current, - workInProgress, - renderExpirationTime - ); + return updatePortalComponent(current, workInProgress, renderLanes); case ForwardRef: { var type = workInProgress.type; @@ -14330,32 +14791,24 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, type, _resolvedProps2, - renderExpirationTime + renderLanes ); } case Fragment: - return updateFragment(current, workInProgress, renderExpirationTime); + return updateFragment(current, workInProgress, renderLanes); case Mode: - return updateMode(current, workInProgress, renderExpirationTime); + return updateMode(current, workInProgress, renderLanes); case Profiler: - return updateProfiler(current, workInProgress, renderExpirationTime); + return updateProfiler(current, workInProgress, renderLanes); case ContextProvider: - return updateContextProvider( - current, - workInProgress, - renderExpirationTime - ); + return updateContextProvider(current, workInProgress, renderLanes); case ContextConsumer: - return updateContextConsumer( - current, - workInProgress, - renderExpirationTime - ); + return updateContextConsumer(current, workInProgress, renderLanes); case MemoComponent: { var _type2 = workInProgress.type; @@ -14384,8 +14837,8 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _type2, _resolvedProps3, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -14395,8 +14848,8 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); } @@ -14414,16 +14867,32 @@ function beginWork(current, workInProgress, renderExpirationTime) { workInProgress, _Component3, _resolvedProps4, - renderExpirationTime + renderLanes ); } - case SuspenseListComponent: { - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); + case SuspenseListComponent: { + return updateSuspenseListComponent(current, workInProgress, renderLanes); + } + + case FundamentalComponent: { + break; + } + + case ScopeComponent: { + break; + } + + case Block: { + break; + } + + case OffscreenComponent: { + return updateOffscreenComponent(current, workInProgress, renderLanes); + } + + case LegacyHiddenComponent: { + return updateLegacyHiddenComponent(current, workInProgress, renderLanes); } } @@ -14439,11 +14908,11 @@ function beginWork(current, workInProgress, renderExpirationTime) { function markUpdate(workInProgress) { // Tag the fiber with an update effect. This turns a Placement into // a PlacementAndUpdate. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } function markRef$1(workInProgress) { - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } var appendAllChildren; @@ -14607,7 +15076,7 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { } } -function completeWork(current, workInProgress, renderExpirationTime) { +function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -14636,6 +15105,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); + resetWorkInProgressVersions(); var fiberRoot = workInProgress.stateNode; if (fiberRoot.pendingContext) { @@ -14652,6 +15122,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); + } else if (!fiberRoot.hydrate) { + // Schedule an effect to clear this container at the start of the next commit. + // This handles the case of React rendering into a container with previous children. + // It's also safe to do for updates too, because current.child would only be null + // if the previous render was null (so the the container would already be empty). + workInProgress.flags |= Snapshot; } } @@ -14710,9 +15186,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { currentHostContext, workInProgress ); - appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners - - workInProgress.stateNode = instance; + appendAllChildren(instance, workInProgress, false, false); + workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). // Make sure such renderers get scheduled for later work. @@ -14774,9 +15249,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { popSuspenseContext(workInProgress); var nextState = workInProgress.memoizedState; - if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + if ((workInProgress.flags & DidCapture) !== NoFlags) { // Something suspended. Re-render with the fallback children. - workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list. + workInProgress.lanes = renderLanes; // Do not reset the effect list. + + if ((workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } return workInProgress; } @@ -14789,29 +15268,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { } else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; - - if (!nextDidTimeout && prevState !== null) { - // We just switched from the fallback to the normal children. - // Delete the fallback. - // TODO: Would it be better to store the fallback fragment on - // the stateNode during the begin phase? - var currentFallbackChild = current.child.sibling; - - if (currentFallbackChild !== null) { - // Deletions go at the beginning of the return fiber's effect list - var first = workInProgress.firstEffect; - - if (first !== null) { - workInProgress.firstEffect = currentFallbackChild; - currentFallbackChild.nextEffect = first; - } else { - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; - currentFallbackChild.nextEffect = null; - } - - currentFallbackChild.effectTag = Deletion; - } - } } if (nextDidTimeout && !prevDidTimeout) { @@ -14858,7 +15314,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // primary children. In mutation mode, we also need the flag to // *unhide* children that were previously hidden, so check if this // is currently timed out, too. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -14868,6 +15324,11 @@ function completeWork(current, workInProgress, renderExpirationTime) { case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); + + if (current === null) { + preparePortalMount(workInProgress.stateNode.containerInfo); + } + return null; case ContextProvider: @@ -14897,8 +15358,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } - var didSuspendAlready = - (workInProgress.effectTag & DidCapture) !== NoEffect; + var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags; var renderedTail = renderState.rendering; if (renderedTail === null) { @@ -14915,7 +15375,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // findFirstSuspended. var cannotBeSuspended = renderHasNotSuspendedYet() && - (current === null || (current.effectTag & DidCapture) === NoEffect); + (current === null || (current.flags & DidCapture) === NoFlags); if (!cannotBeSuspended) { var row = workInProgress.child; @@ -14925,7 +15385,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (suspended !== null) { didSuspendAlready = true; - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as // part of the second pass. In that case nothing will subscribe to // its thennables. Instead, we'll transfer its thennables to the @@ -14943,7 +15403,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks // to stay in place. // Reset the effect list before doing the second pass since that's now invalid. @@ -14954,7 +15414,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. - resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately + resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately // rerender the children. pushSuspenseContext( @@ -14970,6 +15430,28 @@ function completeWork(current, workInProgress, renderExpirationTime) { row = row.sibling; } } + + if (renderState.tail !== null && now() > getRenderTargetTime()) { + // We have already passed our CPU deadline but we still have rows + // left in the tail. We'll just give up further attempts to render + // the main content and only render fallbacks. + workInProgress.flags |= DidCapture; + didSuspendAlready = true; + cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + } } else { cutOffTailIfNeeded(renderState, false); } // Next we're going to render the tail. @@ -14979,7 +15461,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { var _suspended = findFirstSuspended(renderedTail); if (_suspended !== null) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't // get lost if this row ends up dropped during a second pass. @@ -14987,7 +15469,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (_newThennables !== null) { workInProgress.updateQueue = _newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } cutOffTailIfNeeded(renderState, true); // This might have been modified. @@ -14995,7 +15477,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { if ( renderState.tail === null && renderState.tailMode === "hidden" && - !renderedTail.alternate + !renderedTail.alternate && + !getIsHydrating() // We don't cut it if we're hydrating. ) { // We need to delete the row we just rendered. // Reset the effect list to what it was before we rendered this @@ -15010,28 +15493,31 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } } else if ( - // The time it took to render last row is greater than time until - // the expiration. + // The time it took to render last row is greater than the remaining + // time we have to render. So rendering one more row would likely + // exceed it. now() * 2 - renderState.renderingStartTime > - renderState.tailExpiration && - renderExpirationTime > Never + getRenderTargetTime() && + renderLanes !== OffscreenLane ) { // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. // The assumption is that this is usually faster. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this - // to get it started back up to attempt the next item. If we can show - // them, then they really have the same priority as this render. - // So we'll pick it back up the very next render pass once we've had - // an opportunity to yield for paint. + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. - var nextPriority = renderExpirationTime - 1; - workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority; + workInProgress.lanes = SomeRetryLane; { - markSpawnedWork(nextPriority); + markSpawnedWork(SomeRetryLane); } } } @@ -15059,18 +15545,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (renderState.tail !== null) { // We still have tail rows to render. - if (renderState.tailExpiration === 0) { - // Heuristic for how long we're willing to spend rendering rows - // until we just give up and show what we have so far. - var TAIL_EXPIRATION_TIMEOUT_MS = 500; - renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this - // is a per component value. It should really be since the start - // of the total render or last commit. Consider using something like - // globalMostRecentFallbackTime. That doesn't account for being - // suspended for part of the time or when it's a new render. - // It should probably use a global start time value instead. - } // Pop a row. - + // Pop a row. var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; @@ -15098,6 +15573,38 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } + + case FundamentalComponent: { + break; + } + + case ScopeComponent: { + break; + } + + case Block: + break; + + case OffscreenComponent: + case LegacyHiddenComponent: { + popRenderLanes(workInProgress); + + if (current !== null) { + var _nextState = workInProgress.memoizedState; + var _prevState = current.memoizedState; + var prevIsHidden = _prevState !== null; + var nextIsHidden = _nextState !== null; + + if ( + prevIsHidden !== nextIsHidden && + newProps.mode !== "unstable-defer-without-hiding" + ) { + workInProgress.flags |= Update; + } + } + + return null; + } } { @@ -15109,7 +15616,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } -function unwindWork(workInProgress, renderExpirationTime) { +function unwindWork(workInProgress, renderLanes) { switch (workInProgress.tag) { case ClassComponent: { var Component = workInProgress.type; @@ -15118,10 +15625,15 @@ function unwindWork(workInProgress, renderExpirationTime) { popContext(workInProgress); } - var effectTag = workInProgress.effectTag; + var flags = workInProgress.flags; + + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; + + if ((workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } @@ -15131,15 +15643,16 @@ function unwindWork(workInProgress, renderExpirationTime) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag = workInProgress.effectTag; + resetWorkInProgressVersions(); + var _flags = workInProgress.flags; - if (!((_effectTag & DidCapture) === NoEffect)) { + if (!((_flags & DidCapture) === NoFlags)) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); } - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; return workInProgress; } @@ -15152,10 +15665,14 @@ function unwindWork(workInProgress, renderExpirationTime) { case SuspenseComponent: { popSuspenseContext(workInProgress); - var _effectTag2 = workInProgress.effectTag; + var _flags2 = workInProgress.flags; - if (_effectTag2 & ShouldCapture) { - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. + if (_flags2 & ShouldCapture) { + workInProgress.flags = (_flags2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. + + if ((workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } return workInProgress; } @@ -15174,212 +15691,522 @@ function unwindWork(workInProgress, renderExpirationTime) { popHostContainer(workInProgress); return null; - case ContextProvider: - popProvider(workInProgress); - return null; + case ContextProvider: + popProvider(workInProgress); + return null; + + case OffscreenComponent: + case LegacyHiddenComponent: + popRenderLanes(workInProgress); + return null; + + default: + return null; + } +} + +function unwindInterruptedWork(interruptedWork) { + switch (interruptedWork.tag) { + case ClassComponent: { + var childContextTypes = interruptedWork.type.childContextTypes; + + if (childContextTypes !== null && childContextTypes !== undefined) { + popContext(interruptedWork); + } + + break; + } + + case HostRoot: { + popHostContainer(interruptedWork); + popTopLevelContextObject(interruptedWork); + resetWorkInProgressVersions(); + break; + } + + case HostComponent: { + popHostContext(interruptedWork); + break; + } + + case HostPortal: + popHostContainer(interruptedWork); + break; + + case SuspenseComponent: + popSuspenseContext(interruptedWork); + break; + + case SuspenseListComponent: + popSuspenseContext(interruptedWork); + break; + + case ContextProvider: + popProvider(interruptedWork); + break; + + case OffscreenComponent: + case LegacyHiddenComponent: + popRenderLanes(interruptedWork); + break; + } +} + +function createCapturedValue(value, source) { + // If the value is an error, call this function immediately after it is thrown + // so the stack is accurate. + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} + +if ( + !( + typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === + "function" + ) +) { + throw Error( + "Expected ReactFiberErrorDialog.showErrorDialog to be a function." + ); +} + +function showErrorDialog(boundary, errorInfo) { + var capturedError = { + componentStack: errorInfo.stack !== null ? errorInfo.stack : "", + error: errorInfo.value, + errorBoundary: + boundary !== null && boundary.tag === ClassComponent + ? boundary.stateNode + : null + }; + return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( + capturedError + ); +} + +function logCapturedError(boundary, errorInfo) { + try { + var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + var error = errorInfo.value; + + if (true) { + var source = errorInfo.source; + var stack = errorInfo.stack; + var componentStack = stack !== null ? stack : ""; // Browsers support silencing uncaught errors by calling + // `preventDefault()` in window `error` handler. + // We record this information as an expando on the error. + + if (error != null && error._suppressLogging) { + if (boundary.tag === ClassComponent) { + // The error is recoverable and was silenced. + // Ignore it and don't print the stack addendum. + // This is handy for testing error boundaries without noise. + return; + } // The error is fatal. Since the silencing might have + // been accidental, we'll surface it anyway. + // However, the browser would have silenced the original error + // so we'll print it first, and then print the stack addendum. + + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: + // https://github.com/facebook/react/pull/13384 + } + + var componentName = source ? getComponentName(source.type) : null; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; + var errorBoundaryMessage; + var errorBoundaryName = getComponentName(boundary.type); + + if (errorBoundaryName) { + errorBoundaryMessage = + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + errorBoundaryName + "."); + } else { + errorBoundaryMessage = + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries."; + } + + var combinedMessage = + componentNameMessage + + "\n" + + componentStack + + "\n\n" + + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. + // We don't include the original error message and JS stack because the browser + // has already printed it. Even if the application swallows the error, it is still + // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. + + console["error"](combinedMessage); // Don't transform to our wrapper + } else { + // In production, we print the error directly. + // This will include the message, the JS stack, and anything the browser wants to show. + // We pass the error object instead of custom message so that the browser displays the error natively. + console["error"](error); // Don't transform to our wrapper + } + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function() { + throw e; + }); + } +} + +var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; + +function createRootErrorUpdate(fiber, errorInfo, lane) { + var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. + + update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property + // being called "element". + + update.payload = { + element: null + }; + var error = errorInfo.value; + + update.callback = function() { + onUncaughtError(error); + logCapturedError(fiber, errorInfo); + }; + + return update; +} + +function createClassErrorUpdate(fiber, errorInfo, lane) { + var update = createUpdate(NoTimestamp, lane); + update.tag = CaptureUpdate; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + + if (typeof getDerivedStateFromError === "function") { + var error$1 = errorInfo.value; + + update.payload = function() { + logCapturedError(fiber, errorInfo); + return getDerivedStateFromError(error$1); + }; + } + + var inst = fiber.stateNode; + + if (inst !== null && typeof inst.componentDidCatch === "function") { + update.callback = function callback() { + { + markFailedErrorBoundaryForHotReloading(fiber); + } + + if (typeof getDerivedStateFromError !== "function") { + // To preserve the preexisting retry behavior of error boundaries, + // we keep track of which ones already failed during this batch. + // This gets reset before we yield back to the browser. + // TODO: Warn in strict mode if getDerivedStateFromError is + // not defined. + markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined + + logCapturedError(fiber, errorInfo); + } + + var error$1 = errorInfo.value; + var stack = errorInfo.stack; + this.componentDidCatch(error$1, { + componentStack: stack !== null ? stack : "" + }); + + { + if (typeof getDerivedStateFromError !== "function") { + // If componentDidCatch is the only error boundary method defined, + // then it needs to call setState to recover from errors. + // If no state update is scheduled then the boundary will swallow the error. + if (!includesSomeLane(fiber.lanes, SyncLane)) { + error( + "%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" + ); + } + } + } + }; + } else { + update.callback = function() { + markFailedErrorBoundaryForHotReloading(fiber); + }; + } + + return update; +} + +function attachPingListener(root, wakeable, lanes) { + // Attach a listener to the promise to "ping" the root and retry. But only if + // one does not already exist for the lanes we're currently rendering (which + // acts like a "thread ID" here). + var pingCache = root.pingCache; + var threadIDs; + + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap$1(); + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else { + threadIDs = pingCache.get(wakeable); + + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } + } - default: - return null; + if (!threadIDs.has(lanes)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(lanes); + var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); + wakeable.then(ping, ping); } } -function unwindInterruptedWork(interruptedWork) { - switch (interruptedWork.tag) { - case ClassComponent: { - var childContextTypes = interruptedWork.type.childContextTypes; +function throwException( + root, + returnFiber, + sourceFiber, + value, + rootRenderLanes +) { + // The source fiber did not complete. + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. - if (childContextTypes !== null && childContextTypes !== undefined) { - popContext(interruptedWork); - } + sourceFiber.firstEffect = sourceFiber.lastEffect = null; - break; - } + if ( + value !== null && + typeof value === "object" && + typeof value.then === "function" + ) { + // This is a wakeable. + var wakeable = value; - case HostRoot: { - popHostContainer(interruptedWork); - popTopLevelContextObject(interruptedWork); - break; - } + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; - case HostComponent: { - popHostContext(interruptedWork); - break; + if (currentSource) { + sourceFiber.updateQueue = currentSource.updateQueue; + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.lanes = currentSource.lanes; + } else { + sourceFiber.updateQueue = null; + sourceFiber.memoizedState = null; + } } - case HostPortal: - popHostContainer(interruptedWork); - break; - - case SuspenseComponent: - popSuspenseContext(interruptedWork); - break; + var hasInvisibleParentBoundary = hasSuspenseContext( + suspenseStackCursor.current, + InvisibleParentSuspenseContext + ); // Schedule the nearest Suspense to re-render the timed out view. - case SuspenseListComponent: - popSuspenseContext(interruptedWork); - break; + var _workInProgress = returnFiber; - case ContextProvider: - popProvider(interruptedWork); - break; - } -} + do { + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) + ) { + // Found the nearest boundary. + // Stash the promise on the boundary fiber. If the boundary times out, we'll + // attach another listener to flip the boundary back to its normal state. + var wakeables = _workInProgress.updateQueue; -function createCapturedValue(value, source) { - // If the value is an error, call this function immediately after it is thrown - // so the stack is accurate. - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; -} + if (wakeables === null) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + _workInProgress.updateQueue = updateQueue; + } else { + wakeables.add(wakeable); + } // If the boundary is outside of blocking mode, we should *not* + // suspend the commit. Pretend as if the suspended component rendered + // null and keep rendering. In the commit phase, we'll schedule a + // subsequent synchronous update to re-render the Suspense. + // + // Note: It doesn't matter whether the component that suspended was + // inside a blocking mode tree. If the Suspense is outside of it, we + // should *not* suspend the commit. -// Module provided by RN: + if ((_workInProgress.mode & BlockingMode) === NoMode) { + _workInProgress.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. + // But we shouldn't call any lifecycle methods or callbacks. Remove + // all lifecycle effect tags. -if ( - !( - typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === - "function" - ) -) { - throw Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); -} + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); -function showErrorDialog(capturedError) { - return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( - capturedError - ); -} + if (sourceFiber.tag === ClassComponent) { + var currentSourceFiber = sourceFiber.alternate; -function logCapturedError(capturedError) { - var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + if (currentSourceFiber === null) { + // This is a new mount. Change the tag so it's not mistaken for a + // completed class component. For example, we should not call + // componentWillUnmount if it is deleted. + sourceFiber.tag = IncompleteClassComponent; + } else { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force update to + // prevent a bail out. + var update = createUpdate(NoTimestamp, SyncLane); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } // The source fiber did not complete. Mark it with Sync priority to + // indicate that it still has pending work. - if (logError === false) { - return; - } + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. - var error = capturedError.error; + return; + } // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + // + // After this we'll use a set of heuristics to determine whether this + // render pass will run to completion or restart or "suspend" the commit. + // The actual logic for this is spread out in different places. + // + // This first principle is that if we're going to suspend when we complete + // a root, then we should also restart if we get an update or ping that + // might unsuspend it, and vice versa. The only reason to suspend is + // because you think you might want to restart before committing. However, + // it doesn't make sense to restart only while in the period we're suspended. + // + // Restarting too aggressively is also not good because it starves out any + // intermediate loading state. So we use heuristics to determine when. + // Suspense Heuristics + // + // If nothing threw a Promise or all the same fallbacks are already showing, + // then don't suspend/restart. + // + // If this is an initial render of a new tree of Suspense boundaries and + // those trigger a fallback, then don't suspend/restart. We want to ensure + // that we can show the initial loading state as quickly as possible. + // + // If we hit a "Delayed" case, such as when we'd switch from content back into + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. + // + // If we're already showing a fallback and it gets "retried", allowing us to show + // another level, but there's still an inner boundary that would show a fallback, + // then we suspend/restart for 500ms since the last time we showed a fallback + // anywhere in the tree. This effectively throttles progressive loading into a + // consistent train of commits. This also gives us an opportunity to restart to + // get to the completed state slightly earlier. + // + // If there's ambiguity due to batching it's resolved in preference of: + // 1) "delayed", 2) "initial render", 3) "retry". + // + // We want to ensure that a "busy" state doesn't get force committed. We want to + // ensure that new initial loading states can commit as soon as possible. - { - var componentName = capturedError.componentName, - componentStack = capturedError.componentStack, - errorBoundaryName = capturedError.errorBoundaryName, - errorBoundaryFound = capturedError.errorBoundaryFound, - willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling - // `preventDefault()` in window `error` handler. - // We record this information as an expando on the error. - - if (error != null && error._suppressLogging) { - if (errorBoundaryFound && willRetry) { - // The error is recoverable and was silenced. - // Ignore it and don't print the stack addendum. - // This is handy for testing error boundaries without noise. + attachPingListener(root, wakeable, rootRenderLanes); + _workInProgress.flags |= ShouldCapture; + _workInProgress.lanes = rootRenderLanes; return; - } // The error is fatal. Since the silencing might have - // been accidental, we'll surface it anyway. - // However, the browser would have silenced the original error - // so we'll print it first, and then print the stack addendum. + } // This boundary already captured during this render. Continue to the next + // boundary. - console["error"](error); // Don't transform to our wrapper - // For a more detailed description of this block, see: - // https://github.com/facebook/react/pull/13384 - } + _workInProgress = _workInProgress.return; + } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. + // TODO: Use invariant so the message is stripped in prod? - var componentNameMessage = componentName - ? "The above error occurred in the <" + componentName + "> component:" - : "The above error occurred in one of your React components:"; - var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. + value = new Error( + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + ); + } // We didn't find a boundary that could handle this type of exception. Start + // over and traverse parent path again, this time treating the exception + // as an error. - if (errorBoundaryFound && errorBoundaryName) { - if (willRetry) { - errorBoundaryMessage = - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + errorBoundaryName + "."); - } else { - errorBoundaryMessage = - "This error was initially handled by the error boundary " + - errorBoundaryName + - ".\n" + - "Recreating the tree from scratch failed so React will unmount the tree."; + renderDidError(); + value = createCapturedValue(value, sourceFiber); + var workInProgress = returnFiber; + + do { + switch (workInProgress.tag) { + case HostRoot: { + var _errorInfo = value; + workInProgress.flags |= ShouldCapture; + var lane = pickArbitraryLane(rootRenderLanes); + workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); + + var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); + + enqueueCapturedUpdate(workInProgress, _update); + return; } - } else { - 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."; - } - var combinedMessage = - "" + - componentNameMessage + - componentStack + - "\n\n" + - ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. - // We don't include the original error message and JS stack because the browser - // has already printed it. Even if the application swallows the error, it is still - // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. + case ClassComponent: + // Capture and retry + var errorInfo = value; + var ctor = workInProgress.type; + var instance = workInProgress.stateNode; - console["error"](combinedMessage); // Don't transform to our wrapper - } -} + if ( + (workInProgress.flags & DidCapture) === NoFlags && + (typeof ctor.getDerivedStateFromError === "function" || + (instance !== null && + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance))) + ) { + workInProgress.flags |= ShouldCapture; -var didWarnAboutUndefinedSnapshotBeforeUpdate = null; + var _lane = pickArbitraryLane(rootRenderLanes); -{ - didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); -} + workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state -var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; -function logError(boundary, errorInfo) { - var source = errorInfo.source; - var stack = errorInfo.stack; + var _update2 = createClassErrorUpdate( + workInProgress, + errorInfo, + _lane + ); - if (stack === null && source !== null) { - stack = getStackByFiberInDevAndProd(source); - } + enqueueCapturedUpdate(workInProgress, _update2); + return; + } - var capturedError = { - componentName: source !== null ? getComponentName(source.type) : null, - componentStack: stack !== null ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: false, - willRetry: false - }; + break; + } - if (boundary !== null && boundary.tag === ClassComponent) { - capturedError.errorBoundary = boundary.stateNode; - capturedError.errorBoundaryName = getComponentName(boundary.type); - capturedError.errorBoundaryFound = true; - capturedError.willRetry = true; - } + workInProgress = workInProgress.return; + } while (workInProgress !== null); +} - try { - logCapturedError(capturedError); - } catch (e) { - // This method must not throw, or React internal state will get messed up. - // If console.error is overridden, or logCapturedError() shows a dialog that throws, - // we want to report this error outside of the normal stack as a last resort. - // https://github.com/facebook/react/issues/13188 - setTimeout(function() { - throw e; - }); - } +var didWarnAboutUndefinedSnapshotBeforeUpdate = null; + +{ + didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); } +var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; + var callComponentWillUnmountWithTimer = function(current, instance) { - startPhaseTimer(current, "componentWillUnmount"); instance.props = current.memoizedProps; instance.state = current.memoizedState; { instance.componentWillUnmount(); } - - stopPhaseTimer(); }; // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount(current, instance) { @@ -15405,7 +16232,9 @@ function safelyDetachRef(current) { if (ref !== null) { if (typeof ref === "function") { { - invokeGuardedCallback(null, ref, null, null); + { + invokeGuardedCallback(null, ref, null, null); + } if (hasCaughtError()) { var refError = clearCaughtError(); @@ -15439,11 +16268,10 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } case ClassComponent: { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; - startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate"); var instance = finishedWork.stateNode; // We could update instance props and state here, // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. @@ -15499,14 +16327,23 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } instance.__reactInternalSnapshotBeforeUpdate = snapshot; - stopPhaseTimer(); } } return; } - case HostRoot: + case HostRoot: { + { + if (finishedWork.flags & Snapshot) { + var root = finishedWork.stateNode; + clearContainer(root.containerInfo); + } + } + + return; + } + case HostComponent: case HostText: case HostPortal: @@ -15583,16 +16420,15 @@ function commitHookEffectListMount(tag, finishedWork) { " }\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"; + "Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching"; } else { addendum = " You returned: " + destroy; } error( "An effect function must not return anything besides a function, " + - "which is used for clean-up.%s%s", - addendum, - getStackByFiberInDevAndProd(finishedWork) + "which is used for clean-up.%s", + addendum ); } } @@ -15603,33 +16439,30 @@ function commitHookEffectListMount(tag, finishedWork) { } } -function commitPassiveHookEffects(finishedWork) { - if ((finishedWork.effectTag & Passive) !== NoEffect) { - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: - case Block: { - // TODO (#17945) We should call all passive destroy functions (for all fibers) - // before calling any create functions. The current approach only serializes - // these for a single fiber. - { - commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork); - commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); - } +function schedulePassiveEffects(finishedWork) { + var updateQueue = finishedWork.updateQueue; + var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; - break; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + + do { + var _effect = effect, + next = _effect.next, + tag = _effect.tag; + + if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); + enqueuePendingPassiveHookEffectMount(finishedWork, effect); } - } + + effect = next; + } while (effect !== firstEffect); } } -function commitLifeCycles( - finishedRoot, - current, - finishedWork, - committedExpirationTime -) { +function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: @@ -15643,18 +16476,18 @@ function commitLifeCycles( commitHookEffectListMount(Layout | HasEffect, finishedWork); } + schedulePassiveEffects(finishedWork); return; } case ClassComponent: { var instance = finishedWork.stateNode; - if (finishedWork.effectTag & Update) { + if (finishedWork.flags & Update) { if (current === null) { - startPhaseTimer(finishedWork, "componentDidMount"); // We could update instance props and state here, + // We could update instance props and state here, // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. - { if ( finishedWork.type === finishedWork.elementType && @@ -15687,15 +16520,12 @@ function commitLifeCycles( { instance.componentDidMount(); } - - stopPhaseTimer(); } else { var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); - var prevState = current.memoizedState; - startPhaseTimer(finishedWork, "componentDidUpdate"); // We could update instance props and state here, + var prevState = current.memoizedState; // We could update instance props and state here, // but instead we rely on them being set during last render. // TODO: revisit this when we implement resuming. @@ -15735,10 +16565,9 @@ function commitLifeCycles( instance.__reactInternalSnapshotBeforeUpdate ); } - - stopPhaseTimer(); } - } + } // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. var updateQueue = finishedWork.updateQueue; @@ -15781,6 +16610,8 @@ function commitLifeCycles( } case HostRoot: { + // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. var _updateQueue = finishedWork.updateQueue; if (_updateQueue !== null) { @@ -15810,7 +16641,7 @@ function commitLifeCycles( // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. - if (current === null && finishedWork.effectTag & Update) { + if (current === null && finishedWork.flags & Update) { var type = finishedWork.type; var props = finishedWork.memoizedProps; } @@ -15862,6 +16693,8 @@ function commitLifeCycles( case IncompleteClassComponent: case FundamentalComponent: case ScopeComponent: + case OffscreenComponent: + case LegacyHiddenComponent: return; } @@ -15896,17 +16729,12 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { unhideTextInstance(_instance3, node.memoizedProps); } } else if ( - node.tag === SuspenseComponent && + (node.tag === OffscreenComponent || + node.tag === LegacyHiddenComponent) && node.memoizedState !== null && - node.memoizedState.dehydrated === null - ) { - // Found a nested Suspense component that timed out. Skip over the - // primary child fragment, which should remain hidden. - var fallbackChildFragment = node.child.sibling; - fallbackChildFragment.return = node; - node = fallbackChildFragment; - continue; - } else if (node.child !== null) { + node !== finishedWork + ); + else if (node.child !== null) { node.child.return = node; node = node.child; continue; @@ -15947,15 +16775,16 @@ function commitAttachRef(finishedWork) { } // Moved outside to ensure DCE works with this flag if (typeof ref === "function") { - ref(instanceToUse); + { + ref(instanceToUse); + } } else { { if (!ref.hasOwnProperty("current")) { error( "Unexpected ref object provided for %s. " + - "Use either a ref-setter function or React.createRef().%s", - getComponentName(finishedWork.type), - getStackByFiberInDevAndProd(finishedWork) + "Use either a ref-setter function or React.createRef().", + getComponentName(finishedWork.type) ); } } @@ -15970,7 +16799,9 @@ function commitDetachRef(current) { if (currentRef !== null) { if (typeof currentRef === "function") { - currentRef(null); + { + currentRef(null); + } } else { currentRef.current = null; } @@ -15995,42 +16826,25 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { if (lastEffect !== null) { var firstEffect = lastEffect.next; + var effect = firstEffect; - { - // When the owner fiber is deleted, the destroy function of a passive - // effect hook is called during the synchronous commit phase. This is - // a concession to implementation complexity. Calling it in the - // passive effect phase (like they usually are, when dependencies - // change during an update) would require either traversing the - // children of the deleted fiber again, or including unmount effects - // as part of the fiber effect list. - // - // Because this is during the sync commit phase, we need to change - // the priority. - // - // TODO: Reconsider this implementation trade off. - var priorityLevel = - renderPriorityLevel > NormalPriority - ? NormalPriority - : renderPriorityLevel; - runWithPriority(priorityLevel, function() { - var effect = firstEffect; - - do { - var _effect3 = effect, - _destroy = _effect3.destroy, - _tag = _effect3.tag; - - if (_destroy !== undefined) { - { - safelyCallDestroy(current, _destroy); - } + do { + var _effect2 = effect, + destroy = _effect2.destroy, + tag = _effect2.tag; + + if (destroy !== undefined) { + if ((tag & Passive$1) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(current, effect); + } else { + { + safelyCallDestroy(current, destroy); } + } + } - effect = effect.next; - } while (effect !== firstEffect); - }); - } + effect = effect.next; + } while (effect !== firstEffect); } } @@ -16058,7 +16872,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { // We are also not using this parent because // the portal will get pushed immediately. { - unmountHostComponents(finishedRoot, current, renderPriorityLevel); + unmountHostComponents(finishedRoot, current); } return; @@ -16087,7 +16901,7 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { var node = root; while (true) { - commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes. + commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes. // Skip portals because commitUnmount() currently visits them recursively. if ( @@ -16117,27 +16931,33 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { } } -function detachFiber(current) { - var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we +function detachFiberMutation(fiber) { + // Cut off the return pointers to disconnect it from the tree. Ideally, we // should clear the child pointer of the parent alternate to let this // get GC:ed but we don't know which for sure which parent is the current // one so we'll settle for GC:ing the subtree of this child. This child // itself will be GC:ed when the parent updates the next time. + // Note: we cannot null out sibling here, otherwise it can cause issues + // with findDOMNode and how it requires the sibling field to carry out + // traversal in a later effect. See PR #16820. We now clear the sibling + // field after effects, see: detachFiberAfterEffects. + // + // Don't disconnect stateNode now; it will be detached in detachFiberAfterEffects. + // It may be required if the current component is an error boundary, + // and one of its descendants throws while unmounting a passive effect. + fiber.alternate = null; + fiber.child = null; + fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.return = null; + fiber.updateQueue = null; - current.return = null; - current.child = null; - current.memoizedState = null; - current.updateQueue = null; - current.dependencies = null; - current.alternate = null; - current.firstEffect = null; - current.lastEffect = null; - current.pendingProps = null; - current.memoizedProps = null; - current.stateNode = null; - - if (alternate !== null) { - detachFiber(alternate); + { + fiber._debugOwner = null; } } @@ -16196,7 +17016,7 @@ function getHostSibling(fiber) { ) { // If it is not host node and, we might have a host node inside it. // Try to search down until we find one. - if (node.effectTag & Placement) { + if (node.flags & Placement) { // If we don't have a child, try the siblings instead. continue siblings; } // If we don't have a child, try the siblings instead. @@ -16210,7 +17030,7 @@ function getHostSibling(fiber) { } } // Check if this host node is stable or about to be placed. - if (!(node.effectTag & Placement)) { + if (!(node.flags & Placement)) { // Found it! return node.stateNode; } @@ -16251,8 +17071,8 @@ function commitPlacement(finishedWork) { } } - if (parentFiber.effectTag & ContentReset) { - parentFiber.effectTag &= ~ContentReset; + if (parentFiber.flags & ContentReset) { + parentFiber.flags &= ~ContentReset; } var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its @@ -16369,7 +17189,7 @@ function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { } if (node.tag === HostComponent || node.tag === HostText) { - commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the + commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the // node from the tree. if (currentParentIsContainer) { @@ -16389,7 +17209,7 @@ function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { continue; } } else { - commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below. + commitUnmount(finishedRoot, node); // Visit children because we may find more host components below. if (node.child !== null) { node.child.return = node; @@ -16425,10 +17245,15 @@ function commitDeletion(finishedRoot, current, renderPriorityLevel) { { // Recursively delete all host nodes from the parent. // Detach refs and call componentWillUnmount() on the whole subtree. - unmountHostComponents(finishedRoot, current, renderPriorityLevel); + unmountHostComponents(finishedRoot, current); } - detachFiber(current); + var alternate = current.alternate; + detachFiberMutation(current); + + if (alternate !== null) { + detachFiberMutation(alternate); + } } function commitWork(current, finishedWork) { @@ -16463,3163 +17288,3322 @@ function commitWork(current, finishedWork) { // as the newProps. The updatePayload will contain the real change in // this case. - var oldProps = current !== null ? current.memoizedProps : newProps; - var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components. + var oldProps = current !== null ? current.memoizedProps : newProps; + var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components. + + var updatePayload = finishedWork.updateQueue; + finishedWork.updateQueue = null; + + if (updatePayload !== null) { + commitUpdate(instance, updatePayload, type, oldProps, newProps); + } + } + + return; + } + + case HostText: { + if (!(finishedWork.stateNode !== null)) { + throw Error( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + + var textInstance = finishedWork.stateNode; + var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps + // as the newProps. The updatePayload will contain the real change in + // this case. + + var oldText = current !== null ? current.memoizedProps : newText; + commitTextUpdate(textInstance, oldText, newText); + return; + } + + case HostRoot: { + return; + } + + case Profiler: { + return; + } + + case SuspenseComponent: { + commitSuspenseComponent(finishedWork); + attachSuspenseRetryListeners(finishedWork); + return; + } + + case SuspenseListComponent: { + attachSuspenseRetryListeners(finishedWork); + return; + } + + case IncompleteClassComponent: { + return; + } + + case FundamentalComponent: { + break; + } + + case ScopeComponent: { + break; + } + + case OffscreenComponent: + case LegacyHiddenComponent: { + var newState = finishedWork.memoizedState; + var isHidden = newState !== null; + hideOrUnhideAllChildren(finishedWork, isHidden); + return; + } + } + + { + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } +} + +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + + if (newState !== null) { + markCommitTimeOfFallback(); + + { + // Hide the Offscreen component that contains the primary children. TODO: + // Ideally, this effect would have been scheduled on the Offscreen fiber + // itself. That's how unhiding works: the Offscreen component schedules an + // effect on itself. However, in this case, the component didn't complete, + // so the fiber was never added to the effect list in the normal path. We + // could have appended it to the effect list in the Suspense component's + // second pass, but doing it this way is less complicated. This would be + // simpler if we got rid of the effect list and traversed the tree, like + // we're planning to do. + var primaryChildParent = finishedWork.child; + hideOrUnhideAllChildren(primaryChildParent, true); + } + } +} + +function attachSuspenseRetryListeners(finishedWork) { + // If this boundary just timed out, then it will have a set of wakeables. + // For each wakeable, attach a listener so that when it resolves, React + // attempts to re-render the boundary in the primary (pre-timeout) state. + var wakeables = finishedWork.updateQueue; + + if (wakeables !== null) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + + if (retryCache === null) { + retryCache = finishedWork.stateNode = new PossiblyWeakSet(); + } + + wakeables.forEach(function(wakeable) { + // Memoize using the boundary fiber to prevent redundant listeners. + var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + + if (!retryCache.has(wakeable)) { + { + if (wakeable.__reactDoNotTraceInteractions !== true) { + retry = tracing.unstable_wrap(retry); + } + } + + retryCache.add(wakeable); + wakeable.then(retry, retry); + } + }); + } +} // This function detects when a Suspense boundary goes from visible to hidden. +// It returns false if the boundary is already hidden. +// TODO: Use an effect tag. + +function isSuspenseBoundaryBeingHidden(current, finishedWork) { + if (current !== null) { + var oldState = current.memoizedState; + + if (oldState === null || oldState.dehydrated !== null) { + var newState = finishedWork.memoizedState; + return newState !== null && newState.dehydrated === null; + } + } + + return false; +} + +function commitResetTextContent(current) { + resetTextContent(current.stateNode); +} + +var COMPONENT_TYPE = 0; +var HAS_PSEUDO_CLASS_TYPE = 1; +var ROLE_TYPE = 2; +var TEST_NAME_TYPE = 3; +var TEXT_TYPE = 4; + +if (typeof Symbol === "function" && Symbol.for) { + var symbolFor$1 = Symbol.for; + COMPONENT_TYPE = symbolFor$1("selector.component"); + HAS_PSEUDO_CLASS_TYPE = symbolFor$1("selector.has_pseudo_class"); + ROLE_TYPE = symbolFor$1("selector.role"); + TEST_NAME_TYPE = symbolFor$1("selector.test_id"); + TEXT_TYPE = symbolFor$1("selector.text"); +} + +var ceil = Math.ceil; +var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, + IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; +var NoContext = + /* */ + 0; +var BatchedContext = + /* */ + 1; +var DiscreteEventContext = + /* */ + 4; +var LegacyUnbatchedContext = + /* */ + 8; +var RenderContext = + /* */ + 16; +var CommitContext = + /* */ + 32; +var RetryAfterError = + /* */ + 64; +var RootIncomplete = 0; +var RootFatalErrored = 1; +var RootErrored = 2; +var RootSuspended = 3; +var RootSuspendedWithDelay = 4; +var RootCompleted = 5; // Describes where we are in the React execution stack + +var executionContext = NoContext; // The root we're working on + +var workInProgressRoot = null; // The fiber we're working on + +var workInProgress = null; // The lanes we're rendering + +var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree +// This is a superset of the lanes we started working on at the root. The only +// case where it's different from `workInProgressRootRenderLanes` is when we +// enter a subtree that is hidden and needs to be unhidden: Suspense and +// Offscreen component. +// +// Most things in the work loop should deal with workInProgressRootRenderLanes. +// Most things in begin/complete phases should deal with subtreeRenderLanes. + +var subtreeRenderLanes = NoLanes; +var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. + +var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown + +var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's +// slightly different than `renderLanes` because `renderLanes` can change as you +// enter and exit an Offscreen tree. This value is the combination of all render +// lanes for the entire render phase. + +var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only +// includes unprocessed updates, not work in bailed out children. + +var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. + +var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. + +var workInProgressRootPingedLanes = NoLanes; +var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train +// model where we don't commit new loading states in too quick succession. + +var globalMostRecentFallbackTime = 0; +var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering +// more and prefer CPU suspense heuristics instead. + +var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU +// suspense heuristics and opt out of rendering more content. + +var RENDER_TIMEOUT_MS = 500; + +function resetRenderTimer() { + workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS; +} + +function getRenderTargetTime() { + return workInProgressRootRenderTargetTime; +} +var nextEffect = null; +var hasUncaughtError = false; +var firstUncaughtError = null; +var legacyErrorBoundariesThatAlreadyFailed = null; +var rootDoesHavePassiveEffects = false; +var rootWithPendingPassiveEffects = null; +var pendingPassiveEffectsRenderPriority = NoPriority$1; +var pendingPassiveEffectsLanes = NoLanes; +var pendingPassiveHookEffectsMount = []; +var pendingPassiveHookEffectsUnmount = []; +var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates + +var NESTED_UPDATE_LIMIT = 50; +var nestedUpdateCount = 0; +var rootWithNestedUpdates = null; +var NESTED_PASSIVE_UPDATE_LIMIT = 50; +var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes +// during the commit phase. This enables them to be traced across components +// that spawn new work during render. E.g. hidden boundaries, suspended SSR +// hydration or SuspenseList. +// TODO: Can use a bitmask instead of an array + +var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their +// event times as simultaneous, even if the actual clock time has advanced +// between the first and second call. - var updatePayload = finishedWork.updateQueue; - finishedWork.updateQueue = null; +var currentEventTime = NoTimestamp; +var currentEventWipLanes = NoLanes; +var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. +// We warn about state updates for unmounted components differently in this case. - if (updatePayload !== null) { - commitUpdate(instance, updatePayload, type, oldProps, newProps); - } - } +var isFlushingPassiveEffects = false; +var focusedInstanceHandle = null; +var shouldFireAfterActiveInstanceBlur = false; +function getWorkInProgressRoot() { + return workInProgressRoot; +} +function requestEventTime() { + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + // We're inside React, so it's fine to read the actual time. + return now(); + } // We're not inside React, so we may be in the middle of a browser event. - return; - } + if (currentEventTime !== NoTimestamp) { + // Use the same start time for all updates until we enter React again. + return currentEventTime; + } // This is the first update since React yielded. Compute a new start time. - case HostText: { - if (!(finishedWork.stateNode !== null)) { - throw Error( - "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." - ); - } + currentEventTime = now(); + return currentEventTime; +} +function requestUpdateLane(fiber) { + // Special cases + var mode = fiber.mode; - var textInstance = finishedWork.stateNode; - var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps - // as the newProps. The updatePayload will contain the real change in - // this case. + if ((mode & BlockingMode) === NoMode) { + return SyncLane; + } else if ((mode & ConcurrentMode) === NoMode) { + return getCurrentPriorityLevel() === ImmediatePriority$1 + ? SyncLane + : SyncBatchedLane; + } // The algorithm for assigning an update to a lane should be stable for all + // updates at the same priority within the same event. To do this, the inputs + // to the algorithm must be the same. For example, we use the `renderLanes` + // to avoid choosing a lane that is already in the middle of rendering. + // + // However, the "included" lanes could be mutated in between updates in the + // same event, like if you perform an update inside `flushSync`. Or any other + // code path that might call `prepareFreshStack`. + // + // The trick we use is to cache the first of each of these inputs within an + // event. Then reset the cached values once we can be sure the event is over. + // Our heuristic for that is whenever we enter a concurrent work loop. + // + // We'll do the same for `currentEventPendingLanes` below. - var oldText = current !== null ? current.memoizedProps : newText; - commitTextUpdate(textInstance, oldText, newText); - return; - } + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; + } - case HostRoot: { - return; - } + var isTransition = requestCurrentTransition() !== NoTransition; - case Profiler: { - return; + if (isTransition) { + if (currentEventPendingLanes !== NoLanes) { + currentEventPendingLanes = + mostRecentlyUpdatedRoot !== null + ? mostRecentlyUpdatedRoot.pendingLanes + : NoLanes; } - case SuspenseComponent: { - commitSuspenseComponent(finishedWork); - attachSuspenseRetryListeners(finishedWork); - return; - } + return findTransitionLane(currentEventWipLanes, currentEventPendingLanes); + } // TODO: Remove this dependency on the Scheduler priority. + // To do that, we're replacing it with an update lane priority. - case SuspenseListComponent: { - attachSuspenseRetryListeners(finishedWork); - return; - } + var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler. + // This couples React to the Scheduler internals, so we're replacing it + // with the currentUpdateLanePriority above. As an example of how this + // could be problematic, if we're not inside `Scheduler.runWithPriority`, + // then we'll get the priority of the current running Scheduler task, + // which is probably not what we want. - case IncompleteClassComponent: { - return; - } - } + var lane; - { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + if ( + // TODO: Temporary. We're removing the concept of discrete updates. + (executionContext & DiscreteEventContext) !== NoContext && + schedulerPriority === UserBlockingPriority$1 + ) { + lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); + } else { + var schedulerLanePriority = schedulerPriorityToLanePriority( + schedulerPriority ); + + lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); } + + return lane; } -function commitSuspenseComponent(finishedWork) { - var newState = finishedWork.memoizedState; - var newDidTimeout; - var primaryChildParent = finishedWork; +function requestRetryLane(fiber) { + // This is a fork of `requestUpdateLane` designed specifically for Suspense + // "retries" — a special update that attempts to flip a Suspense boundary + // from its placeholder state to its primary/resolved state. + // Special cases + var mode = fiber.mode; - if (newState === null) { - newDidTimeout = false; - } else { - newDidTimeout = true; - primaryChildParent = finishedWork.child; - markCommitTimeOfFallback(); - } + if ((mode & BlockingMode) === NoMode) { + return SyncLane; + } else if ((mode & ConcurrentMode) === NoMode) { + return getCurrentPriorityLevel() === ImmediatePriority$1 + ? SyncLane + : SyncBatchedLane; + } // See `requestUpdateLane` for explanation of `currentEventWipLanes` - if (primaryChildParent !== null) { - hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; } + + return findRetryLane(currentEventWipLanes); } -function attachSuspenseRetryListeners(finishedWork) { - // If this boundary just timed out, then it will have a set of thenables. - // For each thenable, attach a listener so that when it resolves, React - // attempts to re-render the boundary in the primary (pre-timeout) state. - var thenables = finishedWork.updateQueue; +function scheduleUpdateOnFiber(fiber, lane, eventTime) { + checkForNestedUpdates(); + warnAboutRenderPhaseUpdatesInDEV(fiber); + var root = markUpdateLaneFromFiberToRoot(fiber, lane); - if (thenables !== null) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; + if (root === null) { + warnAboutUpdateOnUnmountedFiberInDEV(fiber); + return null; + } // Mark that the root has a pending update. - if (retryCache === null) { - retryCache = finishedWork.stateNode = new PossiblyWeakSet(); + markRootUpdated(root, lane, eventTime); + + if (root === workInProgressRoot) { + // Received an update to a tree that's in the middle of rendering. Mark + // that there was an interleaved update work on this root. Unless the + // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render + // phase update. In that case, we don't treat render phase updates as if + // they were interleaved, for backwards compat reasons. + { + workInProgressRootUpdatedLanes = mergeLanes( + workInProgressRootUpdatedLanes, + lane + ); } - thenables.forEach(function(thenable) { - // Memoize using the boundary fiber to prevent redundant listeners. - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + if (workInProgressRootExitStatus === RootSuspendedWithDelay) { + // The root already suspended with a delay, which means this render + // definitely won't finish. Since we have a new update, let's mark it as + // suspended now, right before marking the incoming update. This has the + // effect of interrupting the current render and switching to the update. + // TODO: Make sure this doesn't override pings that happen while we've + // already started rendering. + markRootSuspended$1(root, workInProgressRootRenderLanes); + } + } // TODO: requestUpdateLanePriority also reads the priority. Pass the + // priority as an argument to that function and this one. - if (!retryCache.has(thenable)) { - { - if (thenable.__reactDoNotTraceInteractions !== true) { - retry = tracing.unstable_wrap(retry); - } - } + var priorityLevel = getCurrentPriorityLevel(); - retryCache.add(thenable); - thenable.then(retry, retry); + if (lane === SyncLane) { + if ( + // Check if we're inside unbatchedUpdates + (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering + (executionContext & (RenderContext | CommitContext)) === NoContext + ) { + // Register pending interactions on the root to avoid losing traced interaction data. + schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + // root inside of batchedUpdates should be synchronous, but layout updates + // should be deferred until the end of the batch. + + performSyncWorkOnRoot(root); + } else { + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, lane); + + if (executionContext === NoContext) { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncCallbackQueue(); } - }); - } -} + } + } else { + // Schedule a discrete update but only if it's not Sync. + if ( + (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered + // discrete, even inside a discrete event. + (priorityLevel === UserBlockingPriority$1 || + priorityLevel === ImmediatePriority$1) + ) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Set([root]); + } else { + rootsWithPendingDiscreteUpdates.add(root); + } + } // Schedule other updates after in case the callback is sync. -function commitResetTextContent(current) { - resetTextContent(current.stateNode); -} + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, lane); + } // We use this when assigning a lane for a transition inside + // `requestUpdateLane`. We assume it's the same as the root being updated, + // since in the common case of a single root app it probably is. If it's not + // the same root, then it's not a huge deal, we just might batch more stuff + // together more than necessary. -var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; + mostRecentlyUpdatedRoot = root; +} // This is split into a separate function so we can mark a fiber with pending +// work without treating it as a typical update that originates from an event; +// e.g. retrying a Suspense boundary isn't an update, but it does schedule work +// on a fiber. -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - var update = createUpdate(expirationTime, null); // Unmount the root by rendering null. +function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + // Update the source fiber's lanes + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); + var alternate = sourceFiber.alternate; - update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property - // being called "element". + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); + } - update.payload = { - element: null - }; - var error = errorInfo.value; + { + if ( + alternate === null && + (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags + ) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); + } + } // Walk the parent path to the root and update the child expiration time. - update.callback = function() { - onUncaughtError(error); - logError(fiber, errorInfo); - }; + var node = sourceFiber; + var parent = sourceFiber.return; - return update; -} + while (parent !== null) { + parent.childLanes = mergeLanes(parent.childLanes, lane); + alternate = parent.alternate; -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - var update = createUpdate(expirationTime, null); - update.tag = CaptureUpdate; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, lane); + } else { + { + if ((parent.flags & (Placement | Hydrating)) !== NoFlags) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); + } + } + } - if (typeof getDerivedStateFromError === "function") { - var error$1 = errorInfo.value; + node = parent; + parent = parent.return; + } - update.payload = function() { - logError(fiber, errorInfo); - return getDerivedStateFromError(error$1); - }; + if (node.tag === HostRoot) { + var root = node.stateNode; + return root; + } else { + return null; } +} // Use this function to schedule a task for a root. There's only one task per +// root; if a task was already scheduled, we'll check to make sure the priority +// of the existing task is the same as the priority of the next level that the +// root has work on. This function is called on every update, and right before +// exiting a task. - var inst = fiber.stateNode; +function ensureRootIsScheduled(root, currentTime) { + var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. - if (inst !== null && typeof inst.componentDidCatch === "function") { - update.callback = function callback() { - { - markFailedErrorBoundaryForHotReloading(fiber); - } + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - if (typeof getDerivedStateFromError !== "function") { - // To preserve the preexisting retry behavior of error boundaries, - // we keep track of which ones already failed during this batch. - // This gets reset before we yield back to the browser. - // TODO: Warn in strict mode if getDerivedStateFromError is - // not defined. - markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); // This returns the priority level computed during the `getNextLanes` call. - logError(fiber, errorInfo); - } + var newCallbackPriority = returnNextLanesPriority(); - var error$1 = errorInfo.value; - var stack = errorInfo.stack; - this.componentDidCatch(error$1, { - componentStack: stack !== null ? stack : "" - }); + if (nextLanes === NoLanes) { + // Special case: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + root.callbackNode = null; + root.callbackPriority = NoLanePriority; + } - { - if (typeof getDerivedStateFromError !== "function") { - // If componentDidCatch is the only error boundary method defined, - // then it needs to call setState to recover from errors. - // If no state update is scheduled then the boundary will swallow the error. - if (fiber.expirationTime !== Sync) { - error( - "%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" - ); - } - } - } - }; - } else { - update.callback = function() { - markFailedErrorBoundaryForHotReloading(fiber); - }; - } + return; + } // Check if there's an existing task. We may be able to reuse it. - return update; -} + if (existingCallbackNode !== null) { + var existingCallbackPriority = root.callbackPriority; -function attachPingListener(root, renderExpirationTime, thenable) { - // Attach a listener to the promise to "ping" the root and retry. But - // only if one does not already exist for the current render expiration - // time (which acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs; + if (existingCallbackPriority === newCallbackPriority) { + // The priority hasn't changed. We can reuse the existing task. Exit. + return; + } // The priority changed. Cancel the existing callback. We'll schedule a new + // one below. - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap(); - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); - } else { - threadIDs = pingCache.get(thenable); + cancelCallback(existingCallbackNode); + } // Schedule a new callback. - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); - } - } + var newCallbackNode; - if (!threadIDs.has(renderExpirationTime)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(renderExpirationTime); - var ping = pingSuspendedRoot.bind( - null, - root, - thenable, - renderExpirationTime + if (newCallbackPriority === SyncLanePriority) { + // Special case: Sync React callbacks are scheduled on a special + // internal queue + newCallbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + ); + } else if (newCallbackPriority === SyncBatchedLanePriority) { + newCallbackNode = scheduleCallback( + ImmediatePriority$1, + performSyncWorkOnRoot.bind(null, root) + ); + } else { + var schedulerPriorityLevel = lanePriorityToSchedulerPriority( + newCallbackPriority + ); + newCallbackNode = scheduleCallback( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) ); - thenable.then(ping, ping); } -} -function throwException( - root, - returnFiber, - sourceFiber, - value, - renderExpirationTime -) { - // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; +} // This is the entry point for every concurrent task, i.e. anything that +// goes through Scheduler. + +function performConcurrentWorkOnRoot(root) { + // Since we know we're in a React event, we can clear the current + // event time. The next update will compute a new event time. + currentEventTime = NoTimestamp; + currentEventWipLanes = NoLanes; + currentEventPendingLanes = NoLanes; + + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } // Flush any pending passive effects before deciding which lanes to work on, + // in case they schedule additional work. + + var originalCallbackNode = root.callbackNode; + var didFlushPassiveEffects = flushPassiveEffects(); + + if (didFlushPassiveEffects) { + // Something in the passive effect phase may have canceled the current task. + // Check if the task node for this root was changed. + if (root.callbackNode !== originalCallbackNode) { + // The current task was canceled. Exit. We don't need to call + // `ensureRootIsScheduled` because the check above implies either that + // there's a new task, or that there's no remaining work on this root. + return null; + } + } // Determine the next expiration time to work on, using the fields stored + // on the root. + + var lanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); - sourceFiber.firstEffect = sourceFiber.lastEffect = null; + if (lanes === NoLanes) { + // Defensive coding. This is never expected to happen. + return null; + } + + var exitStatus = renderRootConcurrent(root, lanes); if ( - value !== null && - typeof value === "object" && - typeof value.then === "function" + includesSomeLane( + workInProgressRootIncludedLanes, + workInProgressRootUpdatedLanes + ) ) { - // This is a thenable. - var thenable = value; + // The render included lanes that were updated during the render phase. + // For example, when unhiding a hidden tree, we include all the lanes + // that were previously skipped when the tree was hidden. That set of + // lanes is a superset of the lanes we started rendering with. + // + // So we'll throw out the current work and restart. + prepareFreshStack(root, NoLanes); + } else if (exitStatus !== RootIncomplete) { + if (exitStatus === RootErrored) { + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. - if ((sourceFiber.mode & BlockingMode) === NoMode) { - // Reset the memoizedState to what it was before we attempted - // to render it. - var currentSource = sourceFiber.alternate; + if (root.hydrate) { + root.hydrate = false; + clearContainer(root.containerInfo); + } // If something threw an error, try rendering one more time. We'll render + // synchronously to block concurrent data mutations, and we'll includes + // all pending updates are included. If it still fails after the second + // attempt, we'll give up and commit the resulting tree. - if (currentSource) { - sourceFiber.updateQueue = currentSource.updateQueue; - sourceFiber.memoizedState = currentSource.memoizedState; - sourceFiber.expirationTime = currentSource.expirationTime; - } else { - sourceFiber.updateQueue = null; - sourceFiber.memoizedState = null; + lanes = getLanesToRetrySynchronouslyOnError(root); + + if (lanes !== NoLanes) { + exitStatus = renderRootSync(root, lanes); } } - var hasInvisibleParentBoundary = hasSuspenseContext( - suspenseStackCursor.current, - InvisibleParentSuspenseContext - ); // Schedule the nearest Suspense to re-render the timed out view. + if (exitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw fatalError; + } // We now have a consistent tree. The next step is either to commit it, + // or, if something suspended, wait to commit it after a timeout. - var _workInProgress = returnFiber; + var finishedWork = root.current.alternate; + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + finishConcurrentRender(root, exitStatus, lanes); + } - do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) - ) { - // Found the nearest boundary. - // Stash the promise on the boundary fiber. If the boundary times out, we'll - // attach another listener to flip the boundary back to its normal state. - var thenables = _workInProgress.updateQueue; + ensureRootIsScheduled(root, now()); - if (thenables === null) { - var updateQueue = new Set(); - updateQueue.add(thenable); - _workInProgress.updateQueue = updateQueue; - } else { - thenables.add(thenable); - } // If the boundary is outside of blocking mode, we should *not* - // suspend the commit. Pretend as if the suspended component rendered - // null and keep rendering. In the commit phase, we'll schedule a - // subsequent synchronous update to re-render the Suspense. - // - // Note: It doesn't matter whether the component that suspended was - // inside a blocking mode tree. If the Suspense is outside of it, we - // should *not* suspend the commit. + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } - if ((_workInProgress.mode & BlockingMode) === NoMode) { - _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. - // But we shouldn't call any lifecycle methods or callbacks. Remove - // all lifecycle effect tags. + return null; +} - sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); +function finishConcurrentRender(root, exitStatus, lanes) { + switch (exitStatus) { + case RootIncomplete: + case RootFatalErrored: { + { + throw Error("Root did not complete. This is a bug in React."); + } + } + // Flow knows about invariant, so it complains if I add a break + // statement, but eslint doesn't know about invariant, so it complains + // if I do. eslint-disable-next-line no-fallthrough - if (sourceFiber.tag === ClassComponent) { - var currentSourceFiber = sourceFiber.alternate; + case RootErrored: { + // We should have already attempted to retry this tree. If we reached + // this point, it errored again. Commit it. + commitRoot(root); + break; + } - if (currentSourceFiber === null) { - // This is a new mount. Change the tag so it's not mistaken for a - // completed class component. For example, we should not call - // componentWillUnmount if it is deleted. - sourceFiber.tag = IncompleteClassComponent; - } else { - // When we try rendering again, we should not reuse the current fiber, - // since it's known to be in an inconsistent state. Use a force update to - // prevent a bail out. - var update = createUpdate(Sync, null); - update.tag = ForceUpdate; - enqueueUpdate(sourceFiber, update); - } - } // The source fiber did not complete. Mark it with Sync priority to - // indicate that it still has pending work. + case RootSuspended: { + markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we + // should immediately commit it or wait a bit. - sourceFiber.expirationTime = Sync; // Exit without suspending. + if ( + includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope + !shouldForceFlushFallbacksInDEV() + ) { + // This render only included retries, no updates. Throttle committing + // retries so that we don't show too many loading states too quickly. + var msUntilTimeout = + globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. - return; - } // Confirmed that the boundary is in a concurrent mode tree. Continue - // with the normal suspend path. - // - // After this we'll use a set of heuristics to determine whether this - // render pass will run to completion or restart or "suspend" the commit. - // The actual logic for this is spread out in different places. - // - // This first principle is that if we're going to suspend when we complete - // a root, then we should also restart if we get an update or ping that - // might unsuspend it, and vice versa. The only reason to suspend is - // because you think you might want to restart before committing. However, - // it doesn't make sense to restart only while in the period we're suspended. - // - // Restarting too aggressively is also not good because it starves out any - // intermediate loading state. So we use heuristics to determine when. - // Suspense Heuristics - // - // If nothing threw a Promise or all the same fallbacks are already showing, - // then don't suspend/restart. - // - // If this is an initial render of a new tree of Suspense boundaries and - // those trigger a fallback, then don't suspend/restart. We want to ensure - // that we can show the initial loading state as quickly as possible. - // - // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. - // - // If we're already showing a fallback and it gets "retried", allowing us to show - // another level, but there's still an inner boundary that would show a fallback, - // then we suspend/restart for 500ms since the last time we showed a fallback - // anywhere in the tree. This effectively throttles progressive loading into a - // consistent train of commits. This also gives us an opportunity to restart to - // get to the completed state slightly earlier. - // - // If there's ambiguity due to batching it's resolved in preference of: - // 1) "delayed", 2) "initial render", 3) "retry". - // - // We want to ensure that a "busy" state doesn't get force committed. We want to - // ensure that new initial loading states can commit as soon as possible. + if (msUntilTimeout > 10) { + var nextLanes = getNextLanes(root, NoLanes); - attachPingListener(root, renderExpirationTime, thenable); - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.expirationTime = renderExpirationTime; - return; - } // This boundary already captured during this render. Continue to the next - // boundary. + if (nextLanes !== NoLanes) { + // There's additional work on this root. + break; + } - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. - // TODO: Use invariant so the message is stripped in prod? + var suspendedLanes = root.suspendedLanes; - value = new Error( - (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n" + - "\n" + - "Add a component higher in the tree to " + - "provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) - ); - } // We didn't find a boundary that could handle this type of exception. Start - // over and traverse parent path again, this time treating the exception - // as an error. + if (!isSubsetOfLanes(suspendedLanes, lanes)) { + // We should prefer to render the fallback of at the last + // suspended level. Ping the last suspended level to try + // rendering it again. + // FIXME: What if the suspended lanes are Idle? Should not restart. + var eventTime = requestEventTime(); + markRootPinged(root, suspendedLanes); + break; + } // The render is suspended, it hasn't timed out, and there's no + // lower priority work to do. Instead of committing the fallback + // immediately, wait for more data to arrive. - renderDidError(); - value = createCapturedValue(value, sourceFiber); - var workInProgress = returnFiber; + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + msUntilTimeout + ); + break; + } + } // The work expired. Commit immediately. - do { - switch (workInProgress.tag) { - case HostRoot: { - var _errorInfo = value; - workInProgress.effectTag |= ShouldCapture; - workInProgress.expirationTime = renderExpirationTime; + commitRoot(root); + break; + } - var _update = createRootErrorUpdate( - workInProgress, - _errorInfo, - renderExpirationTime - ); + case RootSuspendedWithDelay: { + markRootSuspended$1(root, lanes); - enqueueCapturedUpdate(workInProgress, _update); - return; + if (includesOnlyTransitions(lanes)) { + // This is a transition, so we should exit without committing a + // placeholder and without scheduling a timeout. Delay indefinitely + // until we receive more data. + break; } - case ClassComponent: - // Capture and retry - var errorInfo = value; - var ctor = workInProgress.type; - var instance = workInProgress.stateNode; + if (!shouldForceFlushFallbacksInDEV()) { + // This is not a transition, but we did trigger an avoided state. + // Schedule a placeholder to display after a short delay, using the Just + // Noticeable Difference. + // TODO: Is the JND optimization worth the added complexity? If this is + // the only reason we track the event time, then probably not. + // Consider removing. + var mostRecentEventTime = getMostRecentEventTime(root, lanes); + var eventTimeMs = mostRecentEventTime; + var timeElapsedMs = now() - eventTimeMs; - if ( - (workInProgress.effectTag & DidCapture) === NoEffect && - (typeof ctor.getDerivedStateFromError === "function" || - (instance !== null && - typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance))) - ) { - workInProgress.effectTag |= ShouldCapture; - workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state + var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time. - var _update2 = createClassErrorUpdate( - workInProgress, - errorInfo, - renderExpirationTime + if (_msUntilTimeout > 10) { + // Instead of committing the fallback immediately, wait for more data + // to arrive. + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + _msUntilTimeout ); - - enqueueCapturedUpdate(workInProgress, _update2); - return; + break; } + } // Commit the placeholder. - break; + commitRoot(root); + break; } - workInProgress = workInProgress.return; - } while (workInProgress !== null); -} + case RootCompleted: { + // The work completed. Ready to commit. + commitRoot(root); + break; + } -var ceil = Math.ceil; -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, - ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; -var NoContext = - /* */ - 0; -var BatchedContext = - /* */ - 1; -var DiscreteEventContext = - /* */ - 4; -var LegacyUnbatchedContext = - /* */ - 8; -var RenderContext = - /* */ - 16; -var CommitContext = - /* */ - 32; -var RootIncomplete = 0; -var RootFatalErrored = 1; -var RootErrored = 2; -var RootSuspended = 3; -var RootSuspendedWithDelay = 4; -var RootCompleted = 5; -// Describes where we are in the React execution stack -var executionContext = NoContext; // The root we're working on + default: { + { + throw Error("Unknown root exit status."); + } + } + } +} -var workInProgressRoot = null; // The fiber we're working on +function markRootSuspended$1(root, suspendedLanes) { + // When suspending, we should always exclude lanes that were pinged or (more + // rarely, since we try to avoid it) updated during the render phase. + // TODO: Lol maybe there's a better way to factor this besides this + // obnoxiously named function :) + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); + markRootSuspended(root, suspendedLanes); +} // This is the entry point for synchronous tasks that don't go +// through Scheduler -var workInProgress = null; // The expiration time we're rendering +function performSyncWorkOnRoot(root) { + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } -var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc. + flushPassiveEffects(); + var lanes; + var exitStatus; -var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown + if ( + root === workInProgressRoot && + includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes) + ) { + // There's a partial tree, and at least one of its lanes has expired. Finish + // rendering it before rendering the rest of the expired work. + lanes = workInProgressRootRenderLanes; + exitStatus = renderRootSync(root, lanes); -var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render. -// This is conceptually a time stamp but expressed in terms of an ExpirationTime -// because we deal mostly with expiration times in the hot path, so this avoids -// the conversion happening in the hot path. + if ( + includesSomeLane( + workInProgressRootIncludedLanes, + workInProgressRootUpdatedLanes + ) + ) { + // The render included lanes that were updated during the render phase. + // For example, when unhiding a hidden tree, we include all the lanes + // that were previously skipped when the tree was hidden. That set of + // lanes is a superset of the lanes we started rendering with. + // + // Note that this only happens when part of the tree is rendered + // concurrently. If the whole tree is rendered synchronously, then there + // are no interleaved events. + lanes = getNextLanes(root, lanes); + exitStatus = renderRootSync(root, lanes); + } + } else { + lanes = getNextLanes(root, NoLanes); + exitStatus = renderRootSync(root, lanes); + } -var workInProgressRootLatestProcessedExpirationTime = Sync; -var workInProgressRootLatestSuspenseTimeout = Sync; -var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only -// includes unprocessed updates, not work in bailed out children. + if (root.tag !== LegacyRoot && exitStatus === RootErrored) { + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. -var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately. -// This flag determines if it might be worthwhile to restart if an opportunity -// happens latere. + if (root.hydrate) { + root.hydrate = false; + clearContainer(root.containerInfo); + } // If something threw an error, try rendering one more time. We'll render + // synchronously to block concurrent data mutations, and we'll includes + // all pending updates are included. If it still fails after the second + // attempt, we'll give up and commit the resulting tree. -var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train -// model where we don't commit new loading states in too quick succession. + lanes = getLanesToRetrySynchronouslyOnError(root); -var globalMostRecentFallbackTime = 0; -var FALLBACK_THROTTLE_MS = 500; -var nextEffect = null; -var hasUncaughtError = false; -var firstUncaughtError = null; -var legacyErrorBoundariesThatAlreadyFailed = null; -var rootDoesHavePassiveEffects = false; -var rootWithPendingPassiveEffects = null; -var pendingPassiveEffectsRenderPriority = NoPriority; -var pendingPassiveEffectsExpirationTime = NoWork; -var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates + if (lanes !== NoLanes) { + exitStatus = renderRootSync(root, lanes); + } + } -var NESTED_UPDATE_LIMIT = 50; -var nestedUpdateCount = 0; -var rootWithNestedUpdates = null; -var NESTED_PASSIVE_UPDATE_LIMIT = 50; -var nestedPassiveUpdateCount = 0; -var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times -// during the commit phase. This enables them to be traced across components -// that spawn new work during render. E.g. hidden boundaries, suspended SSR -// hydration or SuspenseList. + if (exitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw fatalError; + } // We now have a consistent tree. Because this is a sync render, we + // will commit it even if something suspended. -var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start -// time). However, if two updates are scheduled within the same event, we -// should treat their start times as simultaneous, even if the actual clock -// time has advanced between the first and second call. -// In other words, because expiration times determine how updates are batched, -// we want all updates of like priority that occur within the same event to -// receive the same expiration time. Otherwise we get tearing. + var finishedWork = root.current.alternate; + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next + // pending level. -var currentEventTime = NoWork; -function requestCurrentTimeForUpdate() { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { - // We're inside React, so it's fine to read the actual time. - return msToExpirationTime(now()); - } // We're not inside React, so we may be in the middle of a browser event. + ensureRootIsScheduled(root, now()); + return null; +} - if (currentEventTime !== NoWork) { - // Use the same start time for all updates until we enter React again. - return currentEventTime; - } // This is the first update since React yielded. Compute a new start time. +function batchedUpdates$1(fn, a) { + var prevExecutionContext = executionContext; + executionContext |= BatchedContext; - currentEventTime = msToExpirationTime(now()); - return currentEventTime; -} -function getCurrentTime() { - return msToExpirationTime(now()); -} -function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { - var mode = fiber.mode; + try { + return fn(a); + } finally { + executionContext = prevExecutionContext; - if ((mode & BlockingMode) === NoMode) { - return Sync; + if (executionContext === NoContext) { + // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); + flushSyncCallbackQueue(); + } } +} +function flushSync(fn, a) { + var prevExecutionContext = executionContext; - var priorityLevel = getCurrentPriorityLevel(); + if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) { + { + error( + "flushSync was called from inside a lifecycle method. React cannot " + + "flush when React is already rendering. Consider moving this call to " + + "a scheduler task or micro task." + ); + } - if ((mode & ConcurrentMode) === NoMode) { - return priorityLevel === ImmediatePriority ? Sync : Batched; + return fn(a); } - if ((executionContext & RenderContext) !== NoContext) { - // Use whatever time we're already rendering - // TODO: Should there be a way to opt out, like with `runWithPriority`? - return renderExpirationTime$1; - } + executionContext |= BatchedContext; - var expirationTime; + { + try { + if (fn) { + return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); + } else { + return undefined; + } + } finally { + executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. + // Note that this will happen even if batchedUpdates is higher up + // the stack. - if (suspenseConfig !== null) { - // Compute an expiration time based on the Suspense timeout. - expirationTime = computeSuspenseExpiration( - currentTime, - suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION - ); - } else { - // Compute an expiration time based on the Scheduler priority. - switch (priorityLevel) { - case ImmediatePriority: - expirationTime = Sync; - break; + flushSyncCallbackQueue(); + } + } +} +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); + subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes); + workInProgressRootIncludedLanes = mergeLanes( + workInProgressRootIncludedLanes, + lanes + ); +} +function popRenderLanes(fiber) { + subtreeRenderLanes = subtreeRenderLanesCursor.current; + pop(subtreeRenderLanesCursor, fiber); +} - case UserBlockingPriority: - // TODO: Rename this to computeUserBlockingExpiration - expirationTime = computeInteractiveExpiration(currentTime); - break; +function prepareFreshStack(root, lanes) { + root.finishedWork = null; + root.finishedLanes = NoLanes; + var timeoutHandle = root.timeoutHandle; - case NormalPriority: - case LowPriority: - // TODO: Handle LowPriority - // TODO: Rename this to... something better. - expirationTime = computeAsyncExpiration(currentTime); - break; + if (timeoutHandle !== noTimeout) { + // The root previous suspended and scheduled a timeout to commit a fallback + // state. Now that we have additional work, cancel the timeout. + root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above - case IdlePriority: - expirationTime = Idle; - break; + cancelTimeout(timeoutHandle); + } - default: { - throw Error("Expected a valid priority level"); - } + if (workInProgress !== null) { + var interruptedWork = workInProgress.return; + + while (interruptedWork !== null) { + unwindInterruptedWork(interruptedWork); + interruptedWork = interruptedWork.return; } - } // If we're in the middle of rendering a tree, do not update at the same - // expiration time that is already rendering. - // TODO: We shouldn't have to do this if the update is on a different root. - // Refactor computeExpirationForFiber + scheduleUpdate so we have access to - // the root when we check for this condition. + } - if ( - workInProgressRoot !== null && - expirationTime === renderExpirationTime$1 - ) { - // This is a trick to move this update into a separate batch - expirationTime -= 1; + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null); + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootFatalError = null; + workInProgressRootSkippedLanes = NoLanes; + workInProgressRootUpdatedLanes = NoLanes; + workInProgressRootPingedLanes = NoLanes; + + { + spawnedWorkDuringRender = null; } - return expirationTime; + { + ReactStrictModeWarnings.discardPendingWarnings(); + } } -function scheduleUpdateOnFiber(fiber, expirationTime) { - checkForNestedUpdates(); - warnAboutRenderPhaseUpdatesInDEV(fiber); - var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); - if (root === null) { - warnAboutUpdateOnUnmountedFiberInDEV(fiber); - return; - } +function handleError(root, thrownValue) { + do { + var erroredWork = workInProgress; - checkForInterruption(fiber, expirationTime); - recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the - // priority as an argument to that function and this one. + try { + // Reset module-level state that was set during the render phase. + resetContextDependencies(); + resetHooksAfterThrow(); + resetCurrentFiber(); // TODO: I found and added this missing line while investigating a + // separate issue. Write a regression test using string refs. - var priorityLevel = getCurrentPriorityLevel(); + ReactCurrentOwner$2.current = null; - if (expirationTime === Sync) { - if ( - // Check if we're inside unbatchedUpdates - (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering - (executionContext & (RenderContext | CommitContext)) === NoContext - ) { - // Register pending interactions on the root to avoid losing traced interaction data. - schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed - // root inside of batchedUpdates should be synchronous, but layout updates - // should be deferred until the end of the batch. + if (erroredWork === null || erroredWork.return === null) { + // Expected to be working on a non-root fiber. This is a fatal error + // because there's no ancestor that can handle it; the root is + // supposed to capture all errors that weren't caught by an error + // boundary. + workInProgressRootExitStatus = RootFatalErrored; + workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next + // sibling, or the parent if there are no siblings. But since the root + // has no siblings nor a parent, we set it to null. Usually this is + // handled by `completeUnitOfWork` or `unwindWork`, but since we're + // intentionally not calling those, we need set it here. + // TODO: Consider calling `unwindWork` to pop the contexts. - performSyncWorkOnRoot(root); - } else { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, expirationTime); + workInProgress = null; + return; + } - if (executionContext === NoContext) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - flushSyncCallbackQueue(); + if (enableProfilerTimer && erroredWork.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. This + // avoids inaccurate Profiler durations in the case of a + // suspended render. + stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); } - } - } else { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, expirationTime); - } - if ( - (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered - // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority || - priorityLevel === ImmediatePriority) - ) { - // This is the result of a discrete event. Track the lowest priority - // discrete update per root so we can flush them early, if needed. - if (rootsWithPendingDiscreteUpdates === null) { - rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); - } else { - var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + throwException( + root, + erroredWork.return, + erroredWork, + thrownValue, + workInProgressRootRenderLanes + ); + completeUnitOfWork(erroredWork); + } catch (yetAnotherThrownValue) { + // Something in the return path also threw. + thrownValue = yetAnotherThrownValue; - if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) { - rootsWithPendingDiscreteUpdates.set(root, expirationTime); + if (workInProgress === erroredWork && erroredWork !== null) { + // If this boundary has already errored, then we had trouble processing + // the error. Bubble it to the next boundary. + erroredWork = erroredWork.return; + workInProgress = erroredWork; + } else { + erroredWork = workInProgress; } - } - } -} -var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending -// work without treating it as a typical update that originates from an event; -// e.g. retrying a Suspense boundary isn't an update, but it does schedule work -// on a fiber. -function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { - // Update the source fiber's expiration time - if (fiber.expirationTime < expirationTime) { - fiber.expirationTime = expirationTime; - } - - var alternate = fiber.alternate; + continue; + } // Return to the normal work loop. - if (alternate !== null && alternate.expirationTime < expirationTime) { - alternate.expirationTime = expirationTime; - } // Walk the parent path to the root and update the child expiration time. + return; + } while (true); +} - var node = fiber.return; - var root = null; +function pushDispatcher() { + var prevDispatcher = ReactCurrentDispatcher$2.current; + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; - if (node === null && fiber.tag === HostRoot) { - root = fiber.stateNode; + if (prevDispatcher === null) { + // The React isomorphic package does not include a default dispatcher. + // Instead the first renderer will lazily attach one, in order to give + // nicer error messages. + return ContextOnlyDispatcher; } else { - while (node !== null) { - alternate = node.alternate; + return prevDispatcher; + } +} - if (node.childExpirationTime < expirationTime) { - node.childExpirationTime = expirationTime; +function popDispatcher(prevDispatcher) { + ReactCurrentDispatcher$2.current = prevDispatcher; +} - if ( - alternate !== null && - alternate.childExpirationTime < expirationTime - ) { - alternate.childExpirationTime = expirationTime; - } - } else if ( - alternate !== null && - alternate.childExpirationTime < expirationTime - ) { - alternate.childExpirationTime = expirationTime; - } +function pushInteractions(root) { + { + var prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + return prevInteractions; + } +} - if (node.return === null && node.tag === HostRoot) { - root = node.stateNode; - break; - } +function popInteractions(prevInteractions) { + { + tracing.__interactionsRef.current = prevInteractions; + } +} - node = node.return; - } +function markCommitTimeOfFallback() { + globalMostRecentFallbackTime = now(); +} +function markSkippedUpdateLanes(lane) { + workInProgressRootSkippedLanes = mergeLanes( + lane, + workInProgressRootSkippedLanes + ); +} +function renderDidSuspend() { + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootSuspended; + } +} +function renderDidSuspendDelayIfPossible() { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) { + workInProgressRootExitStatus = RootSuspendedWithDelay; + } // Check if there are updates that we skipped tree that might have unblocked + // this render. + + if ( + workInProgressRoot !== null && + (includesNonIdleWork(workInProgressRootSkippedLanes) || + includesNonIdleWork(workInProgressRootUpdatedLanes)) + ) { + // Mark the current render as suspended so that we switch to working on + // the updates that were skipped. Usually we only suspend at the end of + // the render phase. + // TODO: We should probably always mark the root as suspended immediately + // (inside this function), since by suspending at the end of the render + // phase introduces a potential mistake where we suspend lanes that were + // pinged or updated while we were rendering. + markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); } - - if (root !== null) { - if (workInProgressRoot === root) { - // Received an update to a tree that's in the middle of rendering. Mark - // that's unprocessed work on this root. - markUnprocessedUpdateTime(expirationTime); - - if (workInProgressRootExitStatus === RootSuspendedWithDelay) { - // The root already suspended with a delay, which means this render - // definitely won't finish. Since we have a new update, let's mark it as - // suspended now, right before marking the incoming update. This has the - // effect of interrupting the current render and switching to the update. - // TODO: This happens to work when receiving an update during the render - // phase, because of the trick inside computeExpirationForFiber to - // subtract 1 from `renderExpirationTime` to move it into a - // separate bucket. But we should probably model it with an exception, - // using the same mechanism we use to force hydration of a subtree. - // TODO: This does not account for low pri updates that were already - // scheduled before the root started rendering. Need to track the next - // pending expiration time (perhaps by backtracking the return path) and - // then trigger a restart in the `renderDidSuspendDelayIfPossible` path. - markRootSuspendedAtTime(root, renderExpirationTime$1); - } - } // Mark that the root has a pending update. - - markRootUpdatedAtTime(root, expirationTime); +} +function renderDidError() { + if (workInProgressRootExitStatus !== RootCompleted) { + workInProgressRootExitStatus = RootErrored; } +} // Called during render to determine if anything has suspended. +// Returns false if we're not sure. - return root; +function renderHasNotSuspendedYet() { + // If something errored or completed, we can't really be sure, + // so those are false. + return workInProgressRootExitStatus === RootIncomplete; } -function getNextRootExpirationTimeToWorkOn(root) { - // Determines the next expiration time that the root should render, taking - // into account levels that may be suspended, or levels that may have - // received a ping. - var lastExpiredTime = root.lastExpiredTime; - - if (lastExpiredTime !== NoWork) { - return lastExpiredTime; - } // "Pending" refers to any update that hasn't committed yet, including if it - // suspended. The "suspended" range is therefore a subset. +function renderRootSync(root, lanes) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - var firstPendingTime = root.firstPendingTime; + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + prepareFreshStack(root, lanes); + startWorkOnPendingInteractions(root, lanes); + } - if (!isRootSuspendedAtTime(root, firstPendingTime)) { - // The highest priority pending time is not suspended. Let's work on that. - return firstPendingTime; - } // If the first pending time is suspended, check if there's a lower priority - // pending level that we know about. Or check if we received a ping. Work - // on whichever is higher priority. + var prevInteractions = pushInteractions(root); - var lastPingedTime = root.lastPingedTime; - var nextKnownPendingLevel = root.nextKnownPendingLevel; - var nextLevel = - lastPingedTime > nextKnownPendingLevel - ? lastPingedTime - : nextKnownPendingLevel; + do { + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + } while (true); - if (nextLevel <= Idle && firstPendingTime !== nextLevel) { - // Don't work on Idle/Never priority unless everything else is committed. - return NoWork; - } + resetContextDependencies(); - return nextLevel; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the -// expiration time of the existing task is the same as the expiration time of -// the next level that the root has work on. This function is called on every -// update, and right before exiting a task. - -function ensureRootIsScheduled(root) { - var lastExpiredTime = root.lastExpiredTime; - - if (lastExpiredTime !== NoWork) { - // Special case: Expired work should flush synchronously. - root.callbackExpirationTime = Sync; - root.callbackPriority = ImmediatePriority; - root.callbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - ); - return; + { + popInteractions(prevInteractions); } - var expirationTime = getNextRootExpirationTimeToWorkOn(root); - var existingCallbackNode = root.callbackNode; + executionContext = prevExecutionContext; + popDispatcher(prevDispatcher); - if (expirationTime === NoWork) { - // There's nothing to work on. - if (existingCallbackNode !== null) { - root.callbackNode = null; - root.callbackExpirationTime = NoWork; - root.callbackPriority = NoPriority; + if (workInProgress !== null) { + // This is a sync render, so we should have finished the whole tree. + { + throw Error( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); } + } - return; - } // TODO: If this is an update, we already read the current time. Pass the - // time as an argument. + workInProgressRoot = null; + workInProgressRootRenderLanes = NoLanes; + return workInProgressRootExitStatus; +} // The work loop is an extremely hot path. Tell Closure not to inline it. - var currentTime = requestCurrentTimeForUpdate(); - var priorityLevel = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); // If there's an existing render task, confirm it has the correct priority and - // expiration time. Otherwise, we'll cancel it and schedule a new one. +/** @noinline */ - if (existingCallbackNode !== null) { - var existingCallbackPriority = root.callbackPriority; - var existingCallbackExpirationTime = root.callbackExpirationTime; +function workLoopSync() { + // Already timed out, so perform work without checking if we need to yield. + while (workInProgress !== null) { + performUnitOfWork(workInProgress); + } +} - if ( - // Callback must have the exact same expiration time. - existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. - existingCallbackPriority >= priorityLevel - ) { - // Existing callback is sufficient. - return; - } // Need to schedule a new task. - // TODO: Instead of scheduling a new task, we should be able to change the - // priority of the existing one. +function renderRootConcurrent(root, lanes) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. - cancelCallback(existingCallbackNode); + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + resetRenderTimer(); + prepareFreshStack(root, lanes); + startWorkOnPendingInteractions(root, lanes); } - root.callbackExpirationTime = expirationTime; - root.callbackPriority = priorityLevel; - var callbackNode; + var prevInteractions = pushInteractions(root); - if (expirationTime === Sync) { - // Sync React callbacks are scheduled on a special internal queue - callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - callbackNode = scheduleCallback( - priorityLevel, - performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects - // ordering because tasks are processed in timeout order. - { - timeout: expirationTimeToMs(expirationTime) - now() - } - ); - } + do { + try { + workLoopConcurrent(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + } while (true); - root.callbackNode = callbackNode; -} // This is the entry point for every concurrent task, i.e. anything that -// goes through Scheduler. + resetContextDependencies(); -function performConcurrentWorkOnRoot(root, didTimeout) { - // Since we know we're in a React event, we can clear the current - // event time. The next update will compute a new event time. - currentEventTime = NoWork; // Check if the render expired. + { + popInteractions(prevInteractions); + } - if (didTimeout) { - // The render task took too long to complete. Mark the current time as - // expired to synchronously render all expired work in a single batch. - var currentTime = requestCurrentTimeForUpdate(); - markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback. + popDispatcher(prevDispatcher); + executionContext = prevExecutionContext; - ensureRootIsScheduled(root); - return null; - } // Determine the next expiration time to work on, using the fields stored - // on the root. + if (workInProgress !== null) { + return RootIncomplete; + } else { + workInProgressRoot = null; + workInProgressRootRenderLanes = NoLanes; // Return the final exit status. - var expirationTime = getNextRootExpirationTimeToWorkOn(root); + return workInProgressRootExitStatus; + } +} +/** @noinline */ - if (expirationTime === NoWork) { - return null; +function workLoopConcurrent() { + // Perform work until Scheduler asks us to yield + while (workInProgress !== null && !shouldYield()) { + performUnitOfWork(workInProgress); } +} - var originalCallbackNode = root.callbackNode; +function performUnitOfWork(unitOfWork) { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current = unitOfWork.alternate; + setCurrentFiber(unitOfWork); + var next; - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if ((unitOfWork.mode & ProfileMode) !== NoMode) { + startProfilerTimer(unitOfWork); + next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + } else { + next = beginWork$1(current, unitOfWork, subtreeRenderLanes); } - flushPassiveEffects(); - var exitStatus = renderRootConcurrent(root, expirationTime); + resetCurrentFiber(); + unitOfWork.memoizedProps = unitOfWork.pendingProps; - if (exitStatus !== RootIncomplete) { - if (exitStatus === RootErrored) { - // If something threw an error, try rendering one more time. We'll - // render synchronously to block concurrent data mutations, and we'll - // render at Idle (or lower) so that all pending updates are included. - // If it still fails after the second attempt, we'll give up and commit - // the resulting tree. - expirationTime = expirationTime > Idle ? Idle : expirationTime; - exitStatus = renderRootSync(root, expirationTime); - } + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } - if (exitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } // We now have a consistent tree. The next step is either to commit it, - // or, if something suspended, wait to commit it after a timeout. + ReactCurrentOwner$2.current = null; +} - var finishedWork = (root.finishedWork = root.current.alternate); - root.finishedExpirationTime = expirationTime; - finishConcurrentRender(root, finishedWork, exitStatus, expirationTime); - } +function completeUnitOfWork(unitOfWork) { + // Attempt to complete the current unit of work, then move to the next + // sibling. If there are no more siblings, return to the parent fiber. + var completedWork = unitOfWork; - ensureRootIsScheduled(root); + do { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current = completedWork.alternate; + var returnFiber = completedWork.return; // Check if the work completed or if something threw. - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } + if ((completedWork.flags & Incomplete) === NoFlags) { + setCurrentFiber(completedWork); + var next = void 0; - return null; -} + if ((completedWork.mode & ProfileMode) === NoMode) { + next = completeWork(current, completedWork, subtreeRenderLanes); + } else { + startProfilerTimer(completedWork); + next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error. -function finishConcurrentRender( - root, - finishedWork, - exitStatus, - expirationTime -) { - switch (exitStatus) { - case RootIncomplete: - case RootFatalErrored: { - { - throw Error("Root did not complete. This is a bug in React."); + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - } - // Flow knows about invariant, so it complains if I add a break - // statement, but eslint doesn't know about invariant, so it complains - // if I do. eslint-disable-next-line no-fallthrough - - case RootErrored: { - // We should have already attempted to retry this tree. If we reached - // this point, it errored again. Commit it. - commitRoot(root); - break; - } - case RootSuspended: { - markRootSuspendedAtTime(root, expirationTime); - var lastSuspendedTime = root.lastSuspendedTime; + resetCurrentFiber(); - if (expirationTime === lastSuspendedTime) { - root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); - } // We have an acceptable loading state. We need to figure out if we - // should immediately commit it or wait a bit. - // If we have processed new updates during this render, we may now - // have a new loading state ready. We want to ensure that we commit - // that as soon as possible. + if (next !== null) { + // Completing this fiber spawned new work. Work on that next. + workInProgress = next; + return; + } - var hasNotProcessedNewUpdates = - workInProgressRootLatestProcessedExpirationTime === Sync; + resetChildLanes(completedWork); if ( - hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope - !IsThisRendererActing.current + returnFiber !== null && // Do not append effects to parents if a sibling failed to complete + (returnFiber.flags & Incomplete) === NoFlags ) { - // If we have not processed any new updates during this pass, then - // this is either a retry of an existing fallback state or a - // hidden tree. Hidden trees shouldn't be batched with other work - // and after that's fixed it can only be a retry. We're going to - // throttle committing retries so that we don't show too many - // loading states too quickly. - var msUntilTimeout = - globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. + // Append all the effects of the subtree and this fiber onto the effect + // list of the parent. The completion order of the children affects the + // side-effect order. + if (returnFiber.firstEffect === null) { + returnFiber.firstEffect = completedWork.firstEffect; + } - if (msUntilTimeout > 10) { - if (workInProgressRootHasPendingPing) { - var lastPingedTime = root.lastPingedTime; - - if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) { - // This render was pinged but we didn't get to restart - // earlier so try restarting now instead. - root.lastPingedTime = expirationTime; - prepareFreshStack(root, expirationTime); - break; - } + if (completedWork.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork.firstEffect; } - var nextTime = getNextRootExpirationTimeToWorkOn(root); + returnFiber.lastEffect = completedWork.lastEffect; + } // If this fiber had side-effects, we append it AFTER the children's + // side-effects. We can perform certain side-effects earlier if needed, + // by doing multiple passes over the effect list. We don't want to + // schedule our own side-effect on our own list because if end up + // reusing children we'll schedule this effect onto itself since we're + // at the end. + + var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect + // list. PerformedWork effect is read by React DevTools but shouldn't be + // committed. - if (nextTime !== NoWork && nextTime !== expirationTime) { - // There's additional work on this root. - break; + if (flags > PerformedWork) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork; + } else { + returnFiber.firstEffect = completedWork; } - if ( - lastSuspendedTime !== NoWork && - lastSuspendedTime !== expirationTime - ) { - // We should prefer to render the fallback of at the last - // suspended level. Ping the last suspended level to try - // rendering it again. - root.lastPingedTime = lastSuspendedTime; - break; - } // The render is suspended, it hasn't timed out, and there's no - // lower priority work to do. Instead of committing the fallback - // immediately, wait for more data to arrive. - - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - msUntilTimeout - ); - break; + returnFiber.lastEffect = completedWork; } - } // The work expired. Commit immediately. + } + } else { + // This fiber did not complete because something threw. Pop values off + // the stack without entering the complete phase. If this is a boundary, + // capture values if possible. + var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time. - commitRoot(root); - break; - } + if (_next !== null) { + // If completing this work spawned new work, do that next. We'll come + // back here again. + // Since we're restarting, remove anything that is not a host effect + // from the effect tag. + _next.flags &= HostEffectMask; + workInProgress = _next; + return; + } - case RootSuspendedWithDelay: { - markRootSuspendedAtTime(root, expirationTime); - var _lastSuspendedTime = root.lastSuspendedTime; + if ((completedWork.mode & ProfileMode) !== NoMode) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing. - if (expirationTime === _lastSuspendedTime) { - root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); - } + var actualDuration = completedWork.actualDuration; + var child = completedWork.child; - { - // We're suspended in a state that should be avoided. We'll try to - // avoid committing it for as long as the timeouts let us. - if (workInProgressRootHasPendingPing) { - var _lastPingedTime = root.lastPingedTime; - - if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) { - // This render was pinged but we didn't get to restart earlier - // so try restarting now instead. - root.lastPingedTime = expirationTime; - prepareFreshStack(root, expirationTime); - break; - } + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; } - var _nextTime = getNextRootExpirationTimeToWorkOn(root); + completedWork.actualDuration = actualDuration; + } - if (_nextTime !== NoWork && _nextTime !== expirationTime) { - // There's additional work on this root. - break; - } + if (returnFiber !== null) { + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; + returnFiber.flags |= Incomplete; + } + } - if ( - _lastSuspendedTime !== NoWork && - _lastSuspendedTime !== expirationTime - ) { - // We should prefer to render the fallback of at the last - // suspended level. Ping the last suspended level to try - // rendering it again. - root.lastPingedTime = _lastSuspendedTime; - break; - } + var siblingFiber = completedWork.sibling; - var _msUntilTimeout; - - if (workInProgressRootLatestSuspenseTimeout !== Sync) { - // We have processed a suspense config whose expiration time we - // can use as the timeout. - _msUntilTimeout = - expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now(); - } else if (workInProgressRootLatestProcessedExpirationTime === Sync) { - // This should never normally happen because only new updates - // cause delayed states, so we should have processed something. - // However, this could also happen in an offscreen tree. - _msUntilTimeout = 0; - } else { - // If we don't have a suspense config, we're going to use a - // heuristic to determine how long we can suspend. - var eventTimeMs = inferTimeFromExpirationTime( - workInProgressRootLatestProcessedExpirationTime - ); - var currentTimeMs = now(); - var timeUntilExpirationMs = - expirationTimeToMs(expirationTime) - currentTimeMs; - var timeElapsed = currentTimeMs - eventTimeMs; - - if (timeElapsed < 0) { - // We get this wrong some time since we estimate the time. - timeElapsed = 0; - } + if (siblingFiber !== null) { + // If there is more work to do in this returnFiber, do that next. + workInProgress = siblingFiber; + return; + } // Otherwise, return to the parent - _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the - // event time is exact instead of inferred from expiration time - // we don't need this. + completedWork = returnFiber; // Update the next thing we're working on in case something throws. - if (timeUntilExpirationMs < _msUntilTimeout) { - _msUntilTimeout = timeUntilExpirationMs; - } - } // Don't bother with a very short suspense time. + workInProgress = completedWork; + } while (completedWork !== null); // We've reached the root. - if (_msUntilTimeout > 10) { - // The render is suspended, it hasn't timed out, and there's no - // lower priority work to do. Instead of committing the fallback - // immediately, wait for more data to arrive. - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - _msUntilTimeout - ); - break; - } - } // The work expired. Commit immediately. + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootCompleted; + } +} - commitRoot(root); - break; - } +function resetChildLanes(completedWork) { + if ( + // TODO: Move this check out of the hot path by moving `resetChildLanes` + // to switch statement in `completeWork`. + (completedWork.tag === LegacyHiddenComponent || + completedWork.tag === OffscreenComponent) && + completedWork.memoizedState !== null && + !includesSomeLane(subtreeRenderLanes, OffscreenLane) && + (completedWork.mode & ConcurrentMode) !== NoLanes + ) { + // The children of this component are hidden. Don't bubble their + // expiration times. + return; + } - case RootCompleted: { - // The work completed. Ready to commit. - if ( - // do not delay if we're inside an act() scope - workInProgressRootLatestProcessedExpirationTime !== Sync && - workInProgressRootCanSuspendUsingConfig !== null - ) { - // If we have exceeded the minimum loading delay, which probably - // means we have shown a spinner already, we might have to suspend - // a bit longer to ensure that the spinner is shown for - // enough time. - var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay( - workInProgressRootLatestProcessedExpirationTime, - expirationTime, - workInProgressRootCanSuspendUsingConfig - ); + var newChildLanes = NoLanes; // Bubble up the earliest expiration time. - if (_msUntilTimeout2 > 10) { - markRootSuspendedAtTime(root, expirationTime); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - _msUntilTimeout2 - ); - break; - } - } + if ((completedWork.mode & ProfileMode) !== NoMode) { + // In profiling mode, resetChildExpirationTime is also used to reset + // profiler durations. + var actualDuration = completedWork.actualDuration; + var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will + // only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. If + // the fiber has not been cloned though, (meaning no work was done), then + // this value will reflect the amount of time spent working on a previous + // render. In that case it should not bubble. We determine whether it was + // cloned by comparing the child pointer. - commitRoot(root); - break; - } + var shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + var child = completedWork.child; - default: { - { - throw Error("Unknown root exit status."); + while (child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(child.lanes, child.childLanes) + ); + + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; } + + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; } - } -} // This is the entry point for synchronous tasks that don't go -// through Scheduler -function performSyncWorkOnRoot(root) { - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } + var isTimedOutSuspense = + completedWork.tag === SuspenseComponent && + completedWork.memoizedState !== null; - flushPassiveEffects(); - var lastExpiredTime = root.lastExpiredTime; - var expirationTime; + if (isTimedOutSuspense) { + // Don't count time spent in a timed out Suspense subtree as part of the base duration. + var primaryChildFragment = completedWork.child; - if (lastExpiredTime !== NoWork) { - // There's expired work on this root. Check if we have a partial tree - // that we can reuse. - if ( - root === workInProgressRoot && - renderExpirationTime$1 >= lastExpiredTime - ) { - // There's a partial tree with equal or greater than priority than the - // expired level. Finish rendering it before rendering the rest of the - // expired work. - expirationTime = renderExpirationTime$1; - } else { - // Start a fresh tree. - expirationTime = lastExpiredTime; + if (primaryChildFragment !== null) { + treeBaseDuration -= primaryChildFragment.treeBaseDuration; + } } - } else { - // There's no expired work. This must be a new, synchronous render. - expirationTime = Sync; - } - var exitStatus = renderRootSync(root, expirationTime); + completedWork.actualDuration = actualDuration; + completedWork.treeBaseDuration = treeBaseDuration; + } else { + var _child = completedWork.child; - if (root.tag !== LegacyRoot && exitStatus === RootErrored) { - // If something threw an error, try rendering one more time. We'll - // render synchronously to block concurrent data mutations, and we'll - // render at Idle (or lower) so that all pending updates are included. - // If it still fails after the second attempt, we'll give up and commit - // the resulting tree. - expirationTime = expirationTime > Idle ? Idle : expirationTime; - exitStatus = renderRootSync(root, expirationTime); + while (_child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(_child.lanes, _child.childLanes) + ); + _child = _child.sibling; + } } - if (exitStatus === RootFatalErrored) { - var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, expirationTime); - markRootSuspendedAtTime(root, expirationTime); - ensureRootIsScheduled(root); - throw fatalError; - } // We now have a consistent tree. Because this is a sync render, we - // will commit it even if something suspended. - - root.finishedWork = root.current.alternate; - root.finishedExpirationTime = expirationTime; - commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next - // pending level. + completedWork.childLanes = newChildLanes; +} - ensureRootIsScheduled(root); +function commitRoot(root) { + var renderPriorityLevel = getCurrentPriorityLevel(); + runWithPriority( + ImmediatePriority$1, + commitRootImpl.bind(null, root, renderPriorityLevel) + ); return null; } -function syncUpdates(fn, a, b, c) { - return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c)); -} -function batchedUpdates$1(fn, a) { - var prevExecutionContext = executionContext; - executionContext |= BatchedContext; +function commitRootImpl(root, renderPriorityLevel) { + do { + // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which + // means `flushPassiveEffects` will sometimes result in additional + // passive effects. So we need to keep flushing in a loop until there are + // no more pending effects. + // TODO: Might be better if `flushPassiveEffects` did not automatically + // flush synchronous work at the end, to avoid factoring hazards like this. + flushPassiveEffects(); + } while (rootWithPendingPassiveEffects !== null); - try { - return fn(a); - } finally { - executionContext = prevExecutionContext; + flushRenderPhaseStrictModeWarningsInDEV(); - if (executionContext === NoContext) { - // Flush the immediate callbacks that were scheduled during this batch - flushSyncCallbackQueue(); - } - } -} -function flushSync(fn, a) { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { - { - throw Error( - "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." - ); - } + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); } - var prevExecutionContext = executionContext; - executionContext |= BatchedContext; - - try { - return runWithPriority(ImmediatePriority, fn.bind(null, a)); - } finally { - executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. - // Note that this will happen even if batchedUpdates is higher up - // the stack. + var finishedWork = root.finishedWork; + var lanes = root.finishedLanes; - flushSyncCallbackQueue(); + if (finishedWork === null) { + return null; } -} -function prepareFreshStack(root, expirationTime) { root.finishedWork = null; - root.finishedExpirationTime = NoWork; - var timeoutHandle = root.timeoutHandle; + root.finishedLanes = NoLanes; - if (timeoutHandle !== noTimeout) { - // The root previous suspended and scheduled a timeout to commit a fallback - // state. Now that we have additional work, cancel the timeout. - root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above + if (!(finishedWork !== root.current)) { + throw Error( + "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." + ); + } // commitRoot never returns a continuation; it always finishes synchronously. + // So we can clear these now to allow a new callback to be scheduled. - cancelTimeout(timeoutHandle); - } + root.callbackNode = null; // Update the first and last pending times on this root. The new first + // pending time is whatever is left on the root fiber. - if (workInProgress !== null) { - var interruptedWork = workInProgress.return; + var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); + markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of + // `flushDiscreteUpdates` starts a useless render pass which may cancels + // a scheduled timeout. - while (interruptedWork !== null) { - unwindInterruptedWork(interruptedWork); - interruptedWork = interruptedWork.return; + if (rootsWithPendingDiscreteUpdates !== null) { + if ( + !hasDiscreteLanes(remainingLanes) && + rootsWithPendingDiscreteUpdates.has(root) + ) { + rootsWithPendingDiscreteUpdates.delete(root); } } - workInProgressRoot = root; - workInProgress = createWorkInProgress(root.current, null); - renderExpirationTime$1 = expirationTime; - workInProgressRootExitStatus = RootIncomplete; - workInProgressRootFatalError = null; - workInProgressRootLatestProcessedExpirationTime = Sync; - workInProgressRootLatestSuspenseTimeout = Sync; - workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootNextUnprocessedUpdateTime = NoWork; - workInProgressRootHasPendingPing = false; + if (root === workInProgressRoot) { + // We can reset these now that they are finished. + workInProgressRoot = null; + workInProgress = null; + workInProgressRootRenderLanes = NoLanes; + } // Get the list of effects. - { - spawnedWorkDuringRender = null; - } + var firstEffect; - { - ReactStrictModeWarnings.discardPendingWarnings(); + if (finishedWork.flags > PerformedWork) { + // A fiber's effect list consists only of its children, not itself. So if + // the root has an effect, we need to add it to the end of the list. The + // resulting list is the set that would belong to the root's parent, if it + // had one; that is, all the effects in the tree including the root. + if (finishedWork.lastEffect !== null) { + finishedWork.lastEffect.nextEffect = finishedWork; + firstEffect = finishedWork.firstEffect; + } else { + firstEffect = finishedWork; + } + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; } -} -function handleError(root, thrownValue) { - do { - try { - // Reset module-level state that was set during the render phase. - resetContextDependencies(); - resetHooksAfterThrow(); - resetCurrentFiber(); + if (firstEffect !== null) { + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles - if (workInProgress === null || workInProgress.return === null) { - // Expected to be working on a non-root fiber. This is a fatal error - // because there's no ancestor that can handle it; the root is - // supposed to capture all errors that weren't caught by an error - // boundary. - workInProgressRootExitStatus = RootFatalErrored; - workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next - // sibling, or the parent if there are no siblings. But since the root - // has no siblings nor a parent, we set it to null. Usually this is - // handled by `completeUnitOfWork` or `unwindWork`, but since we're - // interntionally not calling those, we need set it here. - // TODO: Consider calling `unwindWork` to pop the contexts. + ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass + // of the effect list for each phase: all mutation effects come before all + // layout effects, and so on. + // The first phase a "before mutation" phase. We use this phase to read the + // state of the host tree right before we mutate it. This is where + // getSnapshotBeforeUpdate is called. - workInProgress = null; - return null; - } + focusedInstanceHandle = prepareForCommit(root.containerInfo); + shouldFireAfterActiveInstanceBlur = false; + nextEffect = firstEffect; - if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // Record the time spent rendering before an error was thrown. This - // avoids inaccurate Profiler durations in the case of a - // suspended render. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); - } + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); - throwException( - root, - workInProgress.return, - workInProgress, - thrownValue, - renderExpirationTime$1 - ); - workInProgress = completeUnitOfWork(workInProgress); - } catch (yetAnotherThrownValue) { - // Something in the return path also threw. - thrownValue = yetAnotherThrownValue; - continue; - } // Return to the normal work loop. + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } + + var error = clearCaughtError(); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); // We no longer need to track the active instance fiber - return; - } while (true); -} + focusedInstanceHandle = null; -function pushDispatcher(root) { - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + { + // Mark the current commit time to be shared by all Profilers in this + // batch. This enables them to be grouped later. + recordCommitTime(); + } // The next phase is the mutation phase, where we mutate the host tree. - if (prevDispatcher === null) { - // The React isomorphic package does not include a default dispatcher. - // Instead the first renderer will lazily attach one, in order to give - // nicer error messages. - return ContextOnlyDispatcher; - } else { - return prevDispatcher; - } -} + nextEffect = firstEffect; -function popDispatcher(prevDispatcher) { - ReactCurrentDispatcher$1.current = prevDispatcher; -} + do { + { + invokeGuardedCallback( + null, + commitMutationEffects, + null, + root, + renderPriorityLevel + ); -function pushInteractions(root) { - { - var prevInteractions = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - return prevInteractions; - } -} + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } -function popInteractions(prevInteractions) { - { - tracing.__interactionsRef.current = prevInteractions; - } -} + var _error = clearCaughtError(); -function markCommitTimeOfFallback() { - globalMostRecentFallbackTime = now(); -} -function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { - if ( - expirationTime < workInProgressRootLatestProcessedExpirationTime && - expirationTime > Idle - ) { - workInProgressRootLatestProcessedExpirationTime = expirationTime; - } + captureCommitPhaseError(nextEffect, _error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); - if (suspenseConfig !== null) { - if ( - expirationTime < workInProgressRootLatestSuspenseTimeout && - expirationTime > Idle - ) { - workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad. + resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after + // the mutation phase, so that the previous tree is still current during + // componentWillUnmount, but before the layout phase, so that the finished + // work is current during componentDidMount/Update. - workInProgressRootCanSuspendUsingConfig = suspenseConfig; - } - } -} -function markUnprocessedUpdateTime(expirationTime) { - if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) { - workInProgressRootNextUnprocessedUpdateTime = expirationTime; - } -} -function renderDidSuspend() { - if (workInProgressRootExitStatus === RootIncomplete) { - workInProgressRootExitStatus = RootSuspended; - } -} -function renderDidSuspendDelayIfPossible() { - if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended - ) { - workInProgressRootExitStatus = RootSuspendedWithDelay; - } // Check if there's a lower priority update somewhere else in the tree. + root.current = finishedWork; // The next phase is the layout phase, where we call effects that read + // the host tree after it's been mutated. The idiomatic use case for this is + // layout, but class component lifecycles also fire here for legacy reasons. - if ( - workInProgressRootNextUnprocessedUpdateTime !== NoWork && - workInProgressRoot !== null - ) { - // Mark the current render as suspended, and then mark that there's a - // pending update. - // TODO: This should immediately interrupt the current render, instead - // of waiting until the next time we yield. - markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1); - markRootUpdatedAtTime( - workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - ); - } -} -function renderDidError() { - if (workInProgressRootExitStatus !== RootCompleted) { - workInProgressRootExitStatus = RootErrored; - } -} // Called during render to determine if anything has suspended. -// Returns false if we're not sure. + nextEffect = firstEffect; -function renderHasNotSuspendedYet() { - // If something errored or completed, we can't really be sure, - // so those are false. - return workInProgressRootExitStatus === RootIncomplete; -} + do { + { + invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); -function inferTimeFromExpirationTime(expirationTime) { - // We don't know exactly when the update was scheduled, but we can infer an - // approximate start time from the expiration time. - var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); - return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; -} + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } -function inferTimeFromExpirationTimeWithSuspenseConfig( - expirationTime, - suspenseConfig -) { - // We don't know exactly when the update was scheduled, but we can infer an - // approximate start time from the expiration time by subtracting the timeout - // that was added to the event time. - var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); - return ( - earliestExpirationTimeMs - - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION) - ); -} + var _error2 = clearCaughtError(); -function renderRootSync(root, expirationTime) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. + captureCommitPhaseError(nextEffect, _error2); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime$1 - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); - } + nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an + // opportunity to paint. - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + requestPaint(); - do { - try { - workLoopSync(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); + { + popInteractions(prevInteractions); } - } while (true); - - resetContextDependencies(); - - { - popInteractions(prevInteractions); - } - executionContext = prevExecutionContext; - popDispatcher(prevDispatcher); + executionContext = prevExecutionContext; + } else { + // No effects. + root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were + // no effects. + // TODO: Maybe there's a better way to report this. - if (workInProgress !== null) { - // This is a sync render, so we should have finished the whole tree. { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); + recordCommitTime(); } } - stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. - - workInProgressRoot = null; - return workInProgressRootExitStatus; -} // The work loop is an extremely hot path. Tell Closure not to inline it. - -/** @noinline */ - -function workLoopSync() { - // Already timed out, so perform work without checking if we need to yield. - while (workInProgress !== null) { - workInProgress = performUnitOfWork(workInProgress); - } -} + var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; -function renderRootConcurrent(root, expirationTime) { - var prevExecutionContext = executionContext; - executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack - // and prepare a fresh one. Otherwise we'll continue where we left off. + if (rootDoesHavePassiveEffects) { + // This commit has passive effects. Stash a reference to them. But don't + // schedule a callback until after flushing layout work. + rootDoesHavePassiveEffects = false; + rootWithPendingPassiveEffects = root; + pendingPassiveEffectsLanes = lanes; + pendingPassiveEffectsRenderPriority = renderPriorityLevel; + } else { + // We are done with the effect chain at this point so let's clear the + // nextEffect pointers to assist with GC. If we have passive effects, we'll + // clear this in flushPassiveEffects. + nextEffect = firstEffect; - if ( - root !== workInProgressRoot || - expirationTime !== renderExpirationTime$1 - ) { - prepareFreshStack(root, expirationTime); - startWorkOnPendingInteractions(root, expirationTime); - } + while (nextEffect !== null) { + var nextNextEffect = nextEffect.nextEffect; + nextEffect.nextEffect = null; - var prevInteractions = pushInteractions(root); - startWorkLoopTimer(workInProgress); + if (nextEffect.flags & Deletion) { + detachFiberAfterEffects(nextEffect); + } - do { - try { - workLoopConcurrent(); - break; - } catch (thrownValue) { - handleError(root, thrownValue); + nextEffect = nextNextEffect; } - } while (true); + } // Read this again, since an effect might have updated it - resetContextDependencies(); + remainingLanes = root.pendingLanes; // Check if there's remaining work on this root - { - popInteractions(prevInteractions); - } + if (remainingLanes !== NoLanes) { + { + if (spawnedWorkDuringRender !== null) { + var expirationTimes = spawnedWorkDuringRender; + spawnedWorkDuringRender = null; - popDispatcher(prevDispatcher); - executionContext = prevExecutionContext; // Check if the tree has completed. + for (var i = 0; i < expirationTimes.length; i++) { + scheduleInteractions( + root, + expirationTimes[i], + root.memoizedInteractions + ); + } + } - if (workInProgress !== null) { - // Still work remaining. - stopInterruptedWorkLoopTimer(); - return RootIncomplete; + schedulePendingInteractions(root, remainingLanes); + } } else { - // Completed the tree. - stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. - - workInProgressRoot = null; // Return the final exit status. - - return workInProgressRootExitStatus; + // If there's no remaining work, we can clear the set of already failed + // error boundaries. + legacyErrorBoundariesThatAlreadyFailed = null; } -} -/** @noinline */ -function workLoopConcurrent() { - // Perform work until Scheduler asks us to yield - while (workInProgress !== null && !shouldYield()) { - workInProgress = performUnitOfWork(workInProgress); + { + if (!rootDidHavePassiveEffects) { + // If there are no passive effects, then we can complete the pending interactions. + // Otherwise, we'll wait until after the passive effects are flushed. + // Wait to do this until after remaining work has been scheduled, + // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. + finishPendingInteractions(root, lanes); + } } -} - -function performUnitOfWork(unitOfWork) { - // The current, flushed, state of this fiber is the alternate. Ideally - // nothing should rely on this, but relying on it here means that we don't - // need an additional field on the work in progress. - var current = unitOfWork.alternate; - startWorkTimer(unitOfWork); - setCurrentFiber(unitOfWork); - var next; - if ((unitOfWork.mode & ProfileMode) !== NoMode) { - startProfilerTimer(unitOfWork); - next = beginWork$1(current, unitOfWork, renderExpirationTime$1); - stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + if (remainingLanes === SyncLane) { + // Count the number of times the root synchronously re-renders without + // finishing. If there are too many, it indicates an infinite update loop. + if (root === rootWithNestedUpdates) { + nestedUpdateCount++; + } else { + nestedUpdateCount = 0; + rootWithNestedUpdates = root; + } } else { - next = beginWork$1(current, unitOfWork, renderExpirationTime$1); - } - - resetCurrentFiber(); - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - next = completeUnitOfWork(unitOfWork); + nestedUpdateCount = 0; } - ReactCurrentOwner$2.current = null; - return next; -} + onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + // additional work on this root is scheduled. -function completeUnitOfWork(unitOfWork) { - // Attempt to complete the current unit of work, then move to the next - // sibling. If there are no more siblings, return to the parent fiber. - workInProgress = unitOfWork; + ensureRootIsScheduled(root, now()); - do { - // The current, flushed, state of this fiber is the alternate. Ideally - // nothing should rely on this, but relying on it here means that we don't - // need an additional field on the work in progress. - var current = workInProgress.alternate; - var returnFiber = workInProgress.return; // Check if the work completed or if something threw. + if (hasUncaughtError) { + hasUncaughtError = false; + var _error3 = firstUncaughtError; + firstUncaughtError = null; + throw _error3; + } - if ((workInProgress.effectTag & Incomplete) === NoEffect) { - setCurrentFiber(workInProgress); - var next = void 0; + if ((executionContext & LegacyUnbatchedContext) !== NoContext) { + // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired + // synchronously, but layout updates should be deferred until the end + // of the batch. - if ((workInProgress.mode & ProfileMode) === NoMode) { - next = completeWork(current, workInProgress, renderExpirationTime$1); - } else { - startProfilerTimer(workInProgress); - next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error. + return null; + } // If layout work was scheduled, flush it now. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); - } + flushSyncCallbackQueue(); - stopWorkTimer(workInProgress); - resetCurrentFiber(); - resetChildExpirationTime(workInProgress); + return null; +} - if (next !== null) { - // Completing this fiber spawned new work. Work on that next. - return next; - } +function commitBeforeMutationEffects() { + while (nextEffect !== null) { + var current = nextEffect.alternate; - if ( - returnFiber !== null && // Do not append effects to parents if a sibling failed to complete - (returnFiber.effectTag & Incomplete) === NoEffect - ) { - // Append all the effects of the subtree and this fiber onto the effect - // list of the parent. The completion order of the children affects the - // side-effect order. - if (returnFiber.firstEffect === null) { - returnFiber.firstEffect = workInProgress.firstEffect; + if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { + if ((nextEffect.flags & Deletion) !== NoFlags) { + if (doesFiberContain(nextEffect, focusedInstanceHandle)) { + shouldFireAfterActiveInstanceBlur = true; } - - if (workInProgress.lastEffect !== null) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; - } - - returnFiber.lastEffect = workInProgress.lastEffect; - } // If this fiber had side-effects, we append it AFTER the children's - // side-effects. We can perform certain side-effects earlier if needed, - // by doing multiple passes over the effect list. We don't want to - // schedule our own side-effect on our own list because if end up - // reusing children we'll schedule this effect onto itself since we're - // at the end. - - var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect - // list. PerformedWork effect is read by React DevTools but shouldn't be - // committed. - - if (effectTag > PerformedWork) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress; - } else { - returnFiber.firstEffect = workInProgress; - } - - returnFiber.lastEffect = workInProgress; + } else { + // TODO: Move this out of the hot path using a dedicated effect tag. + if ( + nextEffect.tag === SuspenseComponent && + isSuspenseBoundaryBeingHidden(current, nextEffect) && + doesFiberContain(nextEffect, focusedInstanceHandle) + ) { + shouldFireAfterActiveInstanceBlur = true; } } - } else { - // This fiber did not complete because something threw. Pop values off - // the stack without entering the complete phase. If this is a boundary, - // capture values if possible. - var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time. - - if ((workInProgress.mode & ProfileMode) !== NoMode) { - // Record the render duration for the fiber that errored. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing. + } - var actualDuration = workInProgress.actualDuration; - var child = workInProgress.child; + var flags = nextEffect.flags; - while (child !== null) { - actualDuration += child.actualDuration; - child = child.sibling; - } + if ((flags & Snapshot) !== NoFlags) { + setCurrentFiber(nextEffect); + commitBeforeMutationLifeCycles(current, nextEffect); + resetCurrentFiber(); + } - workInProgress.actualDuration = actualDuration; + if ((flags & Passive) !== NoFlags) { + // If there are passive effects, schedule a callback to flush at + // the earliest opportunity. + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); } + } - if (_next !== null) { - // If completing this work spawned new work, do that next. We'll come - // back here again. - // Since we're restarting, remove anything that is not a host effect - // from the effect tag. - // TODO: The name stopFailedWorkTimer is misleading because Suspense - // also captures and restarts. - stopFailedWorkTimer(workInProgress); - _next.effectTag &= HostEffectMask; - return _next; - } + nextEffect = nextEffect.nextEffect; + } +} - stopWorkTimer(workInProgress); +function commitMutationEffects(root, renderPriorityLevel) { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; - if (returnFiber !== null) { - // Mark the parent fiber as incomplete and clear its effect list. - returnFiber.firstEffect = returnFiber.lastEffect = null; - returnFiber.effectTag |= Incomplete; - } + if (flags & ContentReset) { + commitResetTextContent(nextEffect); } - var siblingFiber = workInProgress.sibling; - - if (siblingFiber !== null) { - // If there is more work to do in this returnFiber, do that next. - return siblingFiber; - } // Otherwise, return to the parent + if (flags & Ref) { + var current = nextEffect.alternate; - workInProgress = returnFiber; - } while (workInProgress !== null); // We've reached the root. + if (current !== null) { + commitDetachRef(current); + } + } // The following switch statement is only concerned about placement, + // updates, and deletions. To avoid needing to add a case for every possible + // bitmap value, we remove the secondary effects from the effect tag and + // switch on that value. - if (workInProgressRootExitStatus === RootIncomplete) { - workInProgressRootExitStatus = RootCompleted; - } + var primaryFlags = flags & (Placement | Update | Deletion | Hydrating); - return null; -} + switch (primaryFlags) { + case Placement: { + commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + // TODO: findDOMNode doesn't rely on this any more but isMounted does + // and isMounted is deprecated anyway so we should be able to kill this. -function getRemainingExpirationTime(fiber) { - var updateExpirationTime = fiber.expirationTime; - var childExpirationTime = fiber.childExpirationTime; - return updateExpirationTime > childExpirationTime - ? updateExpirationTime - : childExpirationTime; -} + nextEffect.flags &= ~Placement; + break; + } -function resetChildExpirationTime(completedWork) { - if ( - renderExpirationTime$1 !== Never && - completedWork.childExpirationTime === Never - ) { - // The children of this component are hidden. Don't bubble their - // expiration times. - return; - } + case PlacementAndUpdate: { + // Placement + commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. - var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time. + nextEffect.flags &= ~Placement; // Update - if ((completedWork.mode & ProfileMode) !== NoMode) { - // In profiling mode, resetChildExpirationTime is also used to reset - // profiler durations. - var actualDuration = completedWork.actualDuration; - var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will - // only be updated if work is done on the fiber (i.e. it doesn't bailout). - // When work is done, it should bubble to the parent's actualDuration. If - // the fiber has not been cloned though, (meaning no work was done), then - // this value will reflect the amount of time spent working on a previous - // render. In that case it should not bubble. We determine whether it was - // cloned by comparing the child pointer. + var _current = nextEffect.alternate; + commitWork(_current, nextEffect); + break; + } - var shouldBubbleActualDurations = - completedWork.alternate === null || - completedWork.child !== completedWork.alternate.child; - var child = completedWork.child; + case Hydrating: { + nextEffect.flags &= ~Hydrating; + break; + } - while (child !== null) { - var childUpdateExpirationTime = child.expirationTime; - var childChildExpirationTime = child.childExpirationTime; + case HydratingAndUpdate: { + nextEffect.flags &= ~Hydrating; // Update - if (childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childUpdateExpirationTime; + var _current2 = nextEffect.alternate; + commitWork(_current2, nextEffect); + break; } - if (childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childChildExpirationTime; + case Update: { + var _current3 = nextEffect.alternate; + commitWork(_current3, nextEffect); + break; } - if (shouldBubbleActualDurations) { - actualDuration += child.actualDuration; + case Deletion: { + commitDeletion(root, nextEffect); + break; } - - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; } - completedWork.actualDuration = actualDuration; - completedWork.treeBaseDuration = treeBaseDuration; - } else { - var _child = completedWork.child; + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} - while (_child !== null) { - var _childUpdateExpirationTime = _child.expirationTime; - var _childChildExpirationTime = _child.childExpirationTime; +function commitLayoutEffects(root, committedLanes) { + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; - if (_childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childUpdateExpirationTime; - } + if (flags & (Update | Callback)) { + var current = nextEffect.alternate; + commitLifeCycles(root, current, nextEffect); + } - if (_childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childChildExpirationTime; + { + if (flags & Ref) { + commitAttachRef(nextEffect); } - - _child = _child.sibling; } - } - completedWork.childExpirationTime = newChildExpirationTime; + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } } -function commitRoot(root) { - var renderPriorityLevel = getCurrentPriorityLevel(); - runWithPriority( - ImmediatePriority, - commitRootImpl.bind(null, root, renderPriorityLevel) - ); - return null; -} +function flushPassiveEffects() { + // Returns whether passive effects were flushed. + if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { + var priorityLevel = + pendingPassiveEffectsRenderPriority > NormalPriority$1 + ? NormalPriority$1 + : pendingPassiveEffectsRenderPriority; + pendingPassiveEffectsRenderPriority = NoPriority$1; -function commitRootImpl(root, renderPriorityLevel) { - do { - // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which - // means `flushPassiveEffects` will sometimes result in additional - // passive effects. So we need to keep flushing in a loop until there are - // no more pending effects. - // TODO: Might be better if `flushPassiveEffects` did not automatically - // flush synchronous work at the end, to avoid factoring hazards like this. - flushPassiveEffects(); - } while (rootWithPendingPassiveEffects !== null); + { + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); + } + } - flushRenderPhaseStrictModeWarningsInDEV(); + return false; +} +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); } +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); - var finishedWork = root.finishedWork; - var expirationTime = root.finishedExpirationTime; + { + fiber.flags |= PassiveUnmountPendingDev; + var alternate = fiber.alternate; - if (finishedWork === null) { - return null; + if (alternate !== null) { + alternate.flags |= PassiveUnmountPendingDev; + } } - root.finishedWork = null; - root.finishedExpirationTime = NoWork; - - if (!(finishedWork !== root.current)) { - throw Error( - "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." - ); - } // commitRoot never returns a continuation; it always finishes synchronously. - // So we can clear these now to allow a new callback to be scheduled. + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); + } +} - root.callbackNode = null; - root.callbackExpirationTime = NoWork; - root.callbackPriority = NoPriority; - root.nextKnownPendingLevel = NoWork; - startCommitTimer(); // Update the first and last pending times on this root. The new first - // pending time is whatever is left on the root fiber. +function invokePassiveEffectCreate(effect) { + var create = effect.create; + effect.destroy = create(); +} - var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( - finishedWork - ); - markRootFinishedAtTime( - root, - expirationTime, - remainingExpirationTimeBeforeCommit - ); +function flushPassiveEffectsImpl() { + if (rootWithPendingPassiveEffects === null) { + return false; + } - if (root === workInProgressRoot) { - // We can reset these now that they are finished. - workInProgressRoot = null; - workInProgress = null; - renderExpirationTime$1 = NoWork; - } // This indicates that the last root we worked on is not the same one that - // we're committing now. This most commonly happens when a suspended root - // times out. - // Get the list of effects. + var root = rootWithPendingPassiveEffects; + var lanes = pendingPassiveEffectsLanes; + rootWithPendingPassiveEffects = null; + pendingPassiveEffectsLanes = NoLanes; - var firstEffect; + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Cannot flush passive effects while already rendering."); + } - if (finishedWork.effectTag > PerformedWork) { - // A fiber's effect list consists only of its children, not itself. So if - // the root has an effect, we need to add it to the end of the list. The - // resulting list is the set that would belong to the root's parent, if it - // had one; that is, all the effects in the tree including the root. - if (finishedWork.lastEffect !== null) { - finishedWork.lastEffect.nextEffect = finishedWork; - firstEffect = finishedWork.firstEffect; - } else { - firstEffect = finishedWork; - } - } else { - // There is no effect on the root. - firstEffect = finishedWork.firstEffect; + { + isFlushingPassiveEffects = true; } - if (firstEffect !== null) { - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called + // before ANY passive effect create functions are called. + // Otherwise effects in sibling components might interfere with each other. + // e.g. a destroy function in one component may unintentionally override a ref + // value set by a create function in another component. + // Layout effects have the same constraint. + // First pass: Destroy stale passive effects. + + var unmountEffects = pendingPassiveHookEffectsUnmount; + pendingPassiveHookEffectsUnmount = []; + + for (var i = 0; i < unmountEffects.length; i += 2) { + var _effect = unmountEffects[i]; + var fiber = unmountEffects[i + 1]; + var destroy = _effect.destroy; + _effect.destroy = undefined; - ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass - // of the effect list for each phase: all mutation effects come before all - // layout effects, and so on. - // The first phase a "before mutation" phase. We use this phase to read the - // state of the host tree right before we mutate it. This is where - // getSnapshotBeforeUpdate is called. + { + fiber.flags &= ~PassiveUnmountPendingDev; + var alternate = fiber.alternate; - startCommitSnapshotEffectsTimer(); - prepareForCommit(root.containerInfo); - nextEffect = firstEffect; + if (alternate !== null) { + alternate.flags &= ~PassiveUnmountPendingDev; + } + } - do { + if (typeof destroy === "function") { { - invokeGuardedCallback(null, commitBeforeMutationEffects, null); + setCurrentFiber(fiber); + + { + invokeGuardedCallback(null, destroy, null); + } if (hasCaughtError()) { - if (!(nextEffect !== null)) { + if (!(fiber !== null)) { throw Error("Should be working on an effect."); } var error = clearCaughtError(); - captureCommitPhaseError(nextEffect, error); - nextEffect = nextEffect.nextEffect; + captureCommitPhaseError(fiber, error); } + + resetCurrentFiber(); } - } while (nextEffect !== null); + } + } // Second pass: Create new passive effects. - stopCommitSnapshotEffectsTimer(); + var mountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; - { - // Mark the current commit time to be shared by all Profilers in this - // batch. This enables them to be grouped later. - recordCommitTime(); - } // The next phase is the mutation phase, where we mutate the host tree. + for (var _i = 0; _i < mountEffects.length; _i += 2) { + var _effect2 = mountEffects[_i]; + var _fiber = mountEffects[_i + 1]; - startCommitHostEffectsTimer(); - nextEffect = firstEffect; + { + setCurrentFiber(_fiber); - do { { - invokeGuardedCallback( - null, - commitMutationEffects, - null, - root, - renderPriorityLevel - ); + invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); + } - if (hasCaughtError()) { - if (!(nextEffect !== null)) { - throw Error("Should be working on an effect."); - } + if (hasCaughtError()) { + if (!(_fiber !== null)) { + throw Error("Should be working on an effect."); + } - var _error = clearCaughtError(); + var _error4 = clearCaughtError(); - captureCommitPhaseError(nextEffect, _error); - nextEffect = nextEffect.nextEffect; - } + captureCommitPhaseError(_fiber, _error4); } - } while (nextEffect !== null); - stopCommitHostEffectsTimer(); - resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after - // the mutation phase, so that the previous tree is still current during - // componentWillUnmount, but before the layout phase, so that the finished - // work is current during componentDidMount/Update. + resetCurrentFiber(); + } + } // Note: This currently assumes there are no passive effects on the root fiber + // because the root is not part of its own effect list. + // This could change in the future. - root.current = finishedWork; // The next phase is the layout phase, where we call effects that read - // the host tree after it's been mutated. The idiomatic use case for this is - // layout, but class component lifecycles also fire here for legacy reasons. + var effect = root.current.firstEffect; - startCommitLifeCyclesTimer(); - nextEffect = firstEffect; + while (effect !== null) { + var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC - do { - { - invokeGuardedCallback( - null, - commitLayoutEffects, - null, - root, - expirationTime - ); + effect.nextEffect = null; - if (hasCaughtError()) { - if (!(nextEffect !== null)) { - throw Error("Should be working on an effect."); - } + if (effect.flags & Deletion) { + detachFiberAfterEffects(effect); + } - var _error2 = clearCaughtError(); + effect = nextNextEffect; + } - captureCommitPhaseError(nextEffect, _error2); - nextEffect = nextEffect.nextEffect; - } - } - } while (nextEffect !== null); + { + popInteractions(prevInteractions); + finishPendingInteractions(root, lanes); + } - stopCommitLifeCyclesTimer(); - nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an - // opportunity to paint. + { + isFlushingPassiveEffects = false; + } - requestPaint(); + executionContext = prevExecutionContext; + flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this + // exceeds the limit, we'll fire a warning. - { - popInteractions(prevInteractions); - } + nestedPassiveUpdateCount = + rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; + return true; +} - executionContext = prevExecutionContext; +function isAlreadyFailedLegacyErrorBoundary(instance) { + return ( + legacyErrorBoundariesThatAlreadyFailed !== null && + legacyErrorBoundariesThatAlreadyFailed.has(instance) + ); +} +function markLegacyErrorBoundaryAsFailed(instance) { + if (legacyErrorBoundariesThatAlreadyFailed === null) { + legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); } else { - // No effects. - root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were - // no effects. - // TODO: Maybe there's a better way to report this. + legacyErrorBoundariesThatAlreadyFailed.add(instance); + } +} + +function prepareToThrowUncaughtError(error) { + if (!hasUncaughtError) { + hasUncaughtError = true; + firstUncaughtError = error; + } +} - startCommitSnapshotEffectsTimer(); - stopCommitSnapshotEffectsTimer(); +var onUncaughtError = prepareToThrowUncaughtError; - { - recordCommitTime(); - } +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + enqueueUpdate(rootFiber, update); + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane); - startCommitHostEffectsTimer(); - stopCommitHostEffectsTimer(); - startCommitLifeCyclesTimer(); - stopCommitLifeCyclesTimer(); + if (root !== null) { + markRootUpdated(root, SyncLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, SyncLane); } +} - stopCommitTimer(); - var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; - - if (rootDoesHavePassiveEffects) { - // This commit has passive effects. Stash a reference to them. But don't - // schedule a callback until after flushing layout work. - rootDoesHavePassiveEffects = false; - rootWithPendingPassiveEffects = root; - pendingPassiveEffectsExpirationTime = expirationTime; - pendingPassiveEffectsRenderPriority = renderPriorityLevel; - } else { - // We are done with the effect chain at this point so let's clear the - // nextEffect pointers to assist with GC. If we have passive effects, we'll - // clear this in flushPassiveEffects. - nextEffect = firstEffect; +function captureCommitPhaseError(sourceFiber, error) { + if (sourceFiber.tag === HostRoot) { + // Error was thrown at the root. There is no parent, so the root + // itself should capture it. + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + return; + } - while (nextEffect !== null) { - var nextNextEffect = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = nextNextEffect; - } - } // Check if there's remaining work on this root + var fiber = sourceFiber.return; - var remainingExpirationTime = root.firstPendingTime; + while (fiber !== null) { + if (fiber.tag === HostRoot) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + return; + } else if (fiber.tag === ClassComponent) { + var ctor = fiber.type; + var instance = fiber.stateNode; - if (remainingExpirationTime !== NoWork) { - { - if (spawnedWorkDuringRender !== null) { - var expirationTimes = spawnedWorkDuringRender; - spawnedWorkDuringRender = null; + if ( + typeof ctor.getDerivedStateFromError === "function" || + (typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance)) + ) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + enqueueUpdate(fiber, update); + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane); - for (var i = 0; i < expirationTimes.length; i++) { - scheduleInteractions( - root, - expirationTimes[i], - root.memoizedInteractions - ); + if (root !== null) { + markRootUpdated(root, SyncLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, SyncLane); + } else { + // This component has already been unmounted. + // We can't schedule any follow up work for the root because the fiber is already unmounted, + // but we can still call the log-only boundary so the error isn't swallowed. + // + // TODO This is only a temporary bandaid for the old reconciler fork. + // We can delete this special case once the new fork is merged. + if ( + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance) + ) { + try { + instance.componentDidCatch(error, errorInfo); + } catch (errorToIgnore) { + // TODO Ignore this error? Rethrow it? + // This is kind of an edge case. + } + } } - } - schedulePendingInteractions(root, remainingExpirationTime); + return; + } } - } else { - // If there's no remaining work, we can clear the set of already failed - // error boundaries. - legacyErrorBoundariesThatAlreadyFailed = null; + + fiber = fiber.return; } +} +function pingSuspendedRoot(root, wakeable, pingedLanes) { + var pingCache = root.pingCache; - { - if (!rootDidHavePassiveEffects) { - // If there are no passive effects, then we can complete the pending interactions. - // Otherwise, we'll wait until after the passive effects are flushed. - // Wait to do this until after remaining work has been scheduled, - // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. - finishPendingInteractions(root, expirationTime); + if (pingCache !== null) { + // The wakeable resolved, so we no longer need to memoize, because it will + // never be thrown again. + pingCache.delete(wakeable); + } + + var eventTime = requestEventTime(); + markRootPinged(root, pingedLanes); + + if ( + workInProgressRoot === root && + isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes) + ) { + // Received a ping at the same priority level at which we're currently + // rendering. We might want to restart this render. This should mirror + // the logic of whether or not a root suspends once it completes. + // TODO: If we're rendering sync either due to Sync, Batched or expired, + // we should probably never restart. + // If we're suspended with delay, or if it's a retry, we'll always suspend + // so we can always restart. + if ( + workInProgressRootExitStatus === RootSuspendedWithDelay || + (workInProgressRootExitStatus === RootSuspended && + includesOnlyRetries(workInProgressRootRenderLanes) && + now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) + ) { + // Restart from the root. + prepareFreshStack(root, NoLanes); + } else { + // Even though we can't restart right now, we might get an + // opportunity later. So we mark this render as having a ping. + workInProgressRootPingedLanes = mergeLanes( + workInProgressRootPingedLanes, + pingedLanes + ); } } - if (remainingExpirationTime === Sync) { - // Count the number of times the root synchronously re-renders without - // finishing. If there are too many, it indicates an infinite update loop. - if (root === rootWithNestedUpdates) { - nestedUpdateCount++; - } else { - nestedUpdateCount = 0; - rootWithNestedUpdates = root; - } - } else { - nestedUpdateCount = 0; + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, pingedLanes); +} + +function retryTimedOutBoundary(boundaryFiber, retryLane) { + // The boundary fiber (a Suspense component or SuspenseList component) + // previously was rendered in its fallback state. One of the promises that + // suspended it has resolved, which means at least part of the tree was + // likely unblocked. Try rendering again, at a new expiration time. + if (retryLane === NoLane) { + retryLane = requestRetryLane(boundaryFiber); + } // TODO: Special case idle priority? + + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane); + + if (root !== null) { + markRootUpdated(root, retryLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, retryLane); } +} +function resolveRetryWakeable(boundaryFiber, wakeable) { + var retryLane = NoLane; // Default - onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any - // additional work on this root is scheduled. + var retryCache; - ensureRootIsScheduled(root); + { + retryCache = boundaryFiber.stateNode; + } - if (hasUncaughtError) { - hasUncaughtError = false; - var _error3 = firstUncaughtError; - firstUncaughtError = null; - throw _error3; + if (retryCache !== null) { + // The wakeable resolved, so we no longer need to memoize, because it will + // never be thrown again. + retryCache.delete(wakeable); } - if ((executionContext & LegacyUnbatchedContext) !== NoContext) { - // This is a legacy edge case. We just committed the initial mount of - // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired - // synchronously, but layout updates should be deferred until the end - // of the batch. - return null; - } // If layout work was scheduled, flush it now. + retryTimedOutBoundary(boundaryFiber, retryLane); +} // Computes the next Just Noticeable Difference (JND) boundary. +// The theory is that a person can't tell the difference between small differences in time. +// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable +// difference in the experience. However, waiting for longer might mean that we can avoid +// showing an intermediate loading state. The longer we have already waited, the harder it +// is to tell small differences in time. Therefore, the longer we've already waited, +// the longer we can wait additionally. At some point we have to give up though. +// We pick a train model where the next boundary commits at a consistent schedule. +// These particular numbers are vague estimates. We expect to adjust them based on research. - flushSyncCallbackQueue(); - return null; +function jnd(timeElapsed) { + return timeElapsed < 120 + ? 120 + : timeElapsed < 480 + ? 480 + : timeElapsed < 1080 + ? 1080 + : timeElapsed < 1920 + ? 1920 + : timeElapsed < 3000 + ? 3000 + : timeElapsed < 4320 + ? 4320 + : ceil(timeElapsed / 1960) * 1960; } -function commitBeforeMutationEffects() { - while (nextEffect !== null) { - var effectTag = nextEffect.effectTag; +function checkForNestedUpdates() { + if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { + nestedUpdateCount = 0; + rootWithNestedUpdates = null; - if ((effectTag & Snapshot) !== NoEffect) { - setCurrentFiber(nextEffect); - recordEffect(); - var current = nextEffect.alternate; - commitBeforeMutationLifeCycles(current, nextEffect); - resetCurrentFiber(); + { + throw Error( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + ); } + } - if ((effectTag & Passive) !== NoEffect) { - // If there are passive effects, schedule a callback to flush at - // the earliest opportunity. - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority, function() { - flushPassiveEffects(); - return null; - }); - } + { + if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { + nestedPassiveUpdateCount = 0; + + error( + "Maximum update depth exceeded. This can happen when a component " + + "calls setState inside useEffect, but useEffect either doesn't " + + "have a dependency array, or one of the dependencies changes on " + + "every render." + ); } + } +} - nextEffect = nextEffect.nextEffect; +function flushRenderPhaseStrictModeWarningsInDEV() { + { + ReactStrictModeWarnings.flushLegacyContextWarning(); + + { + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + } } } -function commitMutationEffects(root, renderPriorityLevel) { - // TODO: Should probably move the bulk of this function to commitWork. - while (nextEffect !== null) { - setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; +var didWarnStateUpdateForNotYetMountedComponent = null; - if (effectTag & ContentReset) { - commitResetTextContent(nextEffect); +function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { + { + if ((executionContext & RenderContext) !== NoContext) { + // We let the other warning about render phase updates deal with this one. + return; } - if (effectTag & Ref) { - var current = nextEffect.alternate; + if (!(fiber.mode & (BlockingMode | ConcurrentMode))) { + return; + } - if (current !== null) { - commitDetachRef(current); - } - } // The following switch statement is only concerned about placement, - // updates, and deletions. To avoid needing to add a case for every possible - // bitmap value, we remove the secondary effects from the effect tag and - // switch on that value. + var tag = fiber.tag; - var primaryEffectTag = - effectTag & (Placement | Update | Deletion | Hydrating); + if ( + tag !== IndeterminateComponent && + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent && + tag !== Block + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. - switch (primaryEffectTag) { - case Placement: { - commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is - // inserted, before any life-cycles like componentDidMount gets called. - // TODO: findDOMNode doesn't rely on this any more but isMounted does - // and isMounted is deprecated anyway so we should be able to kill this. + var componentName = getComponentName(fiber.type) || "ReactComponent"; - nextEffect.effectTag &= ~Placement; - break; + if (didWarnStateUpdateForNotYetMountedComponent !== null) { + if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) { + return; } - case PlacementAndUpdate: { - // Placement - commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is - // inserted, before any life-cycles like componentDidMount gets called. + didWarnStateUpdateForNotYetMountedComponent.add(componentName); + } else { + didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); + } - nextEffect.effectTag &= ~Placement; // Update + var previousFiber = current; - var _current = nextEffect.alternate; - commitWork(_current, nextEffect); - break; - } + try { + setCurrentFiber(fiber); - case Hydrating: { - nextEffect.effectTag &= ~Hydrating; - break; + error( + "Can't perform a React state update on a component that hasn't mounted yet. " + + "This indicates that you have a side-effect in your render function that " + + "asynchronously later calls tries to update the component. Move this work to " + + "useEffect instead." + ); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); } + } + } +} - case HydratingAndUpdate: { - nextEffect.effectTag &= ~Hydrating; // Update +var didWarnStateUpdateForUnmountedComponent = null; - var _current2 = nextEffect.alternate; - commitWork(_current2, nextEffect); - break; - } +function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { + { + var tag = fiber.tag; - case Update: { - var _current3 = nextEffect.alternate; - commitWork(_current3, nextEffect); - break; - } + if ( + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent && + tag !== Block + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } // If there are pending passive effects unmounts for this Fiber, + // we can assume that they would have prevented this update. - case Deletion: { - commitDeletion(root, nextEffect, renderPriorityLevel); - break; - } - } // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) { + return; + } // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. - recordEffect(); - resetCurrentFiber(); - nextEffect = nextEffect.nextEffect; - } -} + var componentName = getComponentName(fiber.type) || "ReactComponent"; -function commitLayoutEffects(root, committedExpirationTime) { - // TODO: Should probably move the bulk of this function to commitWork. - while (nextEffect !== null) { - setCurrentFiber(nextEffect); - var effectTag = nextEffect.effectTag; + if (didWarnStateUpdateForUnmountedComponent !== null) { + if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { + return; + } - if (effectTag & (Update | Callback)) { - recordEffect(); - var current = nextEffect.alternate; - commitLifeCycles(root, current, nextEffect); + didWarnStateUpdateForUnmountedComponent.add(componentName); + } else { + didWarnStateUpdateForUnmountedComponent = new Set([componentName]); } - if (effectTag & Ref) { - recordEffect(); - commitAttachRef(nextEffect); - } + if (isFlushingPassiveEffects); + else { + var previousFiber = current; - resetCurrentFiber(); - nextEffect = nextEffect.nextEffect; - } -} + try { + setCurrentFiber(fiber); -function flushPassiveEffects() { - if (pendingPassiveEffectsRenderPriority !== NoPriority) { - var priorityLevel = - pendingPassiveEffectsRenderPriority > NormalPriority - ? NormalPriority - : pendingPassiveEffectsRenderPriority; - pendingPassiveEffectsRenderPriority = NoPriority; - return runWithPriority(priorityLevel, flushPassiveEffectsImpl); + error( + "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.", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function" + ); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); + } + } + } } } -function flushPassiveEffectsImpl() { - if (rootWithPendingPassiveEffects === null) { - return false; - } +var beginWork$1; - var root = rootWithPendingPassiveEffects; - var expirationTime = pendingPassiveEffectsExpirationTime; - rootWithPendingPassiveEffects = null; - pendingPassiveEffectsExpirationTime = NoWork; +{ + var dummyFiber = null; + + beginWork$1 = function(current, unitOfWork, lanes) { + // If a component throws an error, we replay it again in a synchronously + // dispatched event, so that the debugger will treat it as an uncaught + // error See ReactErrorUtils for more information. + // Before entering the begin phase, copy the work-in-progress onto a dummy + // fiber. If beginWork throws, we'll use this to reset the state. + var originalWorkInProgressCopy = assignFiberPropertiesInDEV( + dummyFiber, + unitOfWork + ); - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Cannot flush passive effects while already rendering."); - } + try { + return beginWork(current, unitOfWork, lanes); + } catch (originalError) { + if ( + originalError !== null && + typeof originalError === "object" && + typeof originalError.then === "function" + ) { + // Don't replay promises. Treat everything else like an error. + throw originalError; + } // Keep this code in sync with handleError; any changes here must have + // corresponding changes there. - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); + resetContextDependencies(); + resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the + // same fiber again. + // Unwind the failed stack frame - { - // Note: This currently assumes there are no passive effects on the root fiber - // because the root is not part of its own effect list. - // This could change in the future. - var _effect2 = root.current.firstEffect; + unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. - while (_effect2 !== null) { - { - setCurrentFiber(_effect2); - invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2); + assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); - if (hasCaughtError()) { - if (!(_effect2 !== null)) { - throw Error("Should be working on an effect."); - } + if (unitOfWork.mode & ProfileMode) { + // Reset the profiler timer. + startProfilerTimer(unitOfWork); + } // Run beginWork again. - var _error5 = clearCaughtError(); + invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); - captureCommitPhaseError(_effect2, _error5); - } + if (hasCaughtError()) { + var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. - resetCurrentFiber(); + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; } + } + }; +} - var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC +var didWarnAboutUpdateInRender = false; +var didWarnAboutUpdateInRenderForAnotherComponent; - _effect2.nextEffect = null; - _effect2 = nextNextEffect; - } - } +{ + didWarnAboutUpdateInRenderForAnotherComponent = new Set(); +} +function warnAboutRenderPhaseUpdatesInDEV(fiber) { { - popInteractions(prevInteractions); - finishPendingInteractions(root, expirationTime); - } - - executionContext = prevExecutionContext; - flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this - // exceeds the limit, we'll fire a warning. + if ( + isRendering && + (executionContext & RenderContext) !== NoContext && + !getIsUpdatingOpaqueValueInRenderPhaseInDEV() + ) { + switch (fiber.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + var renderingComponentName = + (workInProgress && getComponentName(workInProgress.type)) || + "Unknown"; // Dedupe by the rendering component because it's the one that needs to be fixed. - nestedPassiveUpdateCount = - rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; - return true; -} + var dedupeKey = renderingComponentName; -function isAlreadyFailedLegacyErrorBoundary(instance) { - return ( - legacyErrorBoundariesThatAlreadyFailed !== null && - legacyErrorBoundariesThatAlreadyFailed.has(instance) - ); -} -function markLegacyErrorBoundaryAsFailed(instance) { - if (legacyErrorBoundariesThatAlreadyFailed === null) { - legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); - } else { - legacyErrorBoundariesThatAlreadyFailed.add(instance); - } -} + if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { + didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); + var setStateComponentName = + getComponentName(fiber.type) || "Unknown"; -function prepareToThrowUncaughtError(error) { - if (!hasUncaughtError) { - hasUncaughtError = true; - firstUncaughtError = error; - } -} + error( + "Cannot update a component (`%s`) while rendering a " + + "different component (`%s`). To locate the bad setState() call inside `%s`, " + + "follow the stack trace as described in https://reactjs.org/link/setstate-in-render", + setStateComponentName, + renderingComponentName, + renderingComponentName + ); + } -var onUncaughtError = prepareToThrowUncaughtError; + break; + } -function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { - var errorInfo = createCapturedValue(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); - enqueueUpdate(rootFiber, update); - var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); + case ClassComponent: { + if (!didWarnAboutUpdateInRender) { + error( + "Cannot update during an existing state transition (such as " + + "within `render`). Render methods should be a pure " + + "function of props and state." + ); - if (root !== null) { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, Sync); - } -} + didWarnAboutUpdateInRender = true; + } -function captureCommitPhaseError(sourceFiber, error) { - if (sourceFiber.tag === HostRoot) { - // Error was thrown at the root. There is no parent, so the root - // itself should capture it. - captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); - return; + break; + } + } + } } +} // a 'shared' variable that changes when act() opens/closes in tests. - var fiber = sourceFiber.return; +var IsThisRendererActing = { + current: false +}; +function warnIfNotScopedWithMatchingAct(fiber) { + { + if ( + IsSomeRendererActing.current === true && + IsThisRendererActing.current !== true + ) { + var previousFiber = current; - while (fiber !== null) { - if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); - return; - } else if (fiber.tag === ClassComponent) { - var ctor = fiber.type; - var instance = fiber.stateNode; + try { + setCurrentFiber(fiber); - if ( - typeof ctor.getDerivedStateFromError === "function" || - (typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance)) - ) { - var errorInfo = createCapturedValue(error, sourceFiber); - var update = createClassErrorUpdate( - fiber, - errorInfo, // TODO: This is always sync - Sync + error( + "It looks like you're using the wrong act() around your test interactions.\n" + + "Be sure to use the matching version of act() corresponding to your renderer:\n\n" + + "// for react-dom:\n" + // Break up imports to avoid accidentally parsing them as dependencies. + "import {act} fr" + + "om 'react-dom/test-utils';\n" + + "// ...\n" + + "act(() => ...);\n\n" + + "// for react-test-renderer:\n" + // Break up imports to avoid accidentally parsing them as dependencies. + "import TestRenderer fr" + + "om react-test-renderer';\n" + + "const {act} = TestRenderer;\n" + + "// ...\n" + + "act(() => ...);" ); - enqueueUpdate(fiber, update); - var root = markUpdateTimeFromFiberToRoot(fiber, Sync); - - if (root !== null) { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, Sync); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); } - - return; } } - - fiber = fiber.return; } } -function pingSuspendedRoot(root, thenable, suspendedTime) { - var pingCache = root.pingCache; - - if (pingCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - pingCache.delete(thenable); - } - - if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { - // Received a ping at the same priority level at which we're currently - // rendering. We might want to restart this render. This should mirror - // the logic of whether or not a root suspends once it completes. - // TODO: If we're rendering sync either due to Sync, Batched or expired, - // we should probably never restart. - // If we're suspended with delay, we'll always suspend so we can always - // restart. If we're suspended without any updates, it might be a retry. - // If it's early in the retry we can restart. We can't know for sure - // whether we'll eventually process an update during this render pass, - // but it's somewhat unlikely that we get to a ping before that, since - // getting to the root most update is usually very fast. +function warnIfNotCurrentlyActingEffectsInDEV(fiber) { + { if ( - workInProgressRootExitStatus === RootSuspendedWithDelay || - (workInProgressRootExitStatus === RootSuspended && - workInProgressRootLatestProcessedExpirationTime === Sync && - now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) + (fiber.mode & StrictMode) !== NoMode && + IsSomeRendererActing.current === false && + IsThisRendererActing.current === false ) { - // Restart from the root. Don't need to schedule a ping because - // we're already working on this tree. - prepareFreshStack(root, renderExpirationTime$1); - } else { - // Even though we can't restart right now, we might get an - // opportunity later. So we mark this render as having a ping. - workInProgressRootHasPendingPing = true; + error( + "An update to %s ran an effect, but was not wrapped in act(...).\n\n" + + "When testing, code that causes React state updates should be " + + "wrapped into act(...):\n\n" + + "act(() => {\n" + + " /* fire events that update state */\n" + + "});\n" + + "/* assert on the output */\n\n" + + "This ensures that you're testing the behavior the user would see " + + "in the browser." + + " Learn more at https://reactjs.org/link/wrap-tests-with-act", + getComponentName(fiber.type) + ); } - - return; } - - if (!isRootSuspendedAtTime(root, suspendedTime)) { - // The root is no longer suspended at this time. - return; - } - - var lastPingedTime = root.lastPingedTime; - - if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) { - // There's already a lower priority ping scheduled. - return; - } // Mark the time at which this ping was scheduled. - - root.lastPingedTime = suspendedTime; - ensureRootIsScheduled(root); - schedulePendingInteractions(root, suspendedTime); } -function retryTimedOutBoundary(boundaryFiber, retryTime) { - // The boundary fiber (a Suspense component or SuspenseList component) - // previously was rendered in its fallback state. One of the promises that - // suspended it has resolved, which means at least part of the tree was - // likely unblocked. Try rendering again, at a new expiration time. - if (retryTime === NoWork) { - var suspenseConfig = null; // Retries don't carry over the already committed update. - - var currentTime = requestCurrentTimeForUpdate(); - retryTime = computeExpirationForFiber( - currentTime, - boundaryFiber, - suspenseConfig - ); - } // TODO: Special case idle priority? +function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { + { + if ( + executionContext === NoContext && + IsSomeRendererActing.current === false && + IsThisRendererActing.current === false + ) { + var previousFiber = current; - var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); + try { + setCurrentFiber(fiber); - if (root !== null) { - ensureRootIsScheduled(root); - schedulePendingInteractions(root, retryTime); + error( + "An update to %s inside a test was not wrapped in act(...).\n\n" + + "When testing, code that causes React state updates should be " + + "wrapped into act(...):\n\n" + + "act(() => {\n" + + " /* fire events that update state */\n" + + "});\n" + + "/* assert on the output */\n\n" + + "This ensures that you're testing the behavior the user would see " + + "in the browser." + + " Learn more at https://reactjs.org/link/wrap-tests-with-act", + getComponentName(fiber.type) + ); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); + } + } + } } } -function resolveRetryThenable(boundaryFiber, thenable) { - var retryTime = NoWork; // Default - - var retryCache; - - { - retryCache = boundaryFiber.stateNode; - } - if (retryCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - retryCache.delete(thenable); - } +var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler. - retryTimedOutBoundary(boundaryFiber, retryTime); -} // Computes the next Just Noticeable Difference (JND) boundary. -// The theory is that a person can't tell the difference between small differences in time. -// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable -// difference in the experience. However, waiting for longer might mean that we can avoid -// showing an intermediate loading state. The longer we have already waited, the harder it -// is to tell small differences in time. Therefore, the longer we've already waited, -// the longer we can wait additionally. At some point we have to give up though. -// We pick a train model where the next boundary commits at a consistent schedule. -// These particular numbers are vague estimates. We expect to adjust them based on research. +var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked +// scheduler is the actual recommendation. The alternative could be a testing build, +// a new lib, or whatever; we dunno just yet. This message is for early adopters +// to get their tests right. -function jnd(timeElapsed) { - return timeElapsed < 120 - ? 120 - : timeElapsed < 480 - ? 480 - : timeElapsed < 1080 - ? 1080 - : timeElapsed < 1920 - ? 1920 - : timeElapsed < 3000 - ? 3000 - : timeElapsed < 4320 - ? 4320 - : ceil(timeElapsed / 1960) * 1960; +function warnIfUnmockedScheduler(fiber) { + { + if ( + didWarnAboutUnmockedScheduler === false && + Scheduler.unstable_flushAllWithoutAsserting === undefined + ) { + if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { + didWarnAboutUnmockedScheduler = true; + + error( + 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + + "to guarantee consistent behaviour across tests and browsers. " + + "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. + "jest.mock('scheduler', () => require" + + "('scheduler/unstable_mock'));\n\n" + + "For more info, visit https://reactjs.org/link/mock-scheduler" + ); + } + } + } } -function computeMsUntilSuspenseLoadingDelay( - mostRecentEventTime, - committedExpirationTime, - suspenseConfig -) { - var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; +function computeThreadID(root, lane) { + // Interaction threads are unique per root and expiration time. + // NOTE: Intentionally unsound cast. All that matters is that it's a number + // and it represents a batch of work. Could make a helper function instead, + // but meh this is fine for now. + return lane * 1000 + root.interactionThreadID; +} - if (busyMinDurationMs <= 0) { - return 0; +function markSpawnedWork(lane) { + if (spawnedWorkDuringRender === null) { + spawnedWorkDuringRender = [lane]; + } else { + spawnedWorkDuringRender.push(lane); } +} - var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. +function scheduleInteractions(root, lane, interactions) { + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(lane); - var currentTimeMs = now(); - var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig( - mostRecentEventTime, - suspenseConfig - ); - var timeElapsed = currentTimeMs - eventTimeMs; + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } - if (timeElapsed <= busyDelayMs) { - // If we haven't yet waited longer than the initial delay, we don't - // have to wait any additional time. - return 0; - } + pendingInteractions.add(interaction); + }); + } else { + pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions. + + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + + var subscriber = tracing.__subscriberRef.current; - var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`. + if (subscriber !== null) { + var threadID = computeThreadID(root, lane); + subscriber.onWorkScheduled(interactions, threadID); + } + } +} - return msUntilTimeout; +function schedulePendingInteractions(root, lane) { + scheduleInteractions(root, lane, tracing.__interactionsRef.current); } -function checkForNestedUpdates() { - if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { - nestedUpdateCount = 0; - rootWithNestedUpdates = null; +function startWorkOnPendingInteractions(root, lanes) { + // we can accurately attribute time spent working on it, And so that cascading + // work triggered during the render phase will be associated with it. - { - throw Error( - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ); + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledLane + ) { + if (includesSomeLane(lanes, scheduledLane)) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); } - } + }); // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like performConcurrentWorkOnRoot() + // without having to recalculate it. We will also use it in commitWork() to + // pass to any Profiler onRender() hooks. This also provides DevTools with a + // way to access it when the onCommitRoot() hook is called. - { - if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { - nestedPassiveUpdateCount = 0; + root.memoizedInteractions = interactions; - error( - "Maximum update depth exceeded. This can happen when a component " + - "calls setState inside useEffect, but useEffect either doesn't " + - "have a dependency array, or one of the dependencies changes on " + - "every render." - ); + if (interactions.size > 0) { + var subscriber = tracing.__subscriberRef.current; + + if (subscriber !== null) { + var threadID = computeThreadID(root, lanes); + + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function() { + throw error; + }); + } } } } -function flushRenderPhaseStrictModeWarningsInDEV() { - { - ReactStrictModeWarnings.flushLegacyContextWarning(); +function finishPendingInteractions(root, committedLanes) { + var remainingLanesAfterCommit = root.pendingLanes; + var subscriber; - { - ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + try { + subscriber = tracing.__subscriberRef.current; + + if (subscriber !== null && root.memoizedInteractions.size > 0) { + // FIXME: More than one lane can finish in a single commit. + var threadID = computeThreadID(root, committedLanes); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); } + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function() { + throw error; + }); + } finally { + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function(scheduledInteractions, lane) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if (!includesSomeLane(remainingLanesAfterCommit, lane)) { + pendingInteractionMap.delete(lane); + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function() { + throw error; + }); + } + } + }); + } + }); } -} +} // `act` testing API -function stopFinishedWorkLoopTimer() { - var didCompleteRoot = true; - stopWorkLoopTimer(interruptedBy, didCompleteRoot); - interruptedBy = null; +function shouldForceFlushFallbacksInDEV() { + // Never force flush in production. This function should get stripped out. + return actingUpdatesScopeDepth > 0; } +// so we can tell if any async act() calls try to run in parallel. -function stopInterruptedWorkLoopTimer() { - // TODO: Track which fiber caused the interruption. - var didCompleteRoot = false; - stopWorkLoopTimer(interruptedBy, didCompleteRoot); - interruptedBy = null; -} +var actingUpdatesScopeDepth = 0; -function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { - if ( - workInProgressRoot !== null && - updateExpirationTime > renderExpirationTime$1 - ) { - interruptedBy = fiberThatReceivedUpdate; - } +function detachFiberAfterEffects(fiber) { + fiber.sibling = null; + fiber.stateNode = null; } -var didWarnStateUpdateForUnmountedComponent = null; +var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. -function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { +var failedBoundaries = null; +var setRefreshHandler = function(handler) { { - var tag = fiber.tag; - - if ( - tag !== HostRoot && - tag !== ClassComponent && - tag !== FunctionComponent && - tag !== ForwardRef && - tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block - ) { - // Only warn for user-defined components, not internal ones like Suspense. - return; + resolveFamily = handler; + } +}; +function resolveFunctionForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; } - // the problematic code almost always lies inside that component. - - var componentName = getComponentName(fiber.type) || "ReactComponent"; - if (didWarnStateUpdateForUnmountedComponent !== null) { - if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { - return; - } + var family = resolveFamily(type); - didWarnStateUpdateForUnmountedComponent.add(componentName); - } else { - didWarnStateUpdateForUnmountedComponent = new Set([componentName]); - } + if (family === undefined) { + return type; + } // Use the latest known implementation. - error( - "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) - ); + return family.current; } } +function resolveClassForHotReloading(type) { + // No implementation differences. + return resolveFunctionForHotReloading(type); +} +function resolveForwardRefForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } -var beginWork$1; - -{ - var dummyFiber = null; - - beginWork$1 = function(current, unitOfWork, expirationTime) { - // If a component throws an error, we replay it again in a synchronously - // dispatched event, so that the debugger will treat it as an uncaught - // error See ReactErrorUtils for more information. - // Before entering the begin phase, copy the work-in-progress onto a dummy - // fiber. If beginWork throws, we'll use this to reset the state. - var originalWorkInProgressCopy = assignFiberPropertiesInDEV( - dummyFiber, - unitOfWork - ); + var family = resolveFamily(type); - try { - return beginWork(current, unitOfWork, expirationTime); - } catch (originalError) { + if (family === undefined) { + // Check if we're dealing with a real forwardRef. Don't want to crash early. if ( - originalError !== null && - typeof originalError === "object" && - typeof originalError.then === "function" + type !== null && + type !== undefined && + typeof type.render === "function" ) { - // Don't replay promises. Treat everything else like an error. - throw originalError; - } // Keep this code in sync with handleError; any changes here must have - // corresponding changes there. + // ForwardRef is special because its resolved .type is an object, + // but it's possible that we only have its inner render function in the map. + // If that inner render function is different, we'll build a new forwardRef type. + var currentRender = resolveFunctionForHotReloading(type.render); - resetContextDependencies(); - resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the - // same fiber again. - // Unwind the failed stack frame + if (type.render !== currentRender) { + var syntheticType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: currentRender + }; - unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. + if (type.displayName !== undefined) { + syntheticType.displayName = type.displayName; + } - assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); + return syntheticType; + } + } + + return type; + } // Use the latest known implementation. + + return family.current; + } +} +function isCompatibleFamilyForHotReloading(fiber, element) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return false; + } - if (unitOfWork.mode & ProfileMode) { - // Reset the profiler timer. - startProfilerTimer(unitOfWork); - } // Run beginWork again. + var prevType = fiber.elementType; + var nextType = element.type; // If we got here, we know types aren't === equal. - invokeGuardedCallback( - null, - beginWork, - null, - current, - unitOfWork, - expirationTime - ); + var needsCompareFamilies = false; + var $$typeofNextType = + typeof nextType === "object" && nextType !== null + ? nextType.$$typeof + : null; - if (hasCaughtError()) { - var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. - // Rethrow this error instead of the original one. + switch (fiber.tag) { + case ClassComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } - throw replayError; - } else { - // This branch is reachable if the render phase is impure. - throw originalError; + break; } - } - }; -} -var didWarnAboutUpdateInRender = false; + case FunctionComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + // We don't know the inner type yet. + // We're going to assume that the lazy inner type is stable, + // and so it is sufficient to avoid reconciling it away. + // We're not going to unwrap or actually use the new lazy type. + needsCompareFamilies = true; + } -function warnAboutRenderPhaseUpdatesInDEV(fiber) { - { - if ((executionContext & RenderContext) !== NoContext) { - switch (fiber.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - error( - "Cannot update a component from inside the function body of a " + - "different component." - ); + break; + } - break; + case ForwardRef: { + if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; } - case ClassComponent: { - if (isRendering && !didWarnAboutUpdateInRender) { - error( - "Cannot update during an existing state transition (such as " + - "within `render`). Render methods should be a pure " + - "function of props and state." - ); + break; + } - didWarnAboutUpdateInRender = true; - break; - } + case MemoComponent: + case SimpleMemoComponent: { + if ($$typeofNextType === REACT_MEMO_TYPE) { + // TODO: if it was but can no longer be simple, + // we shouldn't set this. + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; } + + break; } - } - } -} // a 'shared' variable that changes when act() opens/closes in tests. -var IsThisRendererActing = { - current: false -}; -function warnIfNotScopedWithMatchingAct(fiber) { - { - if ( - IsSomeRendererActing.current === true && - IsThisRendererActing.current !== true - ) { - error( - "It looks like you're using the wrong act() around your test interactions.\n" + - "Be sure to use the matching version of act() corresponding to your renderer:\n\n" + - "// for react-dom:\n" + // Break up imports to avoid accidentally parsing them as dependencies. - "import {act} fr" + - "om 'react-dom/test-utils';\n" + - "// ...\n" + - "act(() => ...);\n\n" + - "// for react-test-renderer:\n" + // Break up imports to avoid accidentally parsing them as dependencies. - "import TestRenderer fr" + - "om react-test-renderer';\n" + - "const {act} = TestRenderer;\n" + - "// ...\n" + - "act(() => ...);" + - "%s", - getStackByFiberInDevAndProd(fiber) - ); + default: + return false; + } // Check if both types have a family and it's the same one. + + if (needsCompareFamilies) { + // Note: memo() and forwardRef() we'll compare outer rather than inner type. + // This means both of them need to be registered to preserve state. + // If we unwrapped and compared the inner types for wrappers instead, + // then we would risk falsely saying two separate memo(Foo) + // calls are equivalent because they wrap the same Foo function. + var prevFamily = resolveFamily(prevType); + + if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { + return true; + } } + + return false; } } -function warnIfNotCurrentlyActingEffectsInDEV(fiber) { +function markFailedErrorBoundaryForHotReloading(fiber) { { - if ( - (fiber.mode & StrictMode) !== NoMode && - IsSomeRendererActing.current === false && - IsThisRendererActing.current === false - ) { - error( - "An update to %s ran an effect, but was not wrapped in act(...).\n\n" + - "When testing, code that causes React state updates should be " + - "wrapped into act(...):\n\n" + - "act(() => {\n" + - " /* fire events that update state */\n" + - "});\n" + - "/* assert on the output */\n\n" + - "This ensures that you're testing the behavior the user would see " + - "in the browser." + - " Learn more at https://fb.me/react-wrap-tests-with-act" + - "%s", - getComponentName(fiber.type), - getStackByFiberInDevAndProd(fiber) - ); + if (resolveFamily === null) { + // Hot reloading is disabled. + return; } - } -} -function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { - { - if ( - executionContext === NoContext && - IsSomeRendererActing.current === false && - IsThisRendererActing.current === false - ) { - error( - "An update to %s inside a test was not wrapped in act(...).\n\n" + - "When testing, code that causes React state updates should be " + - "wrapped into act(...):\n\n" + - "act(() => {\n" + - " /* fire events that update state */\n" + - "});\n" + - "/* assert on the output */\n\n" + - "This ensures that you're testing the behavior the user would see " + - "in the browser." + - " Learn more at https://fb.me/react-wrap-tests-with-act" + - "%s", - getComponentName(fiber.type), - getStackByFiberInDevAndProd(fiber) - ); + if (typeof WeakSet !== "function") { + return; + } + + if (failedBoundaries === null) { + failedBoundaries = new WeakSet(); } + + failedBoundaries.add(fiber); } } +var scheduleRefresh = function(root, update) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } -var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler. + var staleFamilies = update.staleFamilies, + updatedFamilies = update.updatedFamilies; + flushPassiveEffects(); + flushSync(function() { + scheduleFibersWithFamiliesRecursively( + root.current, + updatedFamilies, + staleFamilies + ); + }); + } +}; +var scheduleRoot = function(root, element) { + { + if (root.context !== emptyContextObject) { + // Super edge case: root has a legacy _renderSubtree context + // but we don't know the parentComponent so we can't pass it. + // Just ignore. We'll delete this with _renderSubtree code path later. + return; + } -var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked -// scheduler is the actual recommendation. The alternative could be a testing build, -// a new lib, or whatever; we dunno just yet. This message is for early adopters -// to get their tests right. + flushPassiveEffects(); + flushSync(function() { + updateContainer(element, root, null, null); + }); + } +}; -function warnIfUnmockedScheduler(fiber) { +function scheduleFibersWithFamiliesRecursively( + fiber, + updatedFamilies, + staleFamilies +) { { - if ( - didWarnAboutUnmockedScheduler === false && - Scheduler.unstable_flushAllWithoutAsserting === undefined - ) { - if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { - didWarnAboutUnmockedScheduler = true; + var alternate = fiber.alternate, + child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; - error( - 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + - "to guarantee consistent behaviour across tests and browsers. " + - "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. - "jest.mock('scheduler', () => require" + - "('scheduler/unstable_mock'));\n\n" + - "For more info, visit https://fb.me/react-mock-scheduler" - ); - } + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; + + case ForwardRef: + candidateType = type.render; + break; } - } -} -function computeThreadID(root, expirationTime) { - // Interaction threads are unique per root and expiration time. - return expirationTime * 1000 + root.interactionThreadID; -} + if (resolveFamily === null) { + throw new Error("Expected resolveFamily to be set during hot reload."); + } -function markSpawnedWork(expirationTime) { - if (spawnedWorkDuringRender === null) { - spawnedWorkDuringRender = [expirationTime]; - } else { - spawnedWorkDuringRender.push(expirationTime); - } -} + var needsRender = false; + var needsRemount = false; -function scheduleInteractions(root, expirationTime, interactions) { - if (interactions.size > 0) { - var pendingInteractionMap = root.pendingInteractionMap; - var pendingInteractions = pendingInteractionMap.get(expirationTime); + if (candidateType !== null) { + var family = resolveFamily(candidateType); - if (pendingInteractions != null) { - interactions.forEach(function(interaction) { - if (!pendingInteractions.has(interaction)) { - // Update the pending async work count for previously unscheduled interaction. - interaction.__count++; + if (family !== undefined) { + if (staleFamilies.has(family)) { + needsRemount = true; + } else if (updatedFamilies.has(family)) { + if (tag === ClassComponent) { + needsRemount = true; + } else { + needsRender = true; + } } + } + } - pendingInteractions.add(interaction); - }); - } else { - pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions. + if (failedBoundaries !== null) { + if ( + failedBoundaries.has(fiber) || + (alternate !== null && failedBoundaries.has(alternate)) + ) { + needsRemount = true; + } + } - interactions.forEach(function(interaction) { - interaction.__count++; - }); + if (needsRemount) { + fiber._debugNeedsRemount = true; } - var subscriber = tracing.__subscriberRef.current; + if (needsRemount || needsRender) { + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } - if (subscriber !== null) { - var threadID = computeThreadID(root, expirationTime); - subscriber.onWorkScheduled(interactions, threadID); + if (child !== null && !needsRemount) { + scheduleFibersWithFamiliesRecursively( + child, + updatedFamilies, + staleFamilies + ); } - } -} -function schedulePendingInteractions(root, expirationTime) { - scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); + if (sibling !== null) { + scheduleFibersWithFamiliesRecursively( + sibling, + updatedFamilies, + staleFamilies + ); + } + } } -function startWorkOnPendingInteractions(root, expirationTime) { - // we can accurately attribute time spent working on it, And so that cascading - // work triggered during the render phase will be associated with it. +var findHostInstancesForRefresh = function(root, families) { + { + var hostInstances = new Set(); + var types = new Set( + families.map(function(family) { + return family.current; + }) + ); + findHostInstancesForMatchingFibersRecursively( + root.current, + types, + hostInstances + ); + return hostInstances; + } +}; - var interactions = new Set(); - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - if (scheduledExpirationTime >= expirationTime) { - scheduledInteractions.forEach(function(interaction) { - return interactions.add(interaction); - }); - } - }); // Store the current set of interactions on the FiberRoot for a few reasons: - // We can re-use it in hot functions like performConcurrentWorkOnRoot() - // without having to recalculate it. We will also use it in commitWork() to - // pass to any Profiler onRender() hooks. This also provides DevTools with a - // way to access it when the onCommitRoot() hook is called. +function findHostInstancesForMatchingFibersRecursively( + fiber, + types, + hostInstances +) { + { + var child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; - root.memoizedInteractions = interactions; + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; - if (interactions.size > 0) { - var subscriber = tracing.__subscriberRef.current; + case ForwardRef: + candidateType = type.render; + break; + } - if (subscriber !== null) { - var threadID = computeThreadID(root, expirationTime); + var didMatch = false; - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { - throw error; - }); + if (candidateType !== null) { + if (types.has(candidateType)) { + didMatch = true; } } - } -} - -function finishPendingInteractions(root, committedExpirationTime) { - var earliestRemainingTimeAfterCommit = root.firstPendingTime; - var subscriber; - - try { - subscriber = tracing.__subscriberRef.current; - if (subscriber !== null && root.memoizedInteractions.size > 0) { - var threadID = computeThreadID(root, committedExpirationTime); - subscriber.onWorkStopped(root.memoizedInteractions, threadID); + if (didMatch) { + // We have a match. This only drills down to the closest host components. + // There's no need to search deeper because for the purpose of giving + // visual feedback, "flashing" outermost parent rectangles is sufficient. + findHostInstancesForFiberShallowly(fiber, hostInstances); + } else { + // If there's no match, maybe there will be one further down in the child tree. + if (child !== null) { + findHostInstancesForMatchingFibersRecursively( + child, + types, + hostInstances + ); + } } - } catch (error) { - // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { - throw error; - }); - } finally { - // Clear completed interactions from the pending Map. - // Unless the render was suspended or cascading work was scheduled, - // In which case– leave pending interactions until the subsequent render. - var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - // Only decrement the pending interaction count if we're done. - // If there's still work at the current priority, - // That indicates that we are waiting for suspense data. - if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { - pendingInteractionMap.delete(scheduledExpirationTime); - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - if (subscriber !== null && interaction.__count === 0) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { - throw error; - }); - } - } - }); - } - }); + if (sibling !== null) { + findHostInstancesForMatchingFibersRecursively( + sibling, + types, + hostInstances + ); + } } } -var onScheduleFiberRoot = null; -var onCommitFiberRoot = null; -var onCommitFiberUnmount = null; -var hasLoggedError = false; -var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; -function injectInternals(internals) { - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { - // No DevTools - return false; - } +function findHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var foundHostInstances = findChildHostInstancesForFiberShallowly( + fiber, + hostInstances + ); - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if (foundHostInstances) { + return; + } // If we didn't find any host children, fallback to closest host parent. - if (hook.isDisabled) { - // This isn't a real property on the hook, but it can be set to opt out - // of DevTools integration and associated warnings and logs. - // https://github.com/facebook/react/issues/3877 - return true; - } + var node = fiber; - if (!hook.supportsFiber) { - { - error( - "The installed version of React DevTools is too old and will not work " + - "with the current version of React. Please update React DevTools. " + - "https://fb.me/react-devtools" - ); - } // DevTools exists, even though it doesn't support Fiber. + while (true) { + switch (node.tag) { + case HostComponent: + hostInstances.add(node.stateNode); + return; - return true; - } + case HostPortal: + hostInstances.add(node.stateNode.containerInfo); + return; - try { - var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + case HostRoot: + hostInstances.add(node.stateNode.containerInfo); + return; + } - if (true) { - // Only used by Fast Refresh - if (typeof hook.onScheduleFiberRoot === "function") { - onScheduleFiberRoot = function(root, children) { - try { - hook.onScheduleFiberRoot(rendererID, root, children); - } catch (err) { - if (true && !hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - }; + if (node.return === null) { + throw new Error("Expected to reach root first."); } - } - onCommitFiberRoot = function(root, expirationTime) { - try { - var didError = (root.current.effectTag & DidCapture) === DidCapture; + node = node.return; + } + } +} - if (enableProfilerTimer) { - var currentTime = getCurrentTime(); - var priorityLevel = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); - hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); - } else { - hook.onCommitFiberRoot(rendererID, root, undefined, didError); - } - } catch (err) { - if (true) { - if (!hasLoggedError) { - hasLoggedError = true; +function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var node = fiber; + var foundHostInstances = false; - error("React instrumentation encountered an error: %s", err); - } - } + while (true) { + if (node.tag === HostComponent) { + // We got a match. + foundHostInstances = true; + hostInstances.add(node.stateNode); // There may still be more, so keep searching. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; } - }; - onCommitFiberUnmount = function(fiber) { - try { - hook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) { - if (true) { - if (!hasLoggedError) { - hasLoggedError = true; + if (node === fiber) { + return foundHostInstances; + } - error("React instrumentation encountered an error: %s", err); - } + while (node.sibling === null) { + if (node.return === null || node.return === fiber) { + return foundHostInstances; } + + node = node.return; } - }; - } catch (err) { - // Catch all errors because it is unsafe to throw during initialization. - { - error("React instrumentation encountered an error: %s.", err); - } - } // DevTools exists - return true; -} -function onScheduleRoot(root, children) { - if (typeof onScheduleFiberRoot === "function") { - onScheduleFiberRoot(root, children); - } -} -function onCommitRoot(root, expirationTime) { - if (typeof onCommitFiberRoot === "function") { - onCommitFiberRoot(root, expirationTime); - } -} -function onCommitUnmount(fiber) { - if (typeof onCommitFiberUnmount === "function") { - onCommitFiberUnmount(fiber); + node.sibling.return = node.return; + node = node.sibling; + } } + + return false; } var hasBadMapPolyfill; @@ -19629,13 +20613,11 @@ var hasBadMapPolyfill; try { var nonExtensibleObject = Object.preventExtensions({}); - var testMap = new Map([[nonExtensibleObject, null]]); - var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused. - // https://github.com/rollup/rollup/issues/1771 - // TODO: we can remove these if Rollup fixes the bug. + /* eslint-disable no-new */ - testMap.set(0, 0); - testSet.add(0); + new Map([[nonExtensibleObject, null]]); + new Set([nonExtensibleObject]); + /* eslint-enable no-new */ } catch (e) { // TODO: Consider warning about bad polyfills hasBadMapPolyfill = true; @@ -19664,12 +20646,12 @@ function FiberNode(tag, pendingProps, key, mode) { this.dependencies = null; this.mode = mode; // Effects - this.effectTag = NoEffect; + this.flags = NoFlags; this.nextEffect = null; this.firstEffect = null; this.lastEffect = null; - this.expirationTime = NoWork; - this.childExpirationTime = NoWork; + this.lanes = NoLanes; + this.childLanes = NoLanes; this.alternate = null; { @@ -19696,15 +20678,11 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.selfBaseDuration = 0; this.treeBaseDuration = 0; - } // This is normally DEV-only except www when it adds listeners. - // TODO: remove the User Timing integration in favor of Root Events. - - { - this._debugID = debugCounter++; - this._debugIsCurrentlyTiming = false; } { + // This isn't directly used but is handy for debugging internals: + this._debugID = debugCounter++; this._debugSource = null; this._debugOwner = null; this._debugNeedsRemount = false; @@ -19784,10 +20762,7 @@ function createWorkInProgress(current, pendingProps) { { // DEV-only fields - { - workInProgress._debugID = current._debugID; - } - + workInProgress._debugID = current._debugID; workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; workInProgress._debugHookTypes = current._debugHookTypes; @@ -19796,10 +20771,12 @@ function createWorkInProgress(current, pendingProps) { workInProgress.alternate = current; current.alternate = workInProgress; } else { - workInProgress.pendingProps = pendingProps; // We already have an alternate. + workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type. + + workInProgress.type = current.type; // We already have an alternate. // Reset the effect tag. - workInProgress.effectTag = NoEffect; // The effect list is no longer valid. + workInProgress.flags = NoFlags; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -19815,8 +20792,8 @@ function createWorkInProgress(current, pendingProps) { } } - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -19828,9 +20805,8 @@ function createWorkInProgress(current, pendingProps) { currentDependencies === null ? null : { - expirationTime: currentDependencies.expirationTime, - firstContext: currentDependencies.firstContext, - responders: currentDependencies.responders + lanes: currentDependencies.lanes, + firstContext: currentDependencies.firstContext }; // These will be overridden during the parent's reconciliation workInProgress.sibling = current.sibling; @@ -19865,7 +20841,7 @@ function createWorkInProgress(current, pendingProps) { return workInProgress; } // Used to reuse a Fiber for a second pass. -function resetWorkInProgress(workInProgress, renderExpirationTime) { +function resetWorkInProgress(workInProgress, renderLanes) { // This resets the Fiber to what createFiber or createWorkInProgress would // have set the values to before during the first pass. Ideally this wouldn't // be necessary but unfortunately many code paths reads from the workInProgress @@ -19874,7 +20850,7 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { // avoid doing another reconciliation. // Reset the effect tag but keep any Placement tags, since that's something // that child fiber is setting, not the reconciliation. - workInProgress.effectTag &= Placement; // The effect list is no longer valid. + workInProgress.flags &= Placement; // The effect list is no longer valid. workInProgress.nextEffect = null; workInProgress.firstEffect = null; @@ -19883,13 +20859,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { if (current === null) { // Reset to createFiber's initial values. - workInProgress.childExpirationTime = NoWork; - workInProgress.expirationTime = renderExpirationTime; + workInProgress.childLanes = NoLanes; + workInProgress.lanes = renderLanes; workInProgress.child = null; workInProgress.memoizedProps = null; workInProgress.memoizedState = null; workInProgress.updateQueue = null; workInProgress.dependencies = null; + workInProgress.stateNode = null; { // Note: We don't reset the actualTime counts. It's useful to accumulate @@ -19899,12 +20876,14 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { } } else { // Reset to the cloned values that createWorkInProgress would've. - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; - workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so + workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. + + workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so // it cannot be shared with the current fiber. var currentDependencies = current.dependencies; @@ -19912,9 +20891,8 @@ function resetWorkInProgress(workInProgress, renderExpirationTime) { currentDependencies === null ? null : { - expirationTime: currentDependencies.expirationTime, - firstContext: currentDependencies.firstContext, - responders: currentDependencies.responders + lanes: currentDependencies.lanes, + firstContext: currentDependencies.firstContext }; { @@ -19953,9 +20931,8 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - expirationTime + lanes ) { - var fiber; var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy. var resolvedType = type; @@ -19977,16 +20954,11 @@ function createFiberFromTypeAndProps( } else { getTag: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment( - pendingProps.children, - mode, - expirationTime, - key - ); + return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_CONCURRENT_MODE_TYPE: + case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = Mode; - mode |= ConcurrentMode | BlockingMode | StrictMode; + mode |= DebugTracingMode; break; case REACT_STRICT_MODE_TYPE: @@ -19995,18 +20967,23 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: - return createFiberFromProfiler(pendingProps, mode, expirationTime, key); + return createFiberFromProfiler(pendingProps, mode, lanes, key); case REACT_SUSPENSE_TYPE: - return createFiberFromSuspense(pendingProps, mode, expirationTime, key); + return createFiberFromSuspense(pendingProps, mode, lanes, key); case REACT_SUSPENSE_LIST_TYPE: - return createFiberFromSuspenseList( - pendingProps, - mode, - expirationTime, - key - ); + return createFiberFromSuspenseList(pendingProps, mode, lanes, key); + + case REACT_OFFSCREEN_TYPE: + return createFiberFromOffscreen(pendingProps, mode, lanes, key); + + case REACT_LEGACY_HIDDEN_TYPE: + return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); + + case REACT_SCOPE_TYPE: + + // eslint-disable-next-line no-fallthrough default: { if (typeof type === "object" && type !== null) { @@ -20078,13 +21055,18 @@ function createFiberFromTypeAndProps( } } - fiber = createFiber(fiberTag, pendingProps, key, mode); + var fiber = createFiber(fiberTag, pendingProps, key, mode); fiber.elementType = type; fiber.type = resolvedType; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; + + { + fiber._debugOwner = owner; + } + return fiber; } -function createFiberFromElement(element, mode, expirationTime) { +function createFiberFromElement(element, mode, lanes) { var owner = null; { @@ -20100,7 +21082,7 @@ function createFiberFromElement(element, mode, expirationTime) { pendingProps, owner, mode, - expirationTime + lanes ); { @@ -20110,13 +21092,13 @@ function createFiberFromElement(element, mode, expirationTime) { return fiber; } -function createFiberFromFragment(elements, mode, expirationTime, key) { +function createFiberFromFragment(elements, mode, lanes, key) { var fiber = createFiber(Fragment, elements, key, mode); - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; return fiber; } -function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { +function createFiberFromProfiler(pendingProps, mode, lanes, key) { { if (typeof pendingProps.id !== "string") { error('Profiler must specify an "id" as a prop'); @@ -20127,7 +21109,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; { fiber.stateNode = { @@ -20139,17 +21121,17 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { return fiber; } -function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { +function createFiberFromSuspense(pendingProps, mode, lanes, key) { var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. // This needs to be fixed in getComponentName so that it relies on the tag // instead. fiber.type = REACT_SUSPENSE_TYPE; fiber.elementType = REACT_SUSPENSE_TYPE; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; return fiber; } -function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { +function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); { @@ -20160,18 +21142,44 @@ function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { } fiber.elementType = REACT_SUSPENSE_LIST_TYPE; - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; + return fiber; +} +function createFiberFromOffscreen(pendingProps, mode, lanes, key) { + var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + + { + fiber.type = REACT_OFFSCREEN_TYPE; + } + + fiber.elementType = REACT_OFFSCREEN_TYPE; + fiber.lanes = lanes; + return fiber; +} +function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) { + var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + + { + fiber.type = REACT_LEGACY_HIDDEN_TYPE; + } + + fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; + fiber.lanes = lanes; return fiber; } -function createFiberFromText(content, mode, expirationTime) { +function createFiberFromText(content, mode, lanes) { var fiber = createFiber(HostText, content, null, mode); - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; return fiber; } -function createFiberFromPortal(portal, mode, expirationTime) { +function createFiberFromPortal(portal, mode, lanes) { var pendingProps = portal.children !== null ? portal.children : []; var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); - fiber.expirationTime = expirationTime; + fiber.lanes = lanes; fiber.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -20208,12 +21216,12 @@ function assignFiberPropertiesInDEV(target, source) { target.memoizedState = source.memoizedState; target.dependencies = source.dependencies; target.mode = source.mode; - target.effectTag = source.effectTag; + target.flags = source.flags; target.nextEffect = source.nextEffect; target.firstEffect = source.firstEffect; target.lastEffect = source.lastEffect; - target.expirationTime = source.expirationTime; - target.childExpirationTime = source.childExpirationTime; + target.lanes = source.lanes; + target.childLanes = source.childLanes; target.alternate = source.alternate; { @@ -20223,11 +21231,7 @@ function assignFiberPropertiesInDEV(target, source) { target.treeBaseDuration = source.treeBaseDuration; } - { - target._debugID = source._debugID; - target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; - } - + target._debugID = source._debugID; target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugNeedsRemount = source._debugNeedsRemount; @@ -20237,30 +21241,49 @@ function assignFiberPropertiesInDEV(target, source) { function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; - this.current = null; this.containerInfo = containerInfo; this.pendingChildren = null; + this.current = null; this.pingCache = null; - this.finishedExpirationTime = NoWork; this.finishedWork = null; this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = NoPriority; - this.firstPendingTime = NoWork; - this.firstSuspendedTime = NoWork; - this.lastSuspendedTime = NoWork; - this.nextKnownPendingLevel = NoWork; - this.lastPingedTime = NoWork; - this.lastExpiredTime = NoWork; + this.callbackPriority = NoLanePriority; + this.eventTimes = createLaneMap(NoLanes); + this.expirationTimes = createLaneMap(NoTimestamp); + this.pendingLanes = NoLanes; + this.suspendedLanes = NoLanes; + this.pingedLanes = NoLanes; + this.expiredLanes = NoLanes; + this.mutableReadLanes = NoLanes; + this.finishedLanes = NoLanes; + this.entangledLanes = NoLanes; + this.entanglements = createLaneMap(NoLanes); { this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } + + { + switch (tag) { + case BlockingRoot: + this._debugRootType = "createBlockingRoot()"; + break; + + case ConcurrentRoot: + this._debugRootType = "createRoot()"; + break; + + case LegacyRoot: + this._debugRootType = "createLegacyRoot()"; + break; + } + } } function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { @@ -20273,95 +21296,22 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { initializeUpdateQueue(uninitializedFiber); return root; } -function isRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - var lastSuspendedTime = root.lastSuspendedTime; - return ( - firstSuspendedTime !== NoWork && - firstSuspendedTime >= expirationTime && - lastSuspendedTime <= expirationTime - ); -} -function markRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - var lastSuspendedTime = root.lastSuspendedTime; - - if (firstSuspendedTime < expirationTime) { - root.firstSuspendedTime = expirationTime; - } - - if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) { - root.lastSuspendedTime = expirationTime; - } - - if (expirationTime <= root.lastPingedTime) { - root.lastPingedTime = NoWork; - } - - if (expirationTime <= root.lastExpiredTime) { - root.lastExpiredTime = NoWork; - } -} -function markRootUpdatedAtTime(root, expirationTime) { - // Update the range of pending times - var firstPendingTime = root.firstPendingTime; - - if (expirationTime > firstPendingTime) { - root.firstPendingTime = expirationTime; - } // Update the range of suspended times. Treat everything lower priority or - // equal to this update as unsuspended. - var firstSuspendedTime = root.firstSuspendedTime; - - if (firstSuspendedTime !== NoWork) { - if (expirationTime >= firstSuspendedTime) { - // The entire suspended range is now unsuspended. - root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; - } else if (expirationTime >= root.lastSuspendedTime) { - root.lastSuspendedTime = expirationTime + 1; - } // This is a pending level. Check if it's higher priority than the next - // known pending level. - - if (expirationTime > root.nextKnownPendingLevel) { - root.nextKnownPendingLevel = expirationTime; - } - } -} -function markRootFinishedAtTime( - root, - finishedExpirationTime, - remainingExpirationTime +function createPortal( + children, + containerInfo, // TODO: figure out the API for cross-renderer implementation. + implementation ) { - // Update the range of pending times - root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or - // equal to this update as unsuspended. - - if (finishedExpirationTime <= root.lastSuspendedTime) { - // The entire suspended range is now unsuspended. - root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; - } else if (finishedExpirationTime <= root.firstSuspendedTime) { - // Part of the suspended range is now unsuspended. Narrow the range to - // include everything between the unsuspended time (non-inclusive) and the - // last suspended time. - root.firstSuspendedTime = finishedExpirationTime - 1; - } - - if (finishedExpirationTime <= root.lastPingedTime) { - // Clear the pinged time - root.lastPingedTime = NoWork; - } - - if (finishedExpirationTime <= root.lastExpiredTime) { - // Clear the expired time - root.lastExpiredTime = NoWork; - } -} -function markRootExpiredAtTime(root, expirationTime) { - var lastExpiredTime = root.lastExpiredTime; - - if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) { - root.lastExpiredTime = expirationTime; - } + var key = + arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + return { + // This tag allow us to uniquely identify this as a React Portal + $$typeof: REACT_PORTAL_TYPE, + key: key == null ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } var didWarnAboutNestedUpdates; @@ -20421,31 +21371,42 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; + var previousFiber = current; - if (fiber.mode & StrictMode) { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which is inside StrictMode. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node%s", - methodName, - methodName, - componentName, - getStackByFiberInDevAndProd(hostFiber) - ); - } else { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which renders StrictMode children. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node%s", - methodName, - methodName, - componentName, - getStackByFiberInDevAndProd(hostFiber) - ); + try { + setCurrentFiber(hostFiber); + + if (fiber.mode & StrictMode) { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which is inside StrictMode. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-find-node", + methodName, + methodName, + componentName + ); + } else { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which renders StrictMode children. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-find-node", + methodName, + methodName, + componentName + ); + } + } finally { + // Ideally this should reset to previous but this shouldn't be called in + // render and there's another warning for that anyway. + if (previousFiber) { + setCurrentFiber(previousFiber); + } else { + resetCurrentFiber(); + } } } } @@ -20463,7 +21424,7 @@ function updateContainer(element, container, parentComponent, callback) { } var current$1 = container.current; - var currentTime = requestCurrentTimeForUpdate(); + var eventTime = requestEventTime(); { // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests @@ -20473,12 +21434,8 @@ function updateContainer(element, container, parentComponent, callback) { } } - var suspenseConfig = requestCurrentSuspenseConfig(); - var expirationTime = computeExpirationForFiber( - currentTime, - current$1, - suspenseConfig - ); + var lane = requestUpdateLane(current$1); + var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -20501,7 +21458,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property + var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property // being called "element". update.payload = { @@ -20524,8 +21481,8 @@ function updateContainer(element, container, parentComponent, callback) { } enqueueUpdate(current$1, update); - scheduleWork(current$1, expirationTime); - return expirationTime; + scheduleUpdateOnFiber(current$1, lane, eventTime); + return lane; } function getPublicRootInstance(container) { var containerFiber = container.current; @@ -20551,28 +21508,102 @@ function shouldSuspend(fiber) { return shouldSuspendImpl(fiber); } var overrideHookState = null; +var overrideHookStateDeletePath = null; +var overrideHookStateRenamePath = null; var overrideProps = null; +var overridePropsDeletePath = null; +var overridePropsRenamePath = null; var scheduleUpdate = null; var setSuspenseHandler = null; { - var copyWithSetImpl = function(obj, path, idx, value) { - if (idx >= path.length) { + var copyWithDeleteImpl = function(obj, path, index) { + var key = path[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === path.length) { + if (Array.isArray(updated)) { + updated.splice(key, 1); + } else { + delete updated[key]; + } + + return updated; + } // $FlowFixMe number or string is fine here + + updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); + return updated; + }; + + var copyWithDelete = function(obj, path) { + return copyWithDeleteImpl(obj, path, 0); + }; + + var copyWithRenameImpl = function(obj, oldPath, newPath, index) { + var oldKey = oldPath[index]; + var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); + + if (index + 1 === oldPath.length) { + var newKey = newPath[index]; // $FlowFixMe number or string is fine here + + updated[newKey] = updated[oldKey]; + + if (Array.isArray(updated)) { + updated.splice(oldKey, 1); + } else { + delete updated[oldKey]; + } + } else { + // $FlowFixMe number or string is fine here + updated[oldKey] = copyWithRenameImpl( + // $FlowFixMe number or string is fine here + obj[oldKey], + oldPath, + newPath, + index + 1 + ); + } + + return updated; + }; + + var copyWithRename = function(obj, oldPath, newPath) { + if (oldPath.length !== newPath.length) { + warn("copyWithRename() expects paths of the same length"); + + return; + } else { + for (var i = 0; i < newPath.length - 1; i++) { + if (oldPath[i] !== newPath[i]) { + warn( + "copyWithRename() expects paths to be the same except for the deepest key" + ); + + return; + } + } + } + + return copyWithRenameImpl(obj, oldPath, newPath, 0); + }; + + var copyWithSetImpl = function(obj, path, index, value) { + if (index >= path.length) { return value; } - var key = path[idx]; + var key = path[index]; var updated = Array.isArray(obj) ? obj.slice() : Object.assign({}, obj); // $FlowFixMe number or string is fine here - updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value); + updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); return updated; }; var copyWithSet = function(obj, path, value) { return copyWithSetImpl(obj, path, 0, value); - }; // Support DevTools editable values for useState and useReducer. + }; - overrideHookState = function(fiber, id, path, value) { + var findHook = function(fiber, id) { // For now, the "id" of stateful hooks is just the stateful hook index. // This may change in the future with e.g. nested hooks. var currentHook = fiber.memoizedState; @@ -20582,17 +21613,57 @@ var setSuspenseHandler = null; id--; } - if (currentHook !== null) { - var newState = copyWithSet(currentHook.memoizedState, path, value); - currentHook.memoizedState = newState; - currentHook.baseState = newState; // We aren't actually adding an update to the queue, + return currentHook; + }; // Support DevTools editable values for useState and useReducer. + + overrideHookState = function(fiber, id, path, value) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithSet(hook.memoizedState, path, value); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateDeletePath = function(fiber, id, path) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithDelete(hook.memoizedState, path); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithRename(hook.memoizedState, oldPath, newPath); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, // because there is no update we can add for useReducer hooks that won't trigger an error. // (There's no appropriate action type for DevTools overrides.) // As a result though, React will see the scheduled update as a noop and bailout. // Shallow cloning props works as a workaround for now to bypass the bailout check. fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); - scheduleWork(fiber, Sync); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); } }; // Support DevTools props for function components, forwardRef, memo, host components, etc. @@ -20603,11 +21674,31 @@ var setSuspenseHandler = null; fiber.alternate.pendingProps = fiber.pendingProps; } - scheduleWork(fiber, Sync); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsDeletePath = function(fiber, path) { + fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsRenamePath = function(fiber, oldPath, newPath) { + fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; scheduleUpdate = function(fiber) { - scheduleWork(fiber, Sync); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); }; setSuspenseHandler = function(newShouldSuspendImpl) { @@ -20615,6 +21706,24 @@ var setSuspenseHandler = null; }; } +function findHostInstanceByFiber(fiber) { + var hostFiber = findCurrentHostFiber(fiber); + + if (hostFiber === null) { + return null; + } + + return hostFiber.stateNode; +} + +function emptyFindFiberByHostInstance(instance) { + return null; +} + +function getCurrentFiberForDevTools() { + return current; +} + function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; @@ -20624,59 +21733,26 @@ function injectIntoDevTools(devToolsConfig) { rendererPackageName: devToolsConfig.rendererPackageName, rendererConfig: devToolsConfig.rendererConfig, overrideHookState: overrideHookState, + overrideHookStateDeletePath: overrideHookStateDeletePath, + overrideHookStateRenamePath: overrideHookStateRenamePath, overrideProps: overrideProps, + overridePropsDeletePath: overridePropsDeletePath, + overridePropsRenamePath: overridePropsRenamePath, setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - var hostFiber = findCurrentHostFiber(fiber); - - if (hostFiber === null) { - return null; - } - - return hostFiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - if (!findFiberByHostInstance) { - // Might not be implemented by the renderer. - return null; - } - - return findFiberByHostInstance(instance); - }, + findHostInstanceByFiber: findHostInstanceByFiber, + findFiberByHostInstance: + findFiberByHostInstance || emptyFindFiberByHostInstance, // React Refresh findHostInstancesForRefresh: findHostInstancesForRefresh, scheduleRefresh: scheduleRefresh, scheduleRoot: scheduleRoot, setRefreshHandler: setRefreshHandler, // Enables DevTools to append owner stacks to error messages in DEV mode. - getCurrentFiber: function() { - return current; - } + getCurrentFiber: getCurrentFiberForDevTools }); } -var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing; - -function createPortal( - children, - containerInfo, // TODO: figure out the API for cross-renderer implementation. - implementation -) { - var key = - arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - return { - // This tag allow us to uniquely identify this as a React Portal - $$typeof: REACT_PORTAL_TYPE, - key: key == null ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; -} - -// TODO: this is special because it gets imported during build. -var ReactVersion = "16.13.0"; var emptyObject$1 = {}; @@ -20907,7 +21983,7 @@ var getInspectorDataForViewAtPoint; ); } else { error( - "getInspectorDataForViewAtPoint expects to receieve a host component" + "getInspectorDataForViewAtPoint expects to receive a host component" ); return; diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 53bb58b0fe5575..b113a690434868 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -919,7 +919,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_228 = { +var injectedNamesToPlugins$jscomp$inline_222 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -954,34 +954,34 @@ var injectedNamesToPlugins$jscomp$inline_228 = { } } }, - isOrderingDirty$jscomp$inline_229 = !1, - pluginName$jscomp$inline_230; -for (pluginName$jscomp$inline_230 in injectedNamesToPlugins$jscomp$inline_228) + isOrderingDirty$jscomp$inline_223 = !1, + pluginName$jscomp$inline_224; +for (pluginName$jscomp$inline_224 in injectedNamesToPlugins$jscomp$inline_222) if ( - injectedNamesToPlugins$jscomp$inline_228.hasOwnProperty( - pluginName$jscomp$inline_230 + injectedNamesToPlugins$jscomp$inline_222.hasOwnProperty( + pluginName$jscomp$inline_224 ) ) { - var pluginModule$jscomp$inline_231 = - injectedNamesToPlugins$jscomp$inline_228[pluginName$jscomp$inline_230]; + var pluginModule$jscomp$inline_225 = + injectedNamesToPlugins$jscomp$inline_222[pluginName$jscomp$inline_224]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_230) || - namesToPlugins[pluginName$jscomp$inline_230] !== - pluginModule$jscomp$inline_231 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_224) || + namesToPlugins[pluginName$jscomp$inline_224] !== + pluginModule$jscomp$inline_225 ) { - if (namesToPlugins[pluginName$jscomp$inline_230]) + if (namesToPlugins[pluginName$jscomp$inline_224]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_230 + + pluginName$jscomp$inline_224 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_230 - ] = pluginModule$jscomp$inline_231; - isOrderingDirty$jscomp$inline_229 = !0; + pluginName$jscomp$inline_224 + ] = pluginModule$jscomp$inline_225; + isOrderingDirty$jscomp$inline_223 = !0; } } -isOrderingDirty$jscomp$inline_229 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_223 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1221,7 +1221,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1738,7 +1738,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1773,28 +1773,24 @@ var rendererID = null, injectedHook = null, Scheduler_now = Scheduler.unstable_now; Scheduler_now(); -var return_highestLanePriority = 10; +var return_highestLanePriority = 8; function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 6), inputDiscreteLanes; inputDiscreteLanes = 62914560 & lanes; @@ -1808,18 +1804,18 @@ function getHighestPriorityLanes(lanes) { return (return_highestLanePriority = 2), inputDiscreteLanes; if (0 !== (1073741824 & lanes)) return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; + return_highestLanePriority = 8; return lanes; } function schedulerPriorityToLanePriority(schedulerPriorityLevel) { switch (schedulerPriorityLevel) { case 99: - return 17; + return 15; case 98: - return 12; + return 10; case 97: case 96: - return 10; + return 8; case 95: return 2; default: @@ -1828,16 +1824,14 @@ function schedulerPriorityToLanePriority(schedulerPriorityLevel) { } function lanePriorityToSchedulerPriority(lanePriority) { switch (lanePriority) { - case 17: - case 16: - return 99; case 15: case 14: + return 99; case 13: case 12: - return 98; case 11: case 10: + return 98; case 9: case 8: case 7: @@ -1867,7 +1861,7 @@ function getNextLanes(root, wipLanes) { pingedLanes = root.pingedLanes; if (0 !== expiredLanes) (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); + (nextLanePriority = return_highestLanePriority = 15); else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; 0 !== nonIdleUnblockedLanes @@ -1906,42 +1900,31 @@ function getNextLanes(root, wipLanes) { (wipLanes &= ~nextLanePriority); return nextLanes; } -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6; - index$6 = root[index$6]; - index$6 > mostRecentEventTime && (mostRecentEventTime = index$6); - lanes &= ~lane; - } - return mostRecentEventTime; -} function getLanesToRetrySynchronouslyOnError(root) { root = root.pendingLanes & -1073741825; return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; } function findUpdateLane(lanePriority, wipLanes) { switch (lanePriority) { - case 17: + case 15: return 1; - case 16: - return 2; case 14: + return 2; + case 12: return ( (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority ); - case 12: + case 10: return ( (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority ); - case 10: + case 8: return ( (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), 0 === lanePriority && (lanePriority = 512)), lanePriority ); @@ -1959,8 +1942,9 @@ function findUpdateLane(lanePriority, wipLanes) { function getHighestPriorityLane(lanes) { return lanes & -lanes; } -function pickArbitraryLane(lanes) { - return lanes & -lanes; +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; } function markRootUpdated(root, updateLane, eventTime) { root.pendingLanes |= updateLane; @@ -2077,6 +2061,32 @@ function flushSyncCallbackQueueImpl() { } } } +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; +function is(x, y) { + return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); +} +var objectIs = "function" === typeof Object.is ? Object.is : is, + hasOwnProperty = Object.prototype.hasOwnProperty; +function shallowEqual(objA, objB) { + if (objectIs(objA, objB)) return !0; + if ( + "object" !== typeof objA || + null === objA || + "object" !== typeof objB || + null === objB + ) + return !1; + var keysA = Object.keys(objA), + keysB = Object.keys(objB); + if (keysA.length !== keysB.length) return !1; + for (keysB = 0; keysB < keysA.length; keysB++) + if ( + !hasOwnProperty.call(objB, keysA[keysB]) || + !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) + ) + return !1; + return !0; +} function describeFiber(fiber) { switch (fiber.tag) { case 5: @@ -2113,31 +2123,6 @@ function getStackByFiberInDevAndProd(workInProgress) { return "\nError generating stack: " + x.message + "\n" + x.stack; } } -function is(x, y) { - return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); -} -var objectIs = "function" === typeof Object.is ? Object.is : is, - hasOwnProperty = Object.prototype.hasOwnProperty; -function shallowEqual(objA, objB) { - if (objectIs(objA, objB)) return !0; - if ( - "object" !== typeof objA || - null === objA || - "object" !== typeof objB || - null === objB - ) - return !1; - var keysA = Object.keys(objA), - keysB = Object.keys(objB); - if (keysA.length !== keysB.length) return !1; - for (keysB = 0; keysB < keysA.length; keysB++) - if ( - !hasOwnProperty.call(objB, keysA[keysB]) || - !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) - ) - return !1; - return !0; -} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2231,11 +2216,10 @@ function cloneUpdateQueue(current, workInProgress) { effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(eventTime, lane) { return { eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, @@ -2268,7 +2252,6 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { var clone = { eventTime: queue.eventTime, lane: queue.lane, - suspenseConfig: queue.suspenseConfig, tag: queue.tag, payload: queue.payload, callback: queue.callback, @@ -2342,16 +2325,11 @@ function processUpdateQueue( (current = current.next = { eventTime: updateEventTime, lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, next: null }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); a: { var workInProgress = workInProgress$jscomp$0, update = firstBaseUpdate; @@ -2371,8 +2349,7 @@ function processUpdateQueue( currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; pendingQueue = @@ -2395,7 +2372,7 @@ function processUpdateQueue( } } null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), + ((workInProgress$jscomp$0.flags |= 32), (pendingQueue = queue.effects), null === pendingQueue ? (queue.effects = [firstBaseUpdate]) @@ -2404,7 +2381,6 @@ function processUpdateQueue( (updateEventTime = { eventTime: updateEventTime, lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, @@ -2456,8 +2432,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2483,41 +2458,32 @@ var classComponentUpdater = { enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); } }; @@ -2610,7 +2576,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2625,7 +2591,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2659,7 +2625,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2683,7 +2649,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2715,16 +2681,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -3258,12 +3224,14 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3323,7 +3291,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim() || shim())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3355,7 +3323,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3480,40 +3448,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3598,10 +3560,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), + (maybeNewVersion = requestUpdateLane(fiber)), (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); maybeNewVersion = root.mutableReadLanes; root.entangledLanes |= maybeNewVersion; @@ -3610,9 +3569,9 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { 0 < lanes; ) { - var index$14 = 31 - clz32(lanes), - lane = 1 << index$14; - entanglements[index$14] |= maybeNewVersion; + var index$13 = 31 - clz32(lanes), + lane = 1 << index$13; + entanglements[index$13] |= maybeNewVersion; lanes &= ~lane; } } @@ -3626,7 +3585,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { latestSetSnapshot = refs.setSnapshot; try { latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); + var lane = requestUpdateLane(fiber); root.mutableReadLanes |= lane & root.pendingLanes; } catch (error) { latestSetSnapshot(function() { @@ -3697,17 +3656,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3715,12 +3674,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3759,13 +3718,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3793,39 +3745,36 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); - suspenseConfig = { - eventTime: eventTime, - lane: lane, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3841,8 +3790,8 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { @@ -3870,7 +3819,13 @@ var ContextOnlyDispatcher = { }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3916,36 +3871,30 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; }, useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); @@ -3975,36 +3924,27 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -4026,36 +3966,27 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -4097,11 +4028,11 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } @@ -4138,7 +4069,7 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, renderLanes ); @@ -4155,7 +4086,7 @@ function updateMemoComponent( Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4175,7 +4106,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -4230,7 +4161,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4255,11 +4186,11 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } @@ -4279,7 +4210,7 @@ function updateClassComponent( null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); @@ -4345,9 +4276,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -4355,7 +4286,7 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); } else { instance = workInProgress.stateNode; @@ -4428,17 +4359,17 @@ function updateClassComponent( oldContext )), "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4448,11 +4379,11 @@ function updateClassComponent( : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4473,7 +4404,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4485,7 +4416,7 @@ function finishClassComponent( didCaptureError && "function" !== typeof Component.getDerivedStateFromError ? null : shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((workInProgress.child = reconcileChildFibers( workInProgress, @@ -4522,50 +4453,48 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { + current = nextProps.children; + suspenseContext = nextProps.fallback; if (showFallback) return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps)) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( + (current = mountSuspenseFallbackChildren( + workInProgress, current, suspenseContext, - renderLanes, - null + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + current + ); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), current ); renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, + { mode: "visible", children: current }, workInProgress.mode, renderLanes, null @@ -4583,13 +4512,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4611,13 +4540,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4630,6 +4559,36 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { workInProgress.memoizedState = null; return renderLanes; } +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren)) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; +} function updateSuspensePrimaryChildren( current, workInProgress, @@ -4647,7 +4606,7 @@ function updateSuspensePrimaryChildren( primaryChildren.sibling = null; null !== current && ((current.nextEffect = null), - (current.effectTag = 8), + (current.flags = 8), (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } @@ -4684,7 +4643,7 @@ function updateSuspenseFallbackChildren( renderLanes, null )), - (fallbackChildren.effectTag |= 2)); + (fallbackChildren.flags |= 2)); fallbackChildren.return = workInProgress; primaryChildren.return = workInProgress; primaryChildren.sibling = fallbackChildren; @@ -4713,7 +4672,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4722,7 +4680,6 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } @@ -4733,9 +4690,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4870,10 +4827,10 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && (requiredContext(contextStackCursor$1.current), (workInProgress.updateQueue = UPDATE_SIGNAL)) && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); }; updateHostText$1 = function(current, workInProgress, oldText, newText) { - oldText !== newText && (workInProgress.effectTag |= 4); + oldText !== newText && (workInProgress.flags |= 4); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4927,7 +4884,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -4945,8 +4902,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4980,8 +4936,8 @@ function completeWork(current, workInProgress, renderLanes) { appendAllChildren(rootContainerInstance, workInProgress, !1, !1); workInProgress.stateNode = rootContainerInstance; finalizeInitialChildren(rootContainerInstance) && - (workInProgress.effectTag |= 4); - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + (workInProgress.flags |= 4); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -5016,7 +4972,7 @@ function completeWork(current, workInProgress, renderLanes) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) + if (0 !== (workInProgress.flags & 64)) return (workInProgress.lanes = renderLanes), workInProgress; newProps = null !== newProps; rootContainerInstance = !1; @@ -5044,7 +5000,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; + if (newProps || rootContainerInstance) workInProgress.flags |= 4; return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -5056,24 +5012,24 @@ function completeWork(current, workInProgress, renderLanes) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.effectTag & 64)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; @@ -5081,7 +5037,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (renderLanes = current), - (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), @@ -5123,6 +5079,12 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); } else { if (!rootContainerInstance) @@ -5130,12 +5092,12 @@ function completeWork(current, workInProgress, renderLanes) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -5148,12 +5110,13 @@ function completeWork(current, workInProgress, renderLanes) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes)); + (workInProgress.lanes = 33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5164,9 +5127,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -5189,7 +5150,7 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), null ); } @@ -5203,32 +5164,30 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); resetWorkInProgressVersions(); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null ); case 19: @@ -5275,7 +5234,7 @@ function logCapturedError(boundary, errorInfo) { } var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; lane.payload = { element: null }; var error = errorInfo.value; @@ -5286,7 +5245,7 @@ function createRootErrorUpdate(fiber, errorInfo, lane) { return lane; } function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { @@ -5332,7 +5291,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -5393,7 +5352,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && + finishedWork.flags & 4 && (null === current ? finishedRoot.componentDidMount() : ((create$81 = @@ -5606,7 +5565,7 @@ function commitPlacement(finishedWork) { "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } - parentFiber.effectTag & 16 && (parentFiber.effectTag &= -17); + parentFiber.flags & 16 && (parentFiber.flags &= -17); a: b: for (parentFiber = finishedWork; ; ) { for (; null === parentFiber.sibling; ) { if (null === parentFiber.return || isHostParent(parentFiber.return)) { @@ -5621,13 +5580,13 @@ function commitPlacement(finishedWork) { 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag; ) { - if (parentFiber.effectTag & 2) continue b; + if (parentFiber.flags & 2) continue b; if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); } - if (!(parentFiber.effectTag & 2)) { + if (!(parentFiber.flags & 2)) { parentFiber = parentFiber.stateNode; break a; } @@ -5947,14 +5906,13 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, - workInProgressRootCanSuspendUsingConfig = null, workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5979,46 +5937,33 @@ function requestEventTime() { ? currentEventTime : (currentEventTime = now()); } -function requestUpdateLane(fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; if (0 === (fiber & 2)) return 1; if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; 0 === currentEventWipLanes && (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; + if (0 !== ReactCurrentBatchConfig.transition) { 0 !== currentEventPendingLanes && (currentEventPendingLanes = null !== mostRecentlyUpdatedRoot ? mostRecentlyUpdatedRoot.pendingLanes : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (50 < nestedUpdateCount) @@ -6039,7 +5984,9 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) ? performSyncWorkOnRoot(fiber) : (ensureRootIsScheduled(fiber, eventTime), - 0 === executionContext && flushSyncCallbackQueue()) + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) : (0 === (executionContext & 4) || (98 !== priorityLevel && 99 !== priorityLevel) || (null === rootsWithPendingDiscreteUpdates @@ -6080,8 +6027,8 @@ function ensureRootIsScheduled(root, currentTime) { getHighestPriorityLanes(lane); var priority = return_highestLanePriority; expirationTimes[index$7] = - 12 <= priority - ? expirationTime + 1e3 + 10 <= priority + ? expirationTime + 250 : 6 <= priority ? expirationTime + 5e3 : -1; @@ -6106,7 +6053,7 @@ function ensureRootIsScheduled(root, currentTime) { existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode); } - 17 === currentTime + 15 === currentTime ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), null === syncQueue ? ((syncQueue = [existingCallbackNode]), @@ -6116,7 +6063,7 @@ function ensureRootIsScheduled(root, currentTime) { ))) : syncQueue.push(existingCallbackNode), (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime + : 14 === currentTime ? (existingCallbackNode = scheduleCallback( 99, performSyncWorkOnRoot.bind(null, root) @@ -6130,7 +6077,7 @@ function ensureRootIsScheduled(root, currentTime) { root.callbackNode = existingCallbackNode; } } -function performConcurrentWorkOnRoot(root, didTimeout) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) @@ -6143,19 +6090,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); - didTimeout = lanes; + var exitStatus = lanes; var prevExecutionContext = executionContext; executionContext |= 16; var prevDispatcher = pushDispatcher(); - (workInProgressRoot === root && - workInProgressRootRenderLanes === didTimeout) || - prepareFreshStack(root, didTimeout); + if ( + workInProgressRoot !== root || + workInProgressRootRenderLanes !== exitStatus + ) + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, exitStatus); do try { workLoopConcurrent(); @@ -6168,19 +6112,19 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ReactCurrentDispatcher$2.current = prevDispatcher; executionContext = prevExecutionContext; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = 0) : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); + (exitStatus = workInProgressRootExitStatus)); if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && + else if (0 !== exitStatus) { + 2 === exitStatus && ((executionContext |= 64), root.hydrate && (root.hydrate = !1), (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended$1(root, lanes), @@ -6188,7 +6132,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { originalCallbackNode); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; - switch (didTimeout) { + switch (exitStatus) { case 0: case 1: throw Error("Root did not complete. This is a bug in React."); @@ -6199,8 +6143,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes); if ( (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevExecutionContext = root.suspendedLanes; @@ -6211,7 +6155,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -6219,33 +6163,31 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) { + var index$6 = 31 - clz32(lanes); + prevDispatcher = 1 << index$6; + index$6 = exitStatus[index$6]; + index$6 > prevExecutionContext && (prevExecutionContext = index$6); + lanes &= ~prevDispatcher; } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), @@ -6256,30 +6198,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { commitRoot(root); break; case 5: - prevDispatcher = getMostRecentEventTime(root, lanes); - if ( - -1 !== prevDispatcher && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevExecutionContext = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (prevDispatcher = now() - prevDispatcher), - (didTimeout = - prevDispatcher <= prevExecutionContext - ? 0 - : prevExecutionContext + didTimeout - prevDispatcher)), - 10 < didTimeout) - ) { - markRootSuspended$1(root, lanes); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - didTimeout - ); - break; - } commitRoot(root); break; default: @@ -6297,9 +6215,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$12 = 31 - clz32(suspendedLanes), - lane = 1 << index$12; - root[index$12] = -1; + var index$11 = 31 - clz32(suspendedLanes), + lane = 1 << index$11; + root[index$11] = -1; suspendedLanes &= ~lane; } } @@ -6393,8 +6311,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; - workInProgressRootCanSuspendUsingConfig = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; } function handleError(root$jscomp$0, thrownValue) { @@ -6431,7 +6347,7 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.effectTag |= 2048; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -6477,13 +6393,13 @@ function handleError(root$jscomp$0, thrownValue) { workInProgress$76.updateQueue = updateQueue; } else wakeables.add(wakeable); if (0 === (workInProgress$76.mode & 2)) { - workInProgress$76.effectTag |= 64; - sourceFiber.effectTag |= 16384; - sourceFiber.effectTag &= -2981; + workInProgress$76.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } @@ -6510,7 +6426,7 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$76.effectTag |= 4096; + workInProgress$76.flags |= 8192; workInProgress$76.lanes = thrownValue; break a; } @@ -6529,7 +6445,7 @@ function handleError(root$jscomp$0, thrownValue) { switch (workInProgress$76.tag) { case 3: root = value; - workInProgress$76.effectTag |= 4096; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; workInProgress$76.lanes |= thrownValue; var update$77 = createRootErrorUpdate( @@ -6544,14 +6460,14 @@ function handleError(root$jscomp$0, thrownValue) { var ctor = workInProgress$76.type, instance = workInProgress$76.stateNode; if ( - 0 === (workInProgress$76.effectTag & 64) && + 0 === (workInProgress$76.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$76.effectTag |= 4096; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; workInProgress$76.lanes |= thrownValue; var update$80 = createClassErrorUpdate( @@ -6582,13 +6498,6 @@ function pushDispatcher() { ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); -} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 16; @@ -6632,7 +6541,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { + if (0 === (completedWork.flags & 4096)) { current = completeWork(current, completedWork, subtreeRenderLanes); if (null !== current) { workInProgress = current; @@ -6651,14 +6560,14 @@ function completeUnitOfWork(unitOfWork) { current.childLanes = newChildLanes; } null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && (unitOfWork.firstEffect = completedWork.firstEffect), null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + 1 < completedWork.flags && (null !== unitOfWork.lastEffect ? (unitOfWork.lastEffect.nextEffect = completedWork) : (unitOfWork.firstEffect = completedWork), @@ -6666,13 +6575,13 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.effectTag &= 2047; + current.flags &= 4095; workInProgress = current; return; } null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -6717,11 +6626,11 @@ function commitRootImpl(root, renderPriorityLevel) { 0 < noLongerPendingLanes; ) { - var index$13 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$13; - remainingLanes$jscomp$0[index$13] = 0; - eventTimes[index$13] = -1; - expirationTimes[index$13] = -1; + var index$12 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$12; + remainingLanes$jscomp$0[index$12] = 0; + eventTimes[index$12] = -1; + expirationTimes[index$12] = -1; noLongerPendingLanes &= ~lane; } null !== rootsWithPendingDiscreteUpdates && @@ -6731,7 +6640,7 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - 1 < finishedWork.effectTag + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), (remainingLanes = finishedWork.firstEffect)) @@ -6757,8 +6666,8 @@ function commitRootImpl(root, renderPriorityLevel) { do try { for (eventTimes = root; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6768,21 +6677,21 @@ function commitRootImpl(root, renderPriorityLevel) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: @@ -6797,9 +6706,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$93) { + } catch (error$88) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$93); + captureCommitPhaseError(nextEffect, error$88); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6807,11 +6716,11 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = remainingLanes; do try { - for (effectTag = root; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { @@ -6830,9 +6739,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$94) { + } catch (error$89) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$94); + captureCommitPhaseError(nextEffect, error$89); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6848,10 +6757,10 @@ function commitRootImpl(root, renderPriorityLevel) { for (nextEffect = remainingLanes; null !== nextEffect; ) (renderPriorityLevel = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && - ((effectTag$jscomp$0 = nextEffect), - (effectTag$jscomp$0.sibling = null), - (effectTag$jscomp$0.stateNode = null)), + nextEffect.flags & 8 && + ((flags$jscomp$0 = nextEffect), + (flags$jscomp$0.sibling = null), + (flags$jscomp$0.stateNode = null)), (nextEffect = renderPriorityLevel); remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); @@ -6867,7 +6776,7 @@ function commitRootImpl(root, renderPriorityLevel) { rendererID, finishedWork, void 0, - 64 === (finishedWork.current.effectTag & 64) + 64 === (finishedWork.current.flags & 64) ); } catch (err) {} ensureRootIsScheduled(root, now()); @@ -6885,17 +6794,16 @@ function commitBeforeMutationEffects() { var current = nextEffect.alternate; shouldFireAfterActiveInstanceBlur || null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) + (0 !== (nextEffect.flags & 8) ? doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0) : 13 === nextEffect.tag && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0)); - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); - 0 === (effectTag & 512) || + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -6912,7 +6820,6 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } return !1; @@ -6946,10 +6853,10 @@ function flushPassiveEffectsImpl() { var unmountEffects = pendingPassiveHookEffectsUnmount; pendingPassiveHookEffectsUnmount = []; for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$99 = unmountEffects[i], + var effect$94 = unmountEffects[i], fiber = unmountEffects[i + 1], - destroy = effect$99.destroy; - effect$99.destroy = void 0; + destroy = effect$94.destroy; + effect$94.destroy = void 0; if ("function" === typeof destroy) try { destroy(); @@ -6961,22 +6868,22 @@ function flushPassiveEffectsImpl() { unmountEffects = pendingPassiveHookEffectsMount; pendingPassiveHookEffectsMount = []; for (i = 0; i < unmountEffects.length; i += 2) { - effect$99 = unmountEffects[i]; + effect$94 = unmountEffects[i]; fiber = unmountEffects[i + 1]; try { - var create$103 = effect$99.create; - effect$99.destroy = create$103(); - } catch (error$104) { + var create$98 = effect$94.create; + effect$94.destroy = create$98(); + } catch (error$99) { if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$104); + captureCommitPhaseError(fiber, error$99); } } - for (create$103 = root.current.firstEffect; null !== create$103; ) - (root = create$103.nextEffect), - (create$103.nextEffect = null), - create$103.effectTag & 8 && - ((create$103.sibling = null), (create$103.stateNode = null)), - (create$103 = root); + for (create$98 = root.current.firstEffect; null !== create$98; ) + (root = create$98.nextEffect), + (create$98.nextEffect = null), + create$98.flags & 8 && + ((create$98.sibling = null), (create$98.stateNode = null)), + (create$98 = root); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; @@ -7008,13 +6915,21 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); - enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); fiber = markUpdateLaneFromFiberToRoot(fiber, 1); - null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber)); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } @@ -7067,7 +6982,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) didReceiveUpdate = !0; else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { didReceiveUpdate = !1; switch (workInProgress.tag) { @@ -7113,14 +7028,14 @@ beginWork$1 = function(current, workInProgress, renderLanes) { break; case 19: updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { + if (0 !== (current.flags & 64)) { if (updateLanes) return updateSuspenseListComponent( current, workInProgress, renderLanes ); - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; } context = workInProgress.memoizedState; null !== context && @@ -7147,7 +7062,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); @@ -7159,7 +7074,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { context, renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -7209,7 +7124,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; hasContext = context._init; context = hasContext(context._payload); @@ -7452,8 +7367,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 1 === context$jscomp$0.tag && ((dependency = createUpdate( -1, - renderLanes & -renderLanes, - null + renderLanes & -renderLanes )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); @@ -7515,7 +7429,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), (updateLanes = updateLanes(context)), - (workInProgress.effectTag |= 1), + (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); @@ -7556,7 +7470,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) @@ -7595,7 +7509,7 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; @@ -7633,7 +7547,7 @@ function createWorkInProgress(current, pendingProps) { (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), - (workInProgress.effectTag = 0), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); @@ -7784,10 +7698,10 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.hydrate = hydrate; this.callbackNode = null; this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.entanglements = createLaneMap(0); } function createPortal(children, containerInfo, implementation) { var key = @@ -7816,8 +7730,7 @@ function findHostInstance(component) { function updateContainer(element, container, parentComponent, callback) { var current = container.current, eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + lane = requestUpdateLane(current); a: if (parentComponent) { parentComponent = parentComponent._reactInternals; b: { @@ -7865,7 +7778,7 @@ function updateContainer(element, container, parentComponent, callback) { null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); @@ -7903,14 +7816,16 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_934 = { + devToolsConfig$jscomp$inline_908 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.0-alpha.0", + version: "17.0.1-4e5d7faf5", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7925,13 +7840,17 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1135 = { - bundleType: devToolsConfig$jscomp$inline_934.bundleType, - version: devToolsConfig$jscomp$inline_934.version, - rendererPackageName: devToolsConfig$jscomp$inline_934.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_934.rendererConfig, +var internals$jscomp$inline_1115 = { + bundleType: devToolsConfig$jscomp$inline_908.bundleType, + version: devToolsConfig$jscomp$inline_908.version, + rendererPackageName: devToolsConfig$jscomp$inline_908.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_908.rendererConfig, overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, setSuspenseHandler: null, scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, @@ -7940,7 +7859,7 @@ var internals$jscomp$inline_1135 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_934.findFiberByHostInstance || + devToolsConfig$jscomp$inline_908.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -7949,16 +7868,16 @@ var internals$jscomp$inline_1135 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1136 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1116 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1136.isDisabled && - hook$jscomp$inline_1136.supportsFiber + !hook$jscomp$inline_1116.isDisabled && + hook$jscomp$inline_1116.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1136.inject( - internals$jscomp$inline_1135 + (rendererID = hook$jscomp$inline_1116.inject( + internals$jscomp$inline_1115 )), - (injectedHook = hook$jscomp$inline_1136); + (injectedHook = hook$jscomp$inline_1116); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js index 31b089c41bfee8..0c2b0f6f04e58a 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js @@ -16,16 +16,6 @@ require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), React = require("react"), Scheduler = require("scheduler"); -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -96,109 +86,6 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } -function getListener(inst, registrationName) { - var listener = inst.stateNode; - if (!listener) return null; - var props = getFiberCurrentPropsFromNode(listener); - if (!props) return null; - listener = props[registrationName]; - a: switch (registrationName) { - case "onClick": - case "onClickCapture": - case "onDoubleClick": - case "onDoubleClickCapture": - case "onMouseDown": - case "onMouseDownCapture": - case "onMouseMove": - case "onMouseMoveCapture": - case "onMouseUp": - case "onMouseUpCapture": - case "onMouseEnter": - (props = !props.disabled) || - ((inst = inst.type), - (props = !( - "button" === inst || - "input" === inst || - "select" === inst || - "textarea" === inst - ))); - inst = !props; - break a; - default: - inst = !1; - } - if (inst) return null; - if (listener && "function" !== typeof listener) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - return listener; -} -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} function functionThatReturnsTrue() { return !0; } @@ -214,6 +101,7 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; + this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -293,7 +181,12 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { +function createOrGetPooledEvent( + dispatchConfig, + targetInst, + nativeEvent, + nativeInst +) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -310,8 +203,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { + EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; - EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -439,6 +332,22 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -452,65 +361,132 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" - }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" - }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" - }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" - }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies - }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies + dependencies: startDependencies + }, + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] + dependencies: ["topScroll"] + }, + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { - registrationName: "onResponderReject", - dependencies: [] + dependencies: ["topSelectionChange"] + }, + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } + dependencies: moveDependencies + }, + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies }, - ResponderEventPlugin = { + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { registrationName: "onResponderReject", dependencies: [] }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } +}; +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} +function getListener(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +var ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -571,68 +547,70 @@ var eventTypes = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp === responderInst; - JSCompiler_temp = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp; + JSCompiler_temp = targetInst === responderInst; + shouldSetEventType = ResponderSyntheticEvent.getPooled( shouldSetEventType, - JSCompiler_temp, + targetInst, nativeEvent, nativeEventTarget ); - JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; - targetInst + shouldSetEventType.touchHistory = + ResponderTouchHistoryStore.touchHistory; + JSCompiler_temp ? forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingle ); b: { - shouldSetEventType = JSCompiler_temp._dispatchListeners; - targetInst = JSCompiler_temp._dispatchInstances; - if (Array.isArray(shouldSetEventType)) + JSCompiler_temp = shouldSetEventType._dispatchListeners; + targetInst = shouldSetEventType._dispatchInstances; + if (Array.isArray(JSCompiler_temp)) for ( depthA = 0; - depthA < shouldSetEventType.length && - !JSCompiler_temp.isPropagationStopped(); + depthA < JSCompiler_temp.length && + !shouldSetEventType.isPropagationStopped(); depthA++ ) { if ( - shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) + JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) ) { - shouldSetEventType = targetInst[depthA]; + JSCompiler_temp = targetInst[depthA]; break b; } } else if ( - shouldSetEventType && - shouldSetEventType(JSCompiler_temp, targetInst) + JSCompiler_temp && + JSCompiler_temp(shouldSetEventType, targetInst) ) { - shouldSetEventType = targetInst; + JSCompiler_temp = targetInst; break b; } - shouldSetEventType = null; + JSCompiler_temp = null; } - JSCompiler_temp._dispatchInstances = null; - JSCompiler_temp._dispatchListeners = null; - JSCompiler_temp.isPersistent() || - JSCompiler_temp.constructor.release(JSCompiler_temp); - if (shouldSetEventType && shouldSetEventType !== responderInst) + shouldSetEventType._dispatchInstances = null; + shouldSetEventType._dispatchListeners = null; + shouldSetEventType.isPersistent() || + shouldSetEventType.constructor.release(shouldSetEventType); + if (JSCompiler_temp && JSCompiler_temp !== responderInst) if ( - ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( + ((shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), - (JSCompiler_temp.touchHistory = + (shouldSetEventType.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), + (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), responderInst) ) if ( @@ -659,13 +637,13 @@ var eventTypes = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [JSCompiler_temp, depthA] + [shouldSetEventType, depthA] ); - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), @@ -682,9 +660,9 @@ var eventTypes = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - JSCompiler_temp + shouldSetEventType )), - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -812,7 +790,6 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -829,7 +806,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -837,7 +814,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -865,13 +842,75 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - customBubblingEventTypes = + registrationNameModules = {}; +function getListener$1(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; +function accumulateDirectionalDispatches$1(inst, phase, event) { + if ( + (phase = getListener$1( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle$1(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + for (var inst = event._targetInst, path = []; inst; ) { + path.push(inst); + do inst = inst.return; + while (inst && 5 !== inst.tag); + inst = inst ? inst : null; + } + for (inst = path.length; 0 < inst--; ) + accumulateDirectionalDispatches$1(path[inst], "captured", event); + for (inst = 0; inst < path.length; inst++) + accumulateDirectionalDispatches$1(path[inst], "bubbled", event); + } +} +function accumulateDirectDispatchesSingle$1(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener$1(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -881,7 +920,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_94 = { +var injectedNamesToPlugins$jscomp$inline_222 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -905,42 +944,45 @@ var injectedNamesToPlugins$jscomp$inline_94 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); + forEachAccumulated( + topLevelType, + accumulateTwoPhaseDispatchesSingle$1 + ); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_95 = !1, - pluginName$jscomp$inline_96; -for (pluginName$jscomp$inline_96 in injectedNamesToPlugins$jscomp$inline_94) + isOrderingDirty$jscomp$inline_223 = !1, + pluginName$jscomp$inline_224; +for (pluginName$jscomp$inline_224 in injectedNamesToPlugins$jscomp$inline_222) if ( - injectedNamesToPlugins$jscomp$inline_94.hasOwnProperty( - pluginName$jscomp$inline_96 + injectedNamesToPlugins$jscomp$inline_222.hasOwnProperty( + pluginName$jscomp$inline_224 ) ) { - var pluginModule$jscomp$inline_97 = - injectedNamesToPlugins$jscomp$inline_94[pluginName$jscomp$inline_96]; + var pluginModule$jscomp$inline_225 = + injectedNamesToPlugins$jscomp$inline_222[pluginName$jscomp$inline_224]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_96) || - namesToPlugins[pluginName$jscomp$inline_96] !== - pluginModule$jscomp$inline_97 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_224) || + namesToPlugins[pluginName$jscomp$inline_224] !== + pluginModule$jscomp$inline_225 ) { - if (namesToPlugins[pluginName$jscomp$inline_96]) + if (namesToPlugins[pluginName$jscomp$inline_224]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_96 + + pluginName$jscomp$inline_224 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_96 - ] = pluginModule$jscomp$inline_97; - isOrderingDirty$jscomp$inline_95 = !0; + pluginName$jscomp$inline_224 + ] = pluginModule$jscomp$inline_225; + isOrderingDirty$jscomp$inline_223 = !0; } } -isOrderingDirty$jscomp$inline_95 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_223 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -986,34 +1028,41 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { target = null; null != inst && (target = inst.stateNode); batchedUpdates(function() { - var events = target; - for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { - var possiblePlugin = plugins[i]; + var JSCompiler_inline_result = target; + for ( + var events = null, legacyPlugins = plugins, i = 0; + i < legacyPlugins.length; + i++ + ) { + var possiblePlugin = legacyPlugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, inst, nativeEvent, - events, - 1 + JSCompiler_inline_result )) && - (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); + (events = accumulateInto(events, possiblePlugin)); } - events = events$jscomp$0; - null !== events && (eventQueue = accumulateInto(eventQueue, events)); - events = eventQueue; + JSCompiler_inline_result = events; + null !== JSCompiler_inline_result && + (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); + JSCompiler_inline_result = eventQueue; eventQueue = null; - if (events) { - forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (JSCompiler_inline_result) { + forEachAccumulated( + JSCompiler_inline_result, + executeDispatchesAndReleaseTopLevel + ); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((events = rethrowError), + throw ((JSCompiler_inline_result = rethrowError), (hasRethrowError = !1), (rethrowError = null), - events); + JSCompiler_inline_result); } }); } @@ -1028,13 +1077,13 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ ) { var JSCompiler_temp = []; for (var i = 0; i < changedIndices.length; i++) { - var index = changedIndices[i]; - JSCompiler_temp.push(touches[index]); - touches[index] = null; + var index$0 = changedIndices[i]; + JSCompiler_temp.push(touches[index$0]); + touches[index$0] = null; } for (i = changedIndices = 0; i < touches.length; i++) - (index = touches[i]), - null !== index && (touches[changedIndices++] = index); + (index$0 = touches[i]), + null !== index$0 && (touches[changedIndices++] = index$0); touches.length = changedIndices; } else for (JSCompiler_temp = [], i = 0; i < changedIndices.length; i++) @@ -1047,10 +1096,10 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ i = JSCompiler_temp[changedIndices]; i.changedTouches = JSCompiler_temp; i.touches = touches; - index = null; + index$0 = null; var target = i.target; - null === target || void 0 === target || 1 > target || (index = target); - _receiveRootNodeIDEvent(index, eventTopLevelType, i); + null === target || void 0 === target || 1 > target || (index$0 = target); + _receiveRootNodeIDEvent(index$0, eventTopLevelType, i); } } }); @@ -1076,31 +1125,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; -ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || - (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); -ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || - (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); -var hasSymbol = "function" === typeof Symbol && Symbol.for, - REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, - REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, - REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, - REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, - REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, - REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, - REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_CONCURRENT_MODE_TYPE = hasSymbol - ? Symbol.for("react.concurrent_mode") - : 60111, - REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, - REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_SUSPENSE_LIST_TYPE = hasSymbol - ? Symbol.for("react.suspense_list") - : 60120, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, + REACT_ELEMENT_TYPE = 60103, + REACT_PORTAL_TYPE = 60106, + REACT_FRAGMENT_TYPE = 60107, + REACT_STRICT_MODE_TYPE = 60108, + REACT_PROFILER_TYPE = 60114, + REACT_PROVIDER_TYPE = 60109, + REACT_CONTEXT_TYPE = 60110, + REACT_FORWARD_REF_TYPE = 60112, + REACT_SUSPENSE_TYPE = 60113, + REACT_SUSPENSE_LIST_TYPE = 60120, + REACT_MEMO_TYPE = 60115, + REACT_LAZY_TYPE = 60116, + REACT_BLOCK_TYPE = 60121, + REACT_DEBUG_TRACING_MODE_TYPE = 60129, + REACT_OFFSCREEN_TYPE = 60130, + REACT_LEGACY_HIDDEN_TYPE = 60131; +if ("function" === typeof Symbol && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor("react.element"); + REACT_PORTAL_TYPE = symbolFor("react.portal"); + REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); + REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); + REACT_PROFILER_TYPE = symbolFor("react.profiler"); + REACT_PROVIDER_TYPE = symbolFor("react.provider"); + REACT_CONTEXT_TYPE = symbolFor("react.context"); + REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); + REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); + REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); + REACT_MEMO_TYPE = symbolFor("react.memo"); + REACT_LAZY_TYPE = symbolFor("react.lazy"); + REACT_BLOCK_TYPE = symbolFor("react.block"); + symbolFor("react.scope"); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); + REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); + REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); +} +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1108,27 +1170,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function initializeLazyComponentType(lazyComponent) { - if (-1 === lazyComponent._status) { - var ctor = lazyComponent._result; - ctor || (ctor = lazyComponent._ctor); - ctor = ctor(); - lazyComponent._status = 0; - lazyComponent._result = ctor; - ctor.then( - function(moduleObject) { - 0 === lazyComponent._status && - ((moduleObject = moduleObject.default), - (lazyComponent._status = 1), - (lazyComponent._result = moduleObject)); - }, - function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); - } - ); - } -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1163,10 +1204,13 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type.render); + return getComponentName(type._render); case REACT_LAZY_TYPE: - if ((type = 1 === type._status ? type._result : null)) - return getComponentName(type); + innerType = type._payload; + type = type._init; + try { + return getComponentName(type(innerType)); + } catch (x) {} } return null; } @@ -1178,7 +1222,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1218,36 +1262,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, _child = parentA.child; _child; ) { - if (_child === a) { + for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { + if (child$1 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (_child === b) { + if (child$1 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - _child = _child.sibling; + child$1 = child$1.sibling; } if (!didFindChild) { - for (_child = parentB.child; _child; ) { - if (_child === a) { + for (child$1 = parentB.child; child$1; ) { + if (child$1 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (_child === b) { + if (child$1 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - _child = _child.sibling; + child$1 = child$1.sibling; } if (!didFindChild) throw Error( @@ -1282,6 +1326,18 @@ function findCurrentHostFiber(parent) { } return null; } +function doesFiberContain(parentFiber, childFiber) { + for ( + var parentFiberAlternate = parentFiber.alternate; + null !== childFiber; + + ) { + if (childFiber === parentFiber || childFiber === parentFiberAlternate) + return !0; + childFiber = childFiber.return; + } + return !1; +} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -1486,19 +1542,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var _propKey in prevProps) - void 0 === nextProps[_propKey] && - (!(attributeConfig = validAttributes[_propKey]) || - (updatePayload && void 0 !== updatePayload[_propKey]) || - ((prevProp = prevProps[_propKey]), + for (var propKey$3 in prevProps) + void 0 === nextProps[propKey$3] && + (!(attributeConfig = validAttributes[propKey$3]) || + (updatePayload && void 0 !== updatePayload[propKey$3]) || + ((prevProp = prevProps[propKey$3]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[_propKey] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), removedKeys || (removedKeys = {}), - removedKeys[_propKey] || - ((removedKeys[_propKey] = !0), removedKeyCount++)) + removedKeys[propKey$3] || + ((removedKeys[propKey$3] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1607,9 +1663,22 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout, - valueStack = [], + cancelTimeout = clearTimeout; +function describeComponentFrame(name, source, ownerName) { + source = ""; + ownerName && (source = " (created by " + ownerName + ")"); + return "\n in " + (name || "Unknown") + source; +} +function describeFunctionComponentFrame(fn, source) { + return fn + ? describeComponentFrame(fn.displayName || fn.name || null, source, null) + : ""; +} +var valueStack = [], index = -1; +function createCursor(defaultValue) { + return { current: defaultValue }; +} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1620,8 +1689,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = { current: emptyContextObject }, - didPerformWorkStackCursor = { current: !1 }, + contextStackCursor = createCursor(emptyContextObject), + didPerformWorkStackCursor = createCursor(!1), previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1670,7 +1739,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1701,11 +1770,204 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } +var rendererID = null, + injectedHook = null, + Scheduler_now = Scheduler.unstable_now; +Scheduler_now(); +var return_highestLanePriority = 8; +function getHighestPriorityLanes(lanes) { + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; + var inputDiscreteLanes = 24 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 12), inputDiscreteLanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 10), inputDiscreteLanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 8), inputDiscreteLanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 6), inputDiscreteLanes; + inputDiscreteLanes = 62914560 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 5), inputDiscreteLanes; + if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; + if (0 !== (lanes & 134217728)) + return (return_highestLanePriority = 3), 134217728; + inputDiscreteLanes = 805306368 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 2), inputDiscreteLanes; + if (0 !== (1073741824 & lanes)) + return (return_highestLanePriority = 1), 1073741824; + return_highestLanePriority = 8; + return lanes; +} +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case 99: + return 15; + case 98: + return 10; + case 97: + case 96: + return 8; + case 95: + return 2; + default: + return 0; + } +} +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case 15: + case 14: + return 99; + case 13: + case 12: + case 11: + case 10: + return 98; + case 9: + case 8: + case 7: + case 6: + case 4: + case 5: + return 97; + case 3: + case 2: + case 1: + return 95; + case 0: + return 90; + default: + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); + } +} +function getNextLanes(root, wipLanes) { + var pendingLanes = root.pendingLanes; + if (0 === pendingLanes) return (return_highestLanePriority = 0); + var nextLanes = 0, + nextLanePriority = 0, + expiredLanes = root.expiredLanes, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes; + if (0 !== expiredLanes) + (nextLanes = expiredLanes), + (nextLanePriority = return_highestLanePriority = 15); + else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { + var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; + 0 !== nonIdleUnblockedLanes + ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), + (nextLanePriority = return_highestLanePriority)) + : ((pingedLanes &= expiredLanes), + 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority))); + } else + (expiredLanes = pendingLanes & ~suspendedLanes), + 0 !== expiredLanes + ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), + (nextLanePriority = return_highestLanePriority)) + : 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority)); + if (0 === nextLanes) return 0; + nextLanes = 31 - clz32(nextLanes); + nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); + if ( + 0 !== wipLanes && + wipLanes !== nextLanes && + 0 === (wipLanes & suspendedLanes) + ) { + getHighestPriorityLanes(wipLanes); + if (nextLanePriority <= return_highestLanePriority) return wipLanes; + return_highestLanePriority = nextLanePriority; + } + wipLanes = root.entangledLanes; + if (0 !== wipLanes) + for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) + (pendingLanes = 31 - clz32(wipLanes)), + (nextLanePriority = 1 << pendingLanes), + (nextLanes |= root[pendingLanes]), + (wipLanes &= ~nextLanePriority); + return nextLanes; +} +function getLanesToRetrySynchronouslyOnError(root) { + root = root.pendingLanes & -1073741825; + return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; +} +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case 15: + return 1; + case 14: + return 2; + case 12: + return ( + (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + ); + case 10: + return ( + (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority + ); + case 8: + return ( + (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), + 0 === lanePriority && + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), + 0 === lanePriority && (lanePriority = 512)), + lanePriority + ); + case 2: + return ( + (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), + 0 === wipLanes && (wipLanes = 268435456), + wipLanes + ); + } + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); +} +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; +} +function markRootUpdated(root, updateLane, eventTime) { + root.pendingLanes |= updateLane; + var higherPriorityLanes = updateLane - 1; + root.suspendedLanes &= higherPriorityLanes; + root.pingedLanes &= higherPriorityLanes; + root = root.eventTimes; + updateLane = 31 - clz32(updateLane); + root[updateLane] = eventTime; +} +var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, + log = Math.log, + LN2 = Math.LN2; +function clz32Fallback(lanes) { + return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; +} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now = Scheduler.unstable_now, + Scheduler_now$1 = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -1714,18 +1976,17 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_LowPriority = Scheduler.unstable_LowPriority, Scheduler_IdlePriority = Scheduler.unstable_IdlePriority, fakeCallbackNode = {}, - shouldYield = Scheduler.unstable_shouldYield, requestPaint = void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), + initialTimeMs$1 = Scheduler_now$1(), now = - 1e4 > initialTimeMs - ? Scheduler_now + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 : function() { - return Scheduler_now() - initialTimeMs; + return Scheduler_now$1() - initialTimeMs$1; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -1767,16 +2028,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } -function scheduleSyncCallback(callback) { - null === syncQueue - ? ((syncQueue = [callback]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(callback); - return fakeCallbackNode; -} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -1811,6 +2062,7 @@ function flushSyncCallbackQueueImpl() { } } } +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -1836,42 +2088,41 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function describeFiber(fiber) { + switch (fiber.tag) { + case 5: + return describeComponentFrame(fiber.type, null, null); + case 16: + return describeComponentFrame("Lazy", null, null); + case 13: + return describeComponentFrame("Suspense", null, null); + case 19: + return describeComponentFrame("SuspenseList", null, null); + case 0: + case 2: + case 15: + return describeFunctionComponentFrame(fiber.type, null); + case 11: + return describeFunctionComponentFrame(fiber.type.render, null); + case 22: + return describeFunctionComponentFrame(fiber.type._render, null); + case 1: + return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; + default: + return ""; + } +} function getStackByFiberInDevAndProd(workInProgress) { - var info = ""; - do { - a: switch (workInProgress.tag) { - case 3: - case 4: - case 6: - case 7: - case 10: - case 9: - var JSCompiler_inline_result = ""; - break a; - default: - var owner = workInProgress._debugOwner, - source = workInProgress._debugSource, - name = getComponentName(workInProgress.type); - JSCompiler_inline_result = null; - owner && (JSCompiler_inline_result = getComponentName(owner.type)); - owner = name; - name = ""; - source - ? (name = - " (at " + - source.fileName.replace(BEFORE_SLASH_RE, "") + - ":" + - source.lineNumber + - ")") - : JSCompiler_inline_result && - (name = " (created by " + JSCompiler_inline_result + ")"); - JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - } - info += JSCompiler_inline_result; - workInProgress = workInProgress.return; - } while (workInProgress); - return info; + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } } function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { @@ -1880,10 +2131,11 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); + return baseProps; } return baseProps; } -var valueCursor = { current: null }, +var valueCursor = createCursor(null), currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -1895,31 +2147,29 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue = currentValue; } -function scheduleWorkOnParentPath(parent, renderExpirationTime) { +function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { var alternate = parent.alternate; - if (parent.childExpirationTime < renderExpirationTime) - (parent.childExpirationTime = renderExpirationTime), - null !== alternate && - alternate.childExpirationTime < renderExpirationTime && - (alternate.childExpirationTime = renderExpirationTime); - else if ( - null !== alternate && - alternate.childExpirationTime < renderExpirationTime - ) - alternate.childExpirationTime = renderExpirationTime; - else break; + if ((parent.childLanes & renderLanes) === renderLanes) + if ( + null === alternate || + (alternate.childLanes & renderLanes) === renderLanes + ) + break; + else alternate.childLanes |= renderLanes; + else + (parent.childLanes |= renderLanes), + null !== alternate && (alternate.childLanes |= renderLanes); parent = parent.return; } } -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress, renderLanes) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (workInProgress.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0), + (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -1938,7 +2188,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - expirationTime: 0, + lanes: 0, firstContext: observedBits, responders: null }; @@ -1950,7 +2200,8 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - baseQueue: null, + firstBaseUpdate: null, + lastBaseUpdate: null, shared: { pending: null }, effects: null }; @@ -1960,21 +2211,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - baseQueue: current.baseQueue, + firstBaseUpdate: current.firstBaseUpdate, + lastBaseUpdate: current.lastBaseUpdate, shared: current.shared, effects: current.effects }); } -function createUpdate(expirationTime, suspenseConfig) { - expirationTime = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, +function createUpdate(eventTime, lane) { + return { + eventTime: eventTime, + lane: lane, tag: 0, payload: null, callback: null, next: null }; - return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -1987,132 +2238,177 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, update) { - var current = workInProgress.alternate; - null !== current && cloneUpdateQueue(current, workInProgress); - workInProgress = workInProgress.updateQueue; - current = workInProgress.baseQueue; - null === current - ? ((workInProgress.baseQueue = update.next = update), - (update.next = update)) - : ((update.next = current.next), (current.next = update)); +function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + var queue = workInProgress.updateQueue, + current = workInProgress.alternate; + if ( + null !== current && + ((current = current.updateQueue), queue === current) + ) { + var newFirst = null, + newLast = null; + queue = queue.firstBaseUpdate; + if (null !== queue) { + do { + var clone = { + eventTime: queue.eventTime, + lane: queue.lane, + tag: queue.tag, + payload: queue.payload, + callback: queue.callback, + next: null + }; + null === newLast + ? (newFirst = newLast = clone) + : (newLast = newLast.next = clone); + queue = queue.next; + } while (null !== queue); + null === newLast + ? (newFirst = newLast = capturedUpdate) + : (newLast = newLast.next = capturedUpdate); + } else newFirst = newLast = capturedUpdate; + queue = { + baseState: current.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: current.shared, + effects: current.effects + }; + workInProgress.updateQueue = queue; + return; + } + workInProgress = queue.lastBaseUpdate; + null === workInProgress + ? (queue.firstBaseUpdate = capturedUpdate) + : (workInProgress.next = capturedUpdate); + queue.lastBaseUpdate = capturedUpdate; } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderExpirationTime + renderLanes ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var baseQueue = queue.baseQueue, + var firstBaseUpdate = queue.firstBaseUpdate, + lastBaseUpdate = queue.lastBaseUpdate, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - if (null !== baseQueue) { - var baseFirst = baseQueue.next; - baseQueue.next = pendingQueue.next; - pendingQueue.next = baseFirst; - } - baseQueue = pendingQueue; queue.shared.pending = null; - baseFirst = workInProgress$jscomp$0.alternate; - null !== baseFirst && - ((baseFirst = baseFirst.updateQueue), - null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); + var lastPendingUpdate = pendingQueue, + firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; + null === lastBaseUpdate + ? (firstBaseUpdate = firstPendingUpdate) + : (lastBaseUpdate.next = firstPendingUpdate); + lastBaseUpdate = lastPendingUpdate; + var current = workInProgress$jscomp$0.alternate; + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate + ? (current.firstBaseUpdate = firstPendingUpdate) + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } - if (null !== baseQueue) { - baseFirst = baseQueue.next; - var newState = queue.baseState, - newExpirationTime = 0, - newBaseState = null, - newBaseQueueFirst = null, - newBaseQueueLast = null; - if (null !== baseFirst) { - var update = baseFirst; - do { - pendingQueue = update.expirationTime; - if (pendingQueue < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, + if (null !== firstBaseUpdate) { + currentLastBaseUpdate = queue.baseState; + lastBaseUpdate = 0; + current = firstPendingUpdate = lastPendingUpdate = null; + do { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { + null !== current && + (current = current.next = { + eventTime: updateEventTime, + lane: 0, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (newBaseState = newState)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - pendingQueue > newExpirationTime && - (newExpirationTime = pendingQueue); - } else { - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }); - markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); - a: { - var workInProgress = workInProgress$jscomp$0, - update$jscomp$0 = update; - pendingQueue = props; - clone = instance; - switch (update$jscomp$0.tag) { - case 1: - workInProgress = update$jscomp$0.payload; - if ("function" === typeof workInProgress) { - newState = workInProgress.call(clone, newState, pendingQueue); - break a; - } - newState = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update$jscomp$0.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call(clone, newState, pendingQueue) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - newState = Object.assign({}, newState, pendingQueue); + }); + a: { + var workInProgress = workInProgress$jscomp$0, + update = firstBaseUpdate; + pendingQueue = props; + updateEventTime = instance; + switch (update.tag) { + case 1: + workInProgress = update.payload; + if ("function" === typeof workInProgress) { + currentLastBaseUpdate = workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ); break a; - case 2: - hasForceUpdate = !0; - } + } + currentLastBaseUpdate = workInProgress; + break a; + case 3: + workInProgress.flags = (workInProgress.flags & -8193) | 64; + case 0: + workInProgress = update.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); + break a; + case 2: + hasForceUpdate = !0; } - null !== update.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [update]) - : pendingQueue.push(update)); } - update = update.next; - if (null === update || update === baseFirst) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (update = baseQueue.next = pendingQueue.next), - (pendingQueue.next = baseFirst), - (queue.baseQueue = baseQueue = pendingQueue), - (queue.shared.pending = null); - } while (1); - } - null === newBaseQueueLast - ? (newBaseState = newState) - : (newBaseQueueLast.next = newBaseQueueFirst); - queue.baseState = newBaseState; - queue.baseQueue = newBaseQueueLast; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress$jscomp$0.expirationTime = newExpirationTime; - workInProgress$jscomp$0.memoizedState = newState; + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); + } else + (updateEventTime = { + eventTime: updateEventTime, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, + next: null + }), + null === current + ? ((firstPendingUpdate = current = updateEventTime), + (lastPendingUpdate = currentLastBaseUpdate)) + : (current = current.next = updateEventTime), + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), + (queue.shared.pending = null); + } while (1); + null === current && (lastPendingUpdate = currentLastBaseUpdate); + queue.baseState = lastPendingUpdate; + queue.firstBaseUpdate = firstPendingUpdate; + queue.lastBaseUpdate = current; + workInProgressRootSkippedLanes |= lastBaseUpdate; + workInProgress$jscomp$0.lanes = lastBaseUpdate; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2137,8 +2433,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2152,54 +2447,45 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.expirationTime && + 0 === workInProgress.lanes && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternalFiber) + return (component = component._reactInternals) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2237,7 +2523,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternalFiber = workInProgress; + ctor._reactInternals = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2258,12 +2544,7 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { +function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2276,7 +2557,7 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2293,15 +2574,10 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue( - workInProgress, - newProps, - instance, - renderExpirationTime - ), + processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2316,7 +2592,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2350,7 +2626,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2362,7 +2638,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - ")." + "). If you meant to render a collection of children, use an array instead." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2374,7 +2650,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2406,26 +2682,22 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, expirationTime) { + function updateTextNode(returnFiber, current, textContent, lanes) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromText(textContent, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2433,27 +2705,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, expirationTime) { + function updateElement(returnFiber, current, element, lanes) { if (null !== current && current.elementType === element.type) return ( - (expirationTime = useFiber(current, element.props)), - (expirationTime.ref = coerceRef(returnFiber, current, element)), - (expirationTime.return = returnFiber), - expirationTime + (lanes = useFiber(current, element.props)), + (lanes.ref = coerceRef(returnFiber, current, element)), + (lanes.return = returnFiber), + lanes ); - expirationTime = createFiberFromTypeAndProps( + lanes = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - expirationTime + lanes ); - expirationTime.ref = coerceRef(returnFiber, current, element); - expirationTime.return = returnFiber; - return expirationTime; + lanes.ref = coerceRef(returnFiber, current, element); + lanes.return = returnFiber; + return lanes; } - function updatePortal(returnFiber, current, portal, expirationTime) { + function updatePortal(returnFiber, current, portal, lanes) { if ( null === current || 4 !== current.tag || @@ -2461,11 +2733,7 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2473,13 +2741,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, expirationTime, key) { + function updateFragment(returnFiber, current, fragment, lanes, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - expirationTime, + lanes, key )), (current.return = returnFiber), @@ -2489,13 +2757,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, expirationTime) { + function createChild(returnFiber, newChild, lanes) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2504,24 +2772,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( + (lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef(returnFiber, null, newChild)), - (expirationTime.return = returnFiber), - expirationTime + (lanes.ref = coerceRef(returnFiber, null, newChild)), + (lanes.return = returnFiber), + lanes ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2532,7 +2800,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - expirationTime, + lanes, null )), (newChild.return = returnFiber), @@ -2542,12 +2810,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { + function updateSlot(returnFiber, oldFiber, newChild, lanes) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); + : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2557,26 +2825,20 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - expirationTime, + lanes, key ) - : updateElement(returnFiber, oldFiber, newChild, expirationTime) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) + ? updatePortal(returnFiber, oldFiber, newChild, lanes) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment( - returnFiber, - oldFiber, - newChild, - expirationTime, - null - ); + : updateFragment(returnFiber, oldFiber, newChild, lanes, null); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2586,17 +2848,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - expirationTime + lanes ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode( - returnFiber, - existingChildren, - "" + newChild, - expirationTime - ) + updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2611,15 +2868,10 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - expirationTime, + lanes, newChild.key ) - : updateElement( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -2627,24 +2879,13 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + updatePortal(returnFiber, existingChildren, newChild, lanes) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment( - returnFiber, - existingChildren, - newChild, - expirationTime, - null - ) + updateFragment(returnFiber, existingChildren, newChild, lanes, null) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2654,7 +2895,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - expirationTime + lanes ) { for ( var resultingFirstChild = null, @@ -2672,7 +2913,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - expirationTime + lanes ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2695,11 +2936,7 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )), + (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -2722,7 +2959,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - expirationTime + lanes )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -2749,7 +2986,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - expirationTime + lanes ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -2771,12 +3008,7 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot( - returnFiber, - oldFiber, - step.value, - expirationTime - ); + var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -2796,7 +3028,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, expirationTime)), + (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -2810,13 +3042,7 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap( - oldFiber, - returnFiber, - newIdx, - step.value, - expirationTime - )), + (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -2832,7 +3058,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, expirationTime) { + return function(returnFiber, currentFirstChild, newChild, lanes) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -2898,26 +3124,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - expirationTime, + lanes, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( + : ((lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef( + (lanes.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (expirationTime.return = returnFiber), - (returnFiber = expirationTime)); + (lanes.return = returnFiber), + (returnFiber = lanes)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -2956,7 +3182,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -2975,7 +3201,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - expirationTime + lanes )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -2986,25 +3212,27 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3012,9 +3240,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = { current: NO_CONTEXT }, - contextFiberStackCursor = { current: NO_CONTEXT }, - rootInstanceStackCursor = { current: NO_CONTEXT }; + contextStackCursor$1 = createCursor(NO_CONTEXT), + contextFiberStackCursor = createCursor(NO_CONTEXT), + rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3037,26 +3265,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var nextContext = fiber.type; - nextContext = - "AndroidTextInput" === nextContext || - "RCTMultilineTextInputView" === nextContext || - "RCTSinglelineTextInputView" === nextContext || - "RCTText" === nextContext || - "RCTVirtualText" === nextContext; - nextContext = - context.isInAParentText !== nextContext - ? { isInAParentText: nextContext } + var JSCompiler_inline_result = fiber.type; + JSCompiler_inline_result = + "AndroidTextInput" === JSCompiler_inline_result || + "RCTMultilineTextInputView" === JSCompiler_inline_result || + "RCTSinglelineTextInputView" === JSCompiler_inline_result || + "RCTText" === JSCompiler_inline_result || + "RCTVirtualText" === JSCompiler_inline_result; + JSCompiler_inline_result = + context.isInAParentText !== JSCompiler_inline_result + ? { isInAParentText: JSCompiler_inline_result } : context; - context !== nextContext && + context !== JSCompiler_inline_result && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, nextContext)); + push(contextStackCursor$1, JSCompiler_inline_result)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = { current: 0 }; +var suspenseStackCursor = createCursor(0); function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3064,7 +3292,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim() || shim())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3080,19 +3308,23 @@ function findFirstSuspended(row) { } return null; } -function createDeprecatedResponderListener(responder, props) { - return { responder: responder, props: props }; +var workInProgressSources = []; +function resetWorkInProgressVersions() { + for (var i = 0; i < workInProgressSources.length; i++) + workInProgressSources[i]._workInProgressVersionPrimary = null; + workInProgressSources.length = 0; } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderExpirationTime = 0, + renderLanes = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1; + didScheduleRenderPhaseUpdate = !1, + didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3107,36 +3339,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderExpirationTime + nextRenderLanes ) { - renderExpirationTime = nextRenderExpirationTime; + renderLanes = nextRenderLanes; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.expirationTime = 0; - ReactCurrentDispatcher.current = + workInProgress.lanes = 0; + ReactCurrentDispatcher$1.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (workInProgress.expirationTime === renderExpirationTime) { - nextRenderExpirationTime = 0; + if (didScheduleRenderPhaseUpdateDuringThisPass) { + nextRenderLanes = 0; do { - workInProgress.expirationTime = 0; - if (!(25 > nextRenderExpirationTime)) + didScheduleRenderPhaseUpdateDuringThisPass = !1; + if (!(25 > nextRenderLanes)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderExpirationTime += 1; + nextRenderLanes += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (workInProgress.expirationTime === renderExpirationTime); + } while (didScheduleRenderPhaseUpdateDuringThisPass); } - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3217,40 +3449,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var updateExpirationTime = update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }; - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - updateExpirationTime > currentlyRenderingFiber$1.expirationTime && - ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), - markUnprocessedUpdateTime(updateExpirationTime)); - } else + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) null !== newBaseQueueLast && (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), (current = update.eagerReducer === reducer ? update.eagerState : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3287,6 +3513,114 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } +function readFromUnsubcribedMutableSource(root, source, getSnapshot) { + var getVersion = source._getVersion; + getVersion = getVersion(source._source); + var JSCompiler_inline_result = source._workInProgressVersionPrimary; + if (null !== JSCompiler_inline_result) + root = JSCompiler_inline_result === getVersion; + else if ( + ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) + ) + (source._workInProgressVersionPrimary = getVersion), + workInProgressSources.push(source); + if (root) return getSnapshot(source._source); + workInProgressSources.push(source); + throw Error( + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." + ); +} +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = workInProgressRoot; + if (null === root) + throw Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + var getVersion = source._getVersion, + version = getVersion(source._source), + dispatcher = ReactCurrentDispatcher$1.current, + _dispatcher$useState = dispatcher.useState(function() { + return readFromUnsubcribedMutableSource(root, source, getSnapshot); + }), + setSnapshot = _dispatcher$useState[1], + snapshot = _dispatcher$useState[0]; + _dispatcher$useState = workInProgressHook; + var memoizedState = hook.memoizedState, + refs = memoizedState.refs, + prevGetSnapshot = refs.getSnapshot, + prevSource = memoizedState.source; + memoizedState = memoizedState.subscribe; + var fiber = currentlyRenderingFiber$1; + hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; + dispatcher.useEffect( + function() { + refs.getSnapshot = getSnapshot; + refs.setSnapshot = setSnapshot; + var maybeNewVersion = getVersion(source._source); + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); + maybeNewVersion = root.mutableReadLanes; + root.entangledLanes |= maybeNewVersion; + for ( + var entanglements = root.entanglements, lanes = maybeNewVersion; + 0 < lanes; + + ) { + var index$13 = 31 - clz32(lanes), + lane = 1 << index$13; + entanglements[index$13] |= maybeNewVersion; + lanes &= ~lane; + } + } + }, + [getSnapshot, source, subscribe] + ); + dispatcher.useEffect( + function() { + return subscribe(source._source, function() { + var latestGetSnapshot = refs.getSnapshot, + latestSetSnapshot = refs.setSnapshot; + try { + latestSetSnapshot(latestGetSnapshot(source._source)); + var lane = requestUpdateLane(fiber); + root.mutableReadLanes |= lane & root.pendingLanes; + } catch (error) { + latestSetSnapshot(function() { + throw error; + }); + } + }); + }, + [source, subscribe] + ); + (objectIs(prevGetSnapshot, getSnapshot) && + objectIs(prevSource, source) && + objectIs(memoizedState, subscribe)) || + ((hook = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), + (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); + return snapshot; +} +function updateMutableSource(source, getSnapshot, subscribe) { + var hook = updateWorkInProgressHook(); + return useMutableSource(hook, source, getSnapshot, subscribe); +} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3323,17 +3657,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3341,12 +3675,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3385,13 +3719,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3419,65 +3746,60 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); - suspenseConfig = { - expirationTime: currentTime, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + var eventTime = requestEventTime(), + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdate = !0), - (suspenseConfig.expirationTime = renderExpirationTime), - (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { if ( - 0 === fiber.expirationTime && - (null === pending || 0 === pending.expirationTime) && + 0 === fiber.lanes && + (null === pending || 0 === pending.lanes) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } -function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3490,14 +3812,21 @@ var ContextOnlyDispatcher = { useRef: throwInvalidHookError, useState: throwInvalidHookError, useDebugValue: throwInvalidHookError, - useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useEvent: throwInvalidHookError + useMutableSource: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, + unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3543,39 +3872,44 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; + }, + useMutableSource: function(source, getSnapshot, subscribe) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); }, - useEvent: function() {} + unstable_isNewReconciler: !1 }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -3591,39 +3925,33 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; + }, + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; }, - useEvent: updateEventListener + unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { readContext: readContext, @@ -3639,61 +3967,45 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; + }, + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; }, - useEvent: updateEventListener + unstable_isNewReconciler: !1 }, ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime -) { +function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress.child = null === current - ? mountChildFibers( - workInProgress, - null, - nextChildren, - renderExpirationTime - ) + ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderExpirationTime + renderLanes ); } function updateForwardRef( @@ -3701,33 +4013,28 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } function updateMemoComponent( @@ -3735,8 +4042,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (null === current) { var type = Component.type; @@ -3755,17 +4062,17 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); current = createFiberFromTypeAndProps( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, - renderExpirationTime + renderLanes ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3773,19 +4080,14 @@ function updateMemoComponent( } type = current.child; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), + 0 === (updateLanes & renderLanes) && + ((updateLanes = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current.ref === workInProgress.ref) + Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3796,26 +4098,63 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { - return null !== current && + if ( + null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref && - ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) - ? ((workInProgress.expirationTime = current.expirationTime), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - )) - : updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderExpirationTime + current.ref === workInProgress.ref + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else + return ( + (workInProgress.lanes = current.lanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); + return updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderLanes + ); +} +function updateOffscreenComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, + nextChildren = nextProps.children, + prevState = null !== current ? current.memoizedState : null; + if ( + "hidden" === nextProps.mode || + "unstable-defer-without-hiding" === nextProps.mode + ) + if (0 === (workInProgress.mode & 4)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes(workInProgress, renderLanes); + else if (0 !== (renderLanes & 1073741824)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes( + workInProgress, + null !== prevState ? prevState.baseLanes : renderLanes + ); + else + return ( + (current = + null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), + (workInProgress.lanes = workInProgress.childLanes = 1073741824), + (workInProgress.memoizedState = { baseLanes: current }), + pushRenderLanes(workInProgress, current), + null + ); + else + null !== prevState + ? ((nextProps = prevState.baseLanes | renderLanes), + (workInProgress.memoizedState = null)) + : (nextProps = renderLanes), + pushRenderLanes(workInProgress, nextProps); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -3823,42 +4162,37 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } function updateClassComponent( @@ -3866,25 +4200,20 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ), + mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -3915,12 +4244,7 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ); + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -3953,9 +4277,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -3963,119 +4287,113 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); - } else - (instance = workInProgress.stateNode), - cloneUpdateQueue(current, workInProgress), - (oldProps = workInProgress.memoizedProps), - (instance.props = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps)), - (oldContext = instance.context), - (contextType = Component.contextType), - "object" === typeof contextType && null !== contextType - ? (contextType = readContext(contextType)) - : ((contextType = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = - "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( + } else { + instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); + oldProps = workInProgress.memoizedProps; + contextType = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); + instance.props = contextType; + hasNewLifecycles = workInProgress.pendingProps; + oldState = instance.context; + oldContext = Component.contextType; + "object" === typeof oldContext && null !== oldContext + ? (oldContext = readContext(oldContext)) + : ((oldContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (oldContext = getMaskedContext(workInProgress, oldContext))); + var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; + (getDerivedStateFromProps = + "function" === typeof getDerivedStateFromProps$jscomp$0 || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== hasNewLifecycles || oldState !== oldContext) && + callComponentWillReceiveProps( + workInProgress, + instance, + nextProps, + oldContext + )); + hasForceUpdate = !1; + oldState = workInProgress.memoizedState; + instance.state = oldState; + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + var newState = workInProgress.memoizedState; + oldProps !== hasNewLifecycles || + oldState !== newState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps$jscomp$0, + nextProps + ), + (newState = workInProgress.memoizedState)), + (contextType = + hasForceUpdate || + checkShouldComponentUpdate( workInProgress, - instance, + Component, + contextType, nextProps, - contextType - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (instance.state = oldContext), - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState), - oldProps !== nextProps || - oldContext !== oldState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldState = workInProgress.memoizedState)), - (getDerivedStateFromProps = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - oldProps, - nextProps, - oldContext, - oldState, - contextType - )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( - nextProps, - oldState, - contextType - ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - oldState, - contextType - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), - (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); + oldState, + newState, + oldContext + )) + ? (getDerivedStateFromProps || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate(nextProps, newState, oldContext), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + newState, + oldContext + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.flags |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.flags |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = newState)), + (instance.props = nextProps), + (instance.state = newState), + (instance.context = oldContext), + (nextProps = contextType)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (nextProps = !1)); + } return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderExpirationTime + renderLanes ); } function finishClassComponent( @@ -4084,18 +4402,14 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4103,26 +4417,21 @@ function finishClassComponent( didCaptureError && "function" !== typeof Component.getDerivedStateFromError ? null : shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((workInProgress.child = reconcileChildFibers( workInProgress, current.child, null, - renderExpirationTime + renderLanes )), (workInProgress.child = reconcileChildFibers( workInProgress, null, nextChildren, - renderExpirationTime + renderLanes ))) - : reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + : reconcileChildren(current, workInProgress, nextChildren, renderLanes); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4139,155 +4448,214 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; -function updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime -) { - var mode = workInProgress.mode, - nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; +function updateSuspenseComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - nextDidTimeout = !1, + showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = - 0 !== (suspenseContext & 2) && - (null === current || null !== current.memoizedState)); + null !== current && null === current.memoizedState + ? !1 + : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + current = nextProps.children; + suspenseContext = nextProps.fallback; + if (showFallback) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + current ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - mode = nextProps.children; - workInProgress.memoizedState = null; - return (workInProgress.child = mountChildFibers( - workInProgress, - null, - mode, - renderExpirationTime - )); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), + current + ); + renderLanes = createFiberFromOffscreen( + { mode: "visible", children: current }, + workInProgress.mode, + renderLanes, + null + ); + renderLanes.return = workInProgress; + return (workInProgress.child = renderLanes); } if (null !== current.memoizedState) { - current = current.child; - mode = current.sibling; - if (nextDidTimeout) { - nextProps = nextProps.fallback; - renderExpirationTime = createWorkInProgress( - current, - current.pendingProps + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - if ( - 0 === (workInProgress.mode & 2) && - ((nextDidTimeout = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child), - nextDidTimeout !== current.child) - ) - for ( - renderExpirationTime.child = nextDidTimeout; - null !== nextDidTimeout; - - ) - (nextDidTimeout.return = renderExpirationTime), - (nextDidTimeout = nextDidTimeout.sibling); - mode = createWorkInProgress(mode, nextProps); - mode.return = workInProgress; - renderExpirationTime.sibling = mode; - renderExpirationTime.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = renderExpirationTime; - return mode; - } - renderExpirationTime = reconcileChildFibers( + renderLanes = updateSuspensePrimaryChildren( + current, workInProgress, - current.child, nextProps.children, - renderExpirationTime + renderLanes ); workInProgress.memoizedState = null; - return (workInProgress.child = renderExpirationTime); + return renderLanes; } - current = current.child; - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - nextProps.child = current; - null !== current && (current.return = nextProps); - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - renderExpirationTime.effectTag |= 2; - nextProps.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - workInProgress.memoizedState = null; - return (workInProgress.child = reconcileChildFibers( - workInProgress, + renderLanes = updateSuspensePrimaryChildren( current, + workInProgress, nextProps.children, - renderExpirationTime - )); + renderLanes + ); + workInProgress.memoizedState = null; + return renderLanes; } -function scheduleWorkOnFiber(fiber, renderExpirationTime) { - fiber.expirationTime < renderExpirationTime && - (fiber.expirationTime = renderExpirationTime); +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren)) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; +} +function updateSuspensePrimaryChildren( + current, + workInProgress, + primaryChildren, + renderLanes +) { + var currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { + mode: "visible", + children: primaryChildren + }); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); + primaryChildren.return = workInProgress; + primaryChildren.sibling = null; + null !== current && + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); + return (workInProgress.child = primaryChildren); +} +function updateSuspenseFallbackChildren( + current, + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + var primaryChildProps = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment + ? ((primaryChildren = workInProgress.child), + (primaryChildren.childLanes = 0), + (primaryChildren.pendingProps = primaryChildProps), + (currentPrimaryChildFragment = primaryChildren.lastEffect), + null !== currentPrimaryChildFragment + ? ((workInProgress.firstEffect = primaryChildren.firstEffect), + (workInProgress.lastEffect = currentPrimaryChildFragment), + (currentPrimaryChildFragment.nextEffect = null)) + : (workInProgress.firstEffect = workInProgress.lastEffect = null)) + : (primaryChildren = createWorkInProgress( + currentPrimaryChildFragment, + primaryChildProps + )); + null !== current + ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) + : ((fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + )), + (fallbackChildren.flags |= 2)); + fallbackChildren.return = workInProgress; + primaryChildren.return = workInProgress; + primaryChildren.sibling = fallbackChildren; + workInProgress.child = primaryChildren; + return fallbackChildren; +} +function scheduleWorkOnFiber(fiber, renderLanes) { + fiber.lanes |= renderLanes; var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < renderExpirationTime && - (alternate.expirationTime = renderExpirationTime); - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + null !== alternate && (alternate.lanes |= renderLanes); + scheduleWorkOnParentPath(fiber.return, renderLanes); } function initSuspenseListRenderState( workInProgress, @@ -4305,7 +4673,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4314,35 +4681,24 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime -) { +function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren( - current, - workInProgress, - nextProps.children, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderExpirationTime); - else if (19 === current.tag) - scheduleWorkOnFiber(current, renderExpirationTime); + scheduleWorkOnFiber(current, renderLanes); + else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4364,30 +4720,29 @@ function updateSuspenseListComponent( else switch (revealOrder) { case "forwards": - renderExpirationTime = workInProgress.child; - for (revealOrder = null; null !== renderExpirationTime; ) - (current = renderExpirationTime.alternate), + renderLanes = workInProgress.child; + for (revealOrder = null; null !== renderLanes; ) + (current = renderLanes.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderExpirationTime), - (renderExpirationTime = renderExpirationTime.sibling); - renderExpirationTime = revealOrder; - null === renderExpirationTime + (revealOrder = renderLanes), + (renderLanes = renderLanes.sibling); + renderLanes = revealOrder; + null === renderLanes ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderExpirationTime.sibling), - (renderExpirationTime.sibling = null)); + : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderExpirationTime, + renderLanes, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderExpirationTime = null; + renderLanes = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4396,14 +4751,14 @@ function updateSuspenseListComponent( break; } current = revealOrder.sibling; - revealOrder.sibling = renderExpirationTime; - renderExpirationTime = revealOrder; + revealOrder.sibling = renderLanes; + renderLanes = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderExpirationTime, + renderLanes, null, tailMode, workInProgress.lastEffect @@ -4424,35 +4779,28 @@ function updateSuspenseListComponent( } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime -) { +function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); - var updateExpirationTime = workInProgress.expirationTime; - 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); - if (workInProgress.childExpirationTime < renderExpirationTime) return null; - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderExpirationTime = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderExpirationTime; - for ( - renderExpirationTime.return = workInProgress; - null !== current.sibling; - - ) - (current = current.sibling), - (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderExpirationTime.return = workInProgress); - renderExpirationTime.sibling = null; + workInProgressRootSkippedLanes |= workInProgress.lanes; + if (0 !== (renderLanes & workInProgress.childLanes)) { + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderLanes = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderLanes; + for (renderLanes.return = workInProgress; null !== current.sibling; ) + (current = current.sibling), + (renderLanes = renderLanes.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderLanes.return = workInProgress); + renderLanes.sibling = null; + } + return workInProgress.child; } - return workInProgress.child; + return null; } var appendAllChildren, updateHostContainer, @@ -4480,10 +4828,10 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && (requiredContext(contextStackCursor$1.current), (workInProgress.updateQueue = UPDATE_SIGNAL)) && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); }; updateHostText$1 = function(current, workInProgress, oldText, newText) { - oldText !== newText && (workInProgress.effectTag |= 4); + oldText !== newText && (workInProgress.flags |= 4); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4499,17 +4847,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var _lastTailNode = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), + for (var lastTailNode$64 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === _lastTailNode + null === lastTailNode$64 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (_lastTailNode.sibling = null); + : (lastTailNode$64.sibling = null); } } -function completeWork(current, workInProgress, renderExpirationTime) { +function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -4530,10 +4878,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - (current = workInProgress.stateNode), - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)), + resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)), + (null !== current && null !== current.child) || + newProps.hydrate || + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -4542,17 +4894,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderExpirationTime = workInProgress.type; + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderExpirationTime, + renderLanes, newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4563,22 +4914,22 @@ function completeWork(current, workInProgress, renderExpirationTime) { } requiredContext(contextStackCursor$1.current); current = allocateTag(); - renderExpirationTime = getViewConfigForType(renderExpirationTime); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - renderExpirationTime.validAttributes + renderLanes.validAttributes ); ReactNativePrivateInterface.UIManager.createView( current, - renderExpirationTime.uiViewClassName, + renderLanes.uiViewClassName, rootContainerInstance, updatePayload ); rootContainerInstance = new ReactNativeFiberHostComponent( current, - renderExpirationTime, + renderLanes, workInProgress ); instanceCache.set(current, workInProgress); @@ -4586,8 +4937,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { appendAllChildren(rootContainerInstance, workInProgress, !1, !1); workInProgress.stateNode = rootContainerInstance; finalizeInitialChildren(rootContainerInstance) && - (workInProgress.effectTag |= 4); - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + (workInProgress.flags |= 4); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -4622,52 +4973,35 @@ function completeWork(current, workInProgress, renderExpirationTime) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) - return ( - (workInProgress.expirationTime = renderExpirationTime), workInProgress - ); + if (0 !== (workInProgress.flags & 64)) + return (workInProgress.lanes = renderLanes), workInProgress; newProps = null !== newProps; rootContainerInstance = !1; null !== current && - ((renderExpirationTime = current.memoizedState), - (rootContainerInstance = null !== renderExpirationTime), - newProps || - null === renderExpirationTime || - ((renderExpirationTime = current.child.sibling), - null !== renderExpirationTime && - ((updatePayload = workInProgress.firstEffect), - null !== updatePayload - ? ((workInProgress.firstEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = updatePayload)) - : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = null)), - (renderExpirationTime.effectTag = 8)))); + (rootContainerInstance = null !== current.memoizedState); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); + 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3); else { if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( - workInProgressRoot, - renderExpirationTime$1 - ), - markRootUpdatedAtTime( + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || + markRootSuspended$1( workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); + workInProgressRootRenderLanes + ); } - if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; + if (newProps || rootContainerInstance) workInProgress.flags |= 4; return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -4679,48 +5013,48 @@ function completeWork(current, workInProgress, renderExpirationTime) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== current && 0 !== (current.effectTag & 64)) + 0 !== workInProgressRootExitStatus || + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderExpirationTime; + current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), - (renderExpirationTime = current), - (rootContainerInstance.effectTag &= 2), + (renderLanes = current), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), (updatePayload = rootContainerInstance.alternate), null === updatePayload - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = renderExpirationTime), + ? ((rootContainerInstance.childLanes = 0), + (rootContainerInstance.lanes = renderLanes), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null)) - : ((rootContainerInstance.childExpirationTime = - updatePayload.childExpirationTime), - (rootContainerInstance.expirationTime = - updatePayload.expirationTime), + (rootContainerInstance.dependencies = null), + (rootContainerInstance.stateNode = null)) + : ((rootContainerInstance.childLanes = + updatePayload.childLanes), + (rootContainerInstance.lanes = updatePayload.lanes), (rootContainerInstance.child = updatePayload.child), (rootContainerInstance.memoizedProps = updatePayload.memoizedProps), @@ -4728,15 +5062,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { updatePayload.memoizedState), (rootContainerInstance.updateQueue = updatePayload.updateQueue), - (renderExpirationTime = updatePayload.dependencies), + (rootContainerInstance.type = updatePayload.type), + (renderLanes = updatePayload.dependencies), (rootContainerInstance.dependencies = - null === renderExpirationTime + null === renderLanes ? null : { - expirationTime: - renderExpirationTime.expirationTime, - firstContext: renderExpirationTime.firstContext, - responders: renderExpirationTime.responders + lanes: renderLanes.lanes, + firstContext: renderLanes.firstContext })), (newProps = newProps.sibling); push( @@ -4747,6 +5080,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); } else { if (!rootContainerInstance) @@ -4754,12 +5093,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -4772,13 +5111,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1 < renderExpirationTime && - ((workInProgress.effectTag |= 64), + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && + 1073741824 !== renderLanes && + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.expirationTime = workInProgress.childExpirationTime = - renderExpirationTime - 1)); + (workInProgress.lanes = 33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -4789,9 +5128,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -4806,6 +5143,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { ), current) : null; + case 23: + case 24: + return ( + popRenderLanes(), + null !== current && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && + "unstable-defer-without-hiding" !== newProps.mode && + (workInProgress.flags |= 4), + null + ); } throw Error( "Unknown unit of work tag (" + @@ -4817,31 +5165,30 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + resetWorkInProgressVersions(); + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - workInProgress) + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null ); case 19: @@ -4850,6 +5197,9 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 23: + case 24: + return popRenderLanes(), null; default: return null; } @@ -4868,51 +5218,61 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(capturedError) { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( - capturedError - ) && console.error(capturedError.error); -} -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; -function logError(boundary, errorInfo) { - var source = errorInfo.source, - stack = errorInfo.stack; - null === stack && - null !== source && - (stack = getStackByFiberInDevAndProd(source)); - errorInfo = { - componentName: null !== source ? getComponentName(source.type) : null, - componentStack: null !== stack ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: !1, - willRetry: !1 - }; - null !== boundary && - 1 === boundary.tag && - ((errorInfo.errorBoundary = boundary.stateNode), - (errorInfo.errorBoundaryName = getComponentName(boundary.type)), - (errorInfo.errorBoundaryFound = !0), - (errorInfo.willRetry = !0)); +function logCapturedError(boundary, errorInfo) { try { - logCapturedError(errorInfo); + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + componentStack: null !== errorInfo.stack ? errorInfo.stack : "", + error: errorInfo.value, + errorBoundary: + null !== boundary && 1 === boundary.tag ? boundary.stateNode : null + }) && console.error(errorInfo.value); } catch (e) { setTimeout(function() { throw e; }); } } -function safelyCallComponentWillUnmount(current, instance) { - try { - (instance.props = current.memoizedProps), - (instance.state = current.memoizedState), - instance.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, unmountError); +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + lane.payload = { element: null }; + var error = errorInfo.value; + lane.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logCapturedError(fiber, errorInfo); + }; + return lane; +} +function createClassErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + lane.payload = function() { + logCapturedError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (lane.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logCapturedError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return lane; } +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -4932,7 +5292,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -4946,6 +5306,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: + return; case 5: case 6: case 4: @@ -4956,58 +5317,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitHookEffectListUnmount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var destroy = effect.destroy; - effect.destroy = void 0; - void 0 !== destroy && destroy(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} -function commitHookEffectListMount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var create = effect.create; - effect.destroy = create(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - commitHookEffectListMount(3, finishedWork); + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + if (3 === (finishedRoot.tag & 3)) { + var create$81 = finishedRoot.create; + finishedRoot.destroy = create$81(); + } + finishedRoot = finishedRoot.next; + } while (finishedRoot !== current); + } + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + var _effect = finishedRoot; + create$81 = _effect.next; + _effect = _effect.tag; + 0 !== (_effect & 4) && + 0 !== (_effect & 1) && + (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), + enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); + finishedRoot = create$81; + } while (finishedRoot !== current); + } return; case 1: finishedRoot = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current) finishedRoot.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - finishedRoot.componentDidUpdate( - prevProps, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ); - } + finishedWork.flags & 4 && + (null === current + ? finishedRoot.componentDidMount() + : ((create$81 = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current.memoizedProps + )), + finishedRoot.componentDidUpdate( + create$81, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ))); current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5041,78 +5401,138 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 23: + case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$jscomp$0); - switch (current$jscomp$0.tag) { +function hideOrUnhideAllChildren(finishedWork, isHidden) { + for (var node = finishedWork; ; ) { + if (5 === node.tag) { + var instance = node.stateNode; + if (isHidden) { + var viewConfig = instance.viewConfig; + var updatePayload = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); + } else { + instance = node.stateNode; + updatePayload = node.memoizedProps; + viewConfig = instance.viewConfig; + var prevProps = Object.assign({}, updatePayload, { + style: [updatePayload.style, { display: "none" }] + }); + updatePayload = diffProperties( + null, + prevProps, + updatePayload, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); + } + } else { + if (6 === node.tag) throw Error("Not yet implemented."); + if ( + ((23 !== node.tag && 24 !== node.tag) || + null === node.memoizedState || + node === finishedWork) && + null !== node.child + ) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === finishedWork) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === finishedWork) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +} +function commitUnmount(finishedRoot, current) { + if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) + try { + injectedHook.onCommitFiberUnmount(rendererID, current); + } catch (err) {} + switch (current.tag) { case 0: case 11: case 14: case 15: case 22: - finishedRoot = current$jscomp$0.updateQueue; + finishedRoot = current.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { - var firstEffect = finishedRoot.next; - runWithPriority( - 97 < renderPriorityLevel ? 97 : renderPriorityLevel, - function() { - var effect = firstEffect; - do { - var _destroy = effect.destroy; - if (void 0 !== _destroy) { - var current = current$jscomp$0; - try { - _destroy(); - } catch (error) { - captureCommitPhaseError(current, error); - } + var effect = (finishedRoot = finishedRoot.next); + do { + var _effect2 = effect, + destroy = _effect2.destroy; + _effect2 = _effect2.tag; + if (void 0 !== destroy) + if (0 !== (_effect2 & 4)) + enqueuePendingPassiveHookEffectUnmount(current, effect); + else { + _effect2 = current; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(_effect2, error); } - effect = effect.next; - } while (effect !== firstEffect); - } - ); + } + effect = effect.next; + } while (effect !== finishedRoot); } break; case 1: - safelyDetachRef(current$jscomp$0); - renderPriorityLevel = current$jscomp$0.stateNode; - "function" === typeof renderPriorityLevel.componentWillUnmount && - safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); + safelyDetachRef(current); + finishedRoot = current.stateNode; + if ("function" === typeof finishedRoot.componentWillUnmount) + try { + (finishedRoot.props = current.memoizedProps), + (finishedRoot.state = current.memoizedState), + finishedRoot.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(current, unmountError); + } break; case 5: - safelyDetachRef(current$jscomp$0); + safelyDetachRef(current); break; case 4: - unmountHostComponents( - finishedRoot, - current$jscomp$0, - renderPriorityLevel - ); + unmountHostComponents(finishedRoot, current); } } -function detachFiber(current) { - var alternate = current.alternate; - current.return = null; - current.child = null; - current.memoizedState = null; - current.updateQueue = null; - current.dependencies = null; - current.alternate = null; - current.firstEffect = null; - current.lastEffect = null; - current.pendingProps = null; - current.memoizedProps = null; - current.stateNode = null; - null !== alternate && detachFiber(alternate); +function detachFiberMutation(fiber) { + fiber.alternate = null; + fiber.child = null; + fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.return = null; + fiber.updateQueue = null; } function isHostParent(fiber) { return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; @@ -5120,16 +5540,14 @@ function isHostParent(fiber) { function commitPlacement(finishedWork) { a: { for (var parent = finishedWork.return; null !== parent; ) { - if (isHostParent(parent)) { - var parentFiber = parent; - break a; - } + if (isHostParent(parent)) break a; parent = parent.return; } throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); } + var parentFiber = parent; parent = parentFiber.stateNode; switch (parentFiber.tag) { case 5: @@ -5148,7 +5566,7 @@ function commitPlacement(finishedWork) { "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } - parentFiber.effectTag & 16 && (parentFiber.effectTag &= -17); + parentFiber.flags & 16 && (parentFiber.flags &= -17); a: b: for (parentFiber = finishedWork; ; ) { for (; null === parentFiber.sibling; ) { if (null === parentFiber.return || isHostParent(parentFiber.return)) { @@ -5163,13 +5581,13 @@ function commitPlacement(finishedWork) { 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag; ) { - if (parentFiber.effectTag & 2) continue b; + if (parentFiber.flags & 2) continue b; if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); } - if (!(parentFiber.effectTag & 2)) { + if (!(parentFiber.flags & 2)) { parentFiber = parentFiber.stateNode; break a; } @@ -5264,11 +5682,7 @@ function insertOrAppendPlacementNode(node, before, parent) { ) insertOrAppendPlacementNode(node, before, parent), (node = node.sibling); } -function unmountHostComponents( - finishedRoot$jscomp$0, - current, - renderPriorityLevel$jscomp$0 -) { +function unmountHostComponents(finishedRoot$jscomp$0, current) { for ( var node = current, currentParentIsValid = !1, @@ -5306,13 +5720,12 @@ function unmountHostComponents( a: for ( var finishedRoot = finishedRoot$jscomp$0, root = node, - renderPriorityLevel = renderPriorityLevel$jscomp$0, node$jscomp$0 = root; ; ) if ( - (commitUnmount(finishedRoot, node$jscomp$0, renderPriorityLevel), + (commitUnmount(finishedRoot, node$jscomp$0), null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), @@ -5339,18 +5752,18 @@ function unmountHostComponents( [0] )) : ((finishedRoot = currentParent), - (renderPriorityLevel = node.stateNode), - recursivelyUncacheFiberNode(renderPriorityLevel), + (node$jscomp$0 = node.stateNode), + recursivelyUncacheFiberNode(node$jscomp$0), (root = finishedRoot._children), - (renderPriorityLevel = root.indexOf(renderPriorityLevel)), - root.splice(renderPriorityLevel, 1), + (node$jscomp$0 = root.indexOf(node$jscomp$0)), + root.splice(node$jscomp$0, 1), ReactNativePrivateInterface.UIManager.manageChildren( finishedRoot._nativeTag, [], [], [], [], - [renderPriorityLevel] + [node$jscomp$0] )); } else if (4 === node.tag) { if (null !== node.child) { @@ -5361,8 +5774,7 @@ function unmountHostComponents( continue; } } else if ( - (commitUnmount(finishedRoot$jscomp$0, node, renderPriorityLevel$jscomp$0), - null !== node.child) + (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child) ) { node.child.return = node; node = node.child; @@ -5385,31 +5797,42 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - commitHookEffectListUnmount(3, finishedWork); + var updateQueue = finishedWork.updateQueue; + updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; + if (null !== updateQueue) { + var effect = (updateQueue = updateQueue.next); + do + 3 === (effect.tag & 3) && + ((finishedWork = effect.destroy), + (effect.destroy = void 0), + void 0 !== finishedWork && finishedWork()), + (effect = effect.next); + while (effect !== updateQueue); + } return; case 1: return; case 5: - var instance = finishedWork.stateNode; - if (null != instance) { - var newProps = finishedWork.memoizedProps; - current = null !== current ? current.memoizedProps : newProps; + updateQueue = finishedWork.stateNode; + if (null != updateQueue) { + effect = finishedWork.memoizedProps; + current = null !== current ? current.memoizedProps : effect; var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - ((finishedWork = instance.viewConfig), - instanceProps.set(instance._nativeTag, newProps), - (newProps = diffProperties( + ((finishedWork = updateQueue.viewConfig), + instanceProps.set(updateQueue._nativeTag, effect), + (effect = diffProperties( null, current, - newProps, + effect, finishedWork.validAttributes )), - null != newProps && + null != effect && ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, + updateQueue._nativeTag, finishedWork.uiViewClassName, - newProps + effect )); } return; @@ -5429,72 +5852,9 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - instance = finishedWork; - null === finishedWork.memoizedState - ? (newProps = !1) - : ((newProps = !0), - (instance = finishedWork.child), - (globalMostRecentFallbackTime = now())); - if (null !== instance) - a: for (current = instance; ; ) { - if (5 === current.tag) - if (((updatePayload = current.stateNode), newProps)) { - var viewConfig = updatePayload.viewConfig; - var updatePayload$jscomp$0 = diffProperties( - null, - emptyObject, - { style: { display: "none" } }, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - updatePayload._nativeTag, - viewConfig.uiViewClassName, - updatePayload$jscomp$0 - ); - } else { - updatePayload = current.stateNode; - updatePayload$jscomp$0 = current.memoizedProps; - viewConfig = updatePayload.viewConfig; - var prevProps = Object.assign({}, updatePayload$jscomp$0, { - style: [updatePayload$jscomp$0.style, { display: "none" }] - }); - updatePayload$jscomp$0 = diffProperties( - null, - prevProps, - updatePayload$jscomp$0, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - updatePayload._nativeTag, - viewConfig.uiViewClassName, - updatePayload$jscomp$0 - ); - } - else { - if (6 === current.tag) throw Error("Not yet implemented."); - if ( - 13 === current.tag && - null !== current.memoizedState && - null === current.memoizedState.dehydrated - ) { - updatePayload = current.child.sibling; - updatePayload.return = current; - current = updatePayload; - continue; - } else if (null !== current.child) { - current.child.return = current; - current = current.child; - continue; - } - } - if (current === instance) break; - for (; null === current.sibling; ) { - if (null === current.return || current.return === instance) break a; - current = current.return; - } - current.sibling.return = current.return; - current = current.sibling; - } + null !== finishedWork.memoizedState && + ((globalMostRecentFallbackTime = now()), + hideOrUnhideAllChildren(finishedWork.child, !0)); attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -5502,90 +5862,58 @@ function commitWork(current, finishedWork) { return; case 17: return; + case 23: + case 24: + hideOrUnhideAllChildren( + finishedWork, + null !== finishedWork.memoizedState + ); + return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } function attachSuspenseRetryListeners(finishedWork) { - var thenables = finishedWork.updateQueue; - if (null !== thenables) { + var wakeables = finishedWork.updateQueue; + if (null !== wakeables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - thenables.forEach(function(thenable) { - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - retryCache.has(thenable) || - (retryCache.add(thenable), thenable.then(retry, retry)); + wakeables.forEach(function(wakeable) { + var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + retryCache.has(wakeable) || + (retryCache.add(wakeable), wakeable.then(retry, retry)); }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - expirationTime.payload = { element: null }; - var error = errorInfo.value; - expirationTime.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logError(fiber, errorInfo); - }; - return expirationTime; -} -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - expirationTime.payload = function() { - logError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; - } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (expirationTime.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return expirationTime; +function isSuspenseBoundaryBeingHidden(current, finishedWork) { + return null !== current && + ((current = current.memoizedState), + null === current || null !== current.dehydrated) + ? ((finishedWork = finishedWork.memoizedState), + null !== finishedWork && null === finishedWork.dehydrated) + : !1; } var ceil = Math.ceil, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - NoContext = 0, - LegacyUnbatchedContext = 8, - RenderContext = 16, - CommitContext = 32, - RootIncomplete = 0, - RootFatalErrored = 1, - RootErrored = 2, - RootSuspended = 3, - RootSuspendedWithDelay = 4, - RootCompleted = 5, - executionContext = NoContext, + executionContext = 0, workInProgressRoot = null, workInProgress = null, - renderExpirationTime$1 = 0, - workInProgressRootExitStatus = RootIncomplete, + workInProgressRootRenderLanes = 0, + subtreeRenderLanes = 0, + subtreeRenderLanesCursor = createCursor(0), + workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestProcessedExpirationTime = 1073741823, - workInProgressRootLatestSuspenseTimeout = 1073741823, - workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootNextUnprocessedUpdateTime = 0, - workInProgressRootHasPendingPing = !1, + workInProgressRootIncludedLanes = 0, + workInProgressRootSkippedLanes = 0, + workInProgressRootUpdatedLanes = 0, + workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, - FALLBACK_THROTTLE_MS = 500, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5593,205 +5921,186 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, - currentEventTime = 0; -function requestCurrentTimeForUpdate() { - return (executionContext & (RenderContext | CommitContext)) !== NoContext - ? 1073741821 - ((now() / 10) | 0) - : 0 !== currentEventTime + currentEventTime = -1, + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; +function requestEventTime() { + return 0 !== (executionContext & 48) + ? now() + : -1 !== currentEventTime ? currentEventTime - : (currentEventTime = 1073741821 - ((now() / 10) | 0)); + : (currentEventTime = now()); } -function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1073741823; - var priorityLevel = getCurrentPriorityLevel(); - if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; - if ((executionContext & RenderContext) !== NoContext) - return renderExpirationTime$1; - if (null !== suspenseConfig) - currentTime = - 1073741821 - - 25 * - ((((1073741821 - - currentTime + - (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / - 25) | - 0) + - 1); - else - switch (priorityLevel) { - case 99: - currentTime = 1073741823; - break; - case 98: - currentTime = - 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); - break; - case 97: - case 96: - currentTime = - 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); - break; - case 95: - currentTime = 2; - break; - default: - throw Error("Expected a valid priority level"); - } - null !== workInProgressRoot && - currentTime === renderExpirationTime$1 && - --currentTime; - return currentTime; -} -function scheduleWork(fiber, expirationTime) { - if (50 < nestedUpdateCount) - throw ((nestedUpdateCount = 0), - (rootWithNestedUpdates = null), - Error( - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - )); - fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); - if (null !== fiber) { - var priorityLevel = getCurrentPriorityLevel(); - 1073741823 === expirationTime - ? (executionContext & LegacyUnbatchedContext) !== NoContext && - (executionContext & (RenderContext | CommitContext)) === NoContext - ? performSyncWorkOnRoot(fiber) - : (ensureRootIsScheduled(fiber), - executionContext === NoContext && flushSyncCallbackQueue()) - : ensureRootIsScheduled(fiber); - (executionContext & 4) === NoContext || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) - : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), - (void 0 === priorityLevel || priorityLevel > expirationTime) && - rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); + if (0 === (fiber & 2)) return 1; + if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; + 0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes); + if (0 !== ReactCurrentBatchConfig.transition) { + 0 !== currentEventPendingLanes && + (currentEventPendingLanes = + null !== mostRecentlyUpdatedRoot + ? mostRecentlyUpdatedRoot.pendingLanes + : 0); + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; } -} -function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); - var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < expirationTime && - (alternate.expirationTime = expirationTime); - var node = fiber.return, - root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; - else - for (; null !== node; ) { - alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); - null !== alternate && - alternate.childExpirationTime < expirationTime && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { - root = node.stateNode; - break; + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; +} +function scheduleUpdateOnFiber(fiber, lane, eventTime) { + if (50 < nestedUpdateCount) + throw ((nestedUpdateCount = 0), + (rootWithNestedUpdates = null), + Error( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + )); + fiber = markUpdateLaneFromFiberToRoot(fiber, lane); + if (null === fiber) return null; + markRootUpdated(fiber, lane, eventTime); + fiber === workInProgressRoot && + ((workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(fiber, workInProgressRootRenderLanes)); + var priorityLevel = getCurrentPriorityLevel(); + 1 === lane + ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) + ? performSyncWorkOnRoot(fiber) + : (ensureRootIsScheduled(fiber, eventTime), + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) + : (0 === (executionContext & 4) || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) + : rootsWithPendingDiscreteUpdates.add(fiber)), + ensureRootIsScheduled(fiber, eventTime)); + mostRecentlyUpdatedRoot = fiber; +} +function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + sourceFiber.lanes |= lane; + var alternate = sourceFiber.alternate; + null !== alternate && (alternate.lanes |= lane); + alternate = sourceFiber; + for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) + (sourceFiber.childLanes |= lane), + (alternate = sourceFiber.alternate), + null !== alternate && (alternate.childLanes |= lane), + (alternate = sourceFiber), + (sourceFiber = sourceFiber.return); + return 3 === alternate.tag ? alternate.stateNode : null; +} +function ensureRootIsScheduled(root, currentTime) { + for ( + var existingCallbackNode = root.callbackNode, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes; + 0 < lanes; + + ) { + var index$7 = 31 - clz32(lanes), + lane = 1 << index$7, + expirationTime = expirationTimes[index$7]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { + expirationTime = currentTime; + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; + expirationTimes[index$7] = + 10 <= priority + ? expirationTime + 250 + : 6 <= priority + ? expirationTime + 5e3 + : -1; } - node = node.return; - } - null !== root && - (workInProgressRoot === root && - (markUnprocessedUpdateTime(expirationTime), - workInProgressRootExitStatus === RootSuspendedWithDelay && - markRootSuspendedAtTime(root, renderExpirationTime$1)), - markRootUpdatedAtTime(root, expirationTime)); - return root; -} -function getNextRootExpirationTimeToWorkOn(root) { - var lastExpiredTime = root.lastExpiredTime; - if (0 !== lastExpiredTime) return lastExpiredTime; - lastExpiredTime = root.firstPendingTime; - if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; - var lastPingedTime = root.lastPingedTime; - root = root.nextKnownPendingLevel; - root = lastPingedTime > root ? lastPingedTime : root; - return 2 >= root && lastExpiredTime !== root ? 0 : root; -} -function ensureRootIsScheduled(root) { - if (0 !== root.lastExpiredTime) - (root.callbackExpirationTime = 1073741823), - (root.callbackPriority = 99), - (root.callbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - )); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + suspendedLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + currentTime = return_highestLanePriority; + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode), + (root.callbackNode = null), + (root.callbackPriority = 0)); else { - var expirationTime = getNextRootExpirationTimeToWorkOn(root), - existingCallbackNode = root.callbackNode; - if (0 === expirationTime) - null !== existingCallbackNode && - ((root.callbackNode = null), - (root.callbackExpirationTime = 0), - (root.callbackPriority = 90)); - else { - var priorityLevel = requestCurrentTimeForUpdate(); - 1073741823 === expirationTime - ? (priorityLevel = 99) - : 1 === expirationTime || 2 === expirationTime - ? (priorityLevel = 95) - : ((priorityLevel = - 10 * (1073741821 - expirationTime) - - 10 * (1073741821 - priorityLevel)), - (priorityLevel = - 0 >= priorityLevel - ? 99 - : 250 >= priorityLevel - ? 98 - : 5250 >= priorityLevel - ? 97 - : 95)); - if (null !== existingCallbackNode) { - var existingCallbackPriority = root.callbackPriority; - if ( - root.callbackExpirationTime === expirationTime && - existingCallbackPriority >= priorityLevel - ) - return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); - } - root.callbackExpirationTime = expirationTime; - root.callbackPriority = priorityLevel; - expirationTime = - 1073741823 === expirationTime - ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleCallback( - priorityLevel, - performConcurrentWorkOnRoot.bind(null, root), - { timeout: 10 * (1073741821 - expirationTime) - now() } - ); - root.callbackNode = expirationTime; + if (null !== existingCallbackNode) { + if (root.callbackPriority === currentTime) return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); } + 15 === currentTime + ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), + null === syncQueue + ? ((syncQueue = [existingCallbackNode]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(existingCallbackNode), + (existingCallbackNode = fakeCallbackNode)) + : 14 === currentTime + ? (existingCallbackNode = scheduleCallback( + 99, + performSyncWorkOnRoot.bind(null, root) + )) + : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), + (existingCallbackNode = scheduleCallback( + existingCallbackNode, + performConcurrentWorkOnRoot.bind(null, root) + ))); + root.callbackPriority = currentTime; + root.callbackNode = existingCallbackNode; } } -function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = 0; - if (didTimeout) { - didTimeout = requestCurrentTimeForUpdate(); - var lastExpiredTime = root.lastExpiredTime; - if (0 === lastExpiredTime || lastExpiredTime > didTimeout) - root.lastExpiredTime = didTimeout; - ensureRootIsScheduled(root); - return null; - } - lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); - if (0 === lastExpiredTime) return null; - didTimeout = root.callbackNode; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) +function performConcurrentWorkOnRoot(root) { + currentEventTime = -1; + currentEventPendingLanes = currentEventWipLanes = 0; + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - flushPassiveEffects(); - var expirationTime = lastExpiredTime; - var exitStatus = executionContext; - executionContext |= RenderContext; + var originalCallbackNode = root.callbackNode; + if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + return null; + var lanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + if (0 === lanes) return null; + var exitStatus = lanes; + var prevExecutionContext = executionContext; + executionContext |= 16; var prevDispatcher = pushDispatcher(); - (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || - prepareFreshStack(root, expirationTime); + if ( + workInProgressRoot !== root || + workInProgressRootRenderLanes !== exitStatus + ) + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, exitStatus); do try { workLoopConcurrent(); @@ -5801,199 +6110,163 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - ReactCurrentDispatcher$1.current = prevDispatcher; - executionContext = exitStatus; + ReactCurrentDispatcher$2.current = prevDispatcher; + executionContext = prevExecutionContext; null !== workInProgress - ? (exitStatus = RootIncomplete) + ? (exitStatus = 0) : ((workInProgressRoot = null), + (workInProgressRootRenderLanes = 0), (exitStatus = workInProgressRootExitStatus)); - if (exitStatus !== RootIncomplete) { - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) - throw ((didTimeout = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - didTimeout); - expirationTime = root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) + prepareFreshStack(root, 0); + else if (0 !== exitStatus) { + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && (root.hydrate = !1), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = root.current.alternate; + root.finishedLanes = lanes; switch (exitStatus) { - case RootIncomplete: - case RootFatalErrored: + case 0: + case 1: throw Error("Root did not complete. This is a bug in React."); - case RootErrored: + case 2: commitRoot(root); break; - case RootSuspended: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - expirationTime - )); + case 3: + markRootSuspended$1(root, lanes); if ( - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - ((expirationTime = - globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), - 10 < expirationTime) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { - if ( - workInProgressRootHasPendingPing && - ((prevDispatcher = root.lastPingedTime), - 0 === prevDispatcher || prevDispatcher >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - prevDispatcher = getNextRootExpirationTimeToWorkOn(root); - if (0 !== prevDispatcher && prevDispatcher !== lastExpiredTime) break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; + if (0 !== getNextLanes(root, 0)) break; + prevExecutionContext = root.suspendedLanes; + if ((prevExecutionContext & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevExecutionContext; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - expirationTime + exitStatus ); break; } commitRoot(root); break; - case RootSuspendedWithDelay: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - expirationTime - )); - if ( - workInProgressRootHasPendingPing && - ((expirationTime = root.lastPingedTime), - 0 === expirationTime || expirationTime >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - expirationTime = getNextRootExpirationTimeToWorkOn(root); - if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; - break; + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) { + var index$6 = 31 - clz32(lanes); + prevDispatcher = 1 << index$6; + index$6 = exitStatus[index$6]; + index$6 > prevExecutionContext && (prevExecutionContext = index$6); + lanes &= ~prevDispatcher; } - 1073741823 !== workInProgressRootLatestSuspenseTimeout - ? (expirationTime = - 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - - now()) - : 1073741823 === workInProgressRootLatestProcessedExpirationTime - ? (expirationTime = 0) - : ((expirationTime = - 10 * - (1073741821 - workInProgressRootLatestProcessedExpirationTime) - - 5e3), - (exitStatus = now()), - (lastExpiredTime = - 10 * (1073741821 - lastExpiredTime) - exitStatus), - (expirationTime = exitStatus - expirationTime), - 0 > expirationTime && (expirationTime = 0), - (expirationTime = - (120 > expirationTime - ? 120 - : 480 > expirationTime - ? 480 - : 1080 > expirationTime - ? 1080 - : 1920 > expirationTime - ? 1920 - : 3e3 > expirationTime - ? 3e3 - : 4320 > expirationTime - ? 4320 - : 1960 * ceil(expirationTime / 1960)) - expirationTime), - lastExpiredTime < expirationTime && - (expirationTime = lastExpiredTime)); - if (10 < expirationTime) { + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - expirationTime + lanes ); break; } commitRoot(root); break; - case RootCompleted: - if ( - 1073741823 !== workInProgressRootLatestProcessedExpirationTime && - null !== workInProgressRootCanSuspendUsingConfig - ) { - prevDispatcher = workInProgressRootLatestProcessedExpirationTime; - var suspenseConfig = workInProgressRootCanSuspendUsingConfig; - expirationTime = suspenseConfig.busyMinDurationMs | 0; - 0 >= expirationTime - ? (expirationTime = 0) - : ((exitStatus = suspenseConfig.busyDelayMs | 0), - (prevDispatcher = - now() - - (10 * (1073741821 - prevDispatcher) - - (suspenseConfig.timeoutMs | 0 || 5e3))), - (expirationTime = - prevDispatcher <= exitStatus - ? 0 - : exitStatus + expirationTime - prevDispatcher)); - if (10 < expirationTime) { - markRootSuspendedAtTime(root, lastExpiredTime); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - expirationTime - ); - break; - } - } + case 5: commitRoot(root); break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root); - return root.callbackNode === didTimeout + ensureRootIsScheduled(root, now()); + return root.callbackNode === originalCallbackNode ? performConcurrentWorkOnRoot.bind(null, root) : null; } +function markRootSuspended$1(root, suspendedLanes) { + suspendedLanes &= ~workInProgressRootPingedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; + for (root = root.expirationTimes; 0 < suspendedLanes; ) { + var index$11 = 31 - clz32(suspendedLanes), + lane = 1 << index$11; + root[index$11] = -1; + suspendedLanes &= ~lane; + } +} function performSyncWorkOnRoot(root) { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lastExpiredTime = root.lastExpiredTime; - lastExpiredTime = - 0 !== lastExpiredTime - ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime - ? renderExpirationTime$1 - : lastExpiredTime - : 1073741823; - var exitStatus = renderRootSync(root, lastExpiredTime); + if ( + root === workInProgressRoot && + 0 !== (root.expiredLanes & workInProgressRootRenderLanes) + ) { + var lanes = workInProgressRootRenderLanes; + var exitStatus = renderRootSync(root, lanes); + 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && + ((lanes = getNextLanes(root, lanes)), + (exitStatus = renderRootSync(root, lanes))); + } else + (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); 0 !== root.tag && - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && (root.hydrate = !1), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), exitStatus); root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + root.finishedLanes = lanes; commitRoot(root); - ensureRootIsScheduled(root); + ensureRootIsScheduled(root, now()); return null; } -function prepareFreshStack(root, expirationTime) { +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} +function popRenderLanes() { + subtreeRenderLanes = subtreeRenderLanesCursor.current; + pop(subtreeRenderLanesCursor); +} +function prepareFreshStack(root, lanes) { root.finishedWork = null; - root.finishedExpirationTime = 0; + root.finishedLanes = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -6011,6 +6284,7 @@ function prepareFreshStack(root, expirationTime) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); + resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -6026,25 +6300,27 @@ function prepareFreshStack(root, expirationTime) { break; case 10: popProvider(interruptedWork); + break; + case 23: + case 24: + popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - renderExpirationTime$1 = expirationTime; - workInProgressRootExitStatus = RootIncomplete; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; - workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootNextUnprocessedUpdateTime = 0; - workInProgressRootHasPendingPing = !1; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; } function handleError(root$jscomp$0, thrownValue) { do { + var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) { for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -6054,49 +6330,52 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - renderExpirationTime = 0; + didScheduleRenderPhaseUpdate = !1; + } + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdate = !1; - if (null === workInProgress || null === workInProgress.return) - return ( - (workInProgressRootExitStatus = RootFatalErrored), - (workInProgressRootFatalError = thrownValue), - (workInProgress = null) - ); + didScheduleRenderPhaseUpdateDuringThisPass = !1; + ReactCurrentOwner$2.current = null; + if (null === erroredWork || null === erroredWork.return) { + workInProgressRootExitStatus = 1; + workInProgressRootFatalError = thrownValue; + workInProgress = null; + break; + } a: { var root = root$jscomp$0, - returnFiber = workInProgress.return, - sourceFiber = workInProgress, + returnFiber = erroredWork.return, + sourceFiber = erroredWork, value = thrownValue; - thrownValue = renderExpirationTime$1; - sourceFiber.effectTag |= 2048; + thrownValue = workInProgressRootRenderLanes; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var thenable = value; + var wakeable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.expirationTime = currentSource.expirationTime)) + (sourceFiber.lanes = currentSource.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - _workInProgress = returnFiber; + workInProgress$76 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === _workInProgress.tag)) { - var nextState = _workInProgress.memoizedState; + if ((JSCompiler_temp = 13 === workInProgress$76.tag)) { + var nextState = workInProgress$76.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = _workInProgress.memoizedProps; + var props = workInProgress$76.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6108,23 +6387,24 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var thenables = _workInProgress.updateQueue; - if (null === thenables) { + var wakeables = workInProgress$76.updateQueue; + if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(thenable); - _workInProgress.updateQueue = updateQueue; - } else thenables.add(thenable); - if (0 === (_workInProgress.mode & 2)) { - _workInProgress.effectTag |= 64; - sourceFiber.effectTag &= -2981; + updateQueue.add(wakeable); + workInProgress$76.updateQueue = updateQueue; + } else wakeables.add(wakeable); + if (0 === (workInProgress$76.mode & 2)) { + workInProgress$76.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(1073741823, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.expirationTime = 1073741823; + sourceFiber.lanes |= 1; break a; } value = void 0; @@ -6133,108 +6413,98 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(thenable, value)) - : ((value = pingCache.get(thenable)), + pingCache.set(wakeable, value)) + : ((value = pingCache.get(wakeable)), void 0 === value && - ((value = new Set()), pingCache.set(thenable, value))); + ((value = new Set()), pingCache.set(wakeable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - thenable, + wakeable, sourceFiber ); - thenable.then(ping, ping); + wakeable.then(ping, ping); } - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; + workInProgress$76.flags |= 8192; + workInProgress$76.lanes = thrownValue; break a; } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$76 = workInProgress$76.return; + } while (null !== workInProgress$76); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); } - workInProgressRootExitStatus !== RootCompleted && - (workInProgressRootExitStatus = RootErrored); + 5 !== workInProgressRootExitStatus && + (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - _workInProgress = returnFiber; + workInProgress$76 = returnFiber; do { - switch (_workInProgress.tag) { + switch (workInProgress$76.tag) { case 3: - thenable = value; - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update = createRootErrorUpdate( - _workInProgress, - thenable, + root = value; + workInProgress$76.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$76.lanes |= thrownValue; + var update$77 = createRootErrorUpdate( + workInProgress$76, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update); + enqueueCapturedUpdate(workInProgress$76, update$77); break a; case 1: - thenable = value; - var ctor = _workInProgress.type, - instance = _workInProgress.stateNode; + root = value; + var ctor = workInProgress$76.type, + instance = workInProgress$76.stateNode; if ( - 0 === (_workInProgress.effectTag & 64) && + 0 === (workInProgress$76.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update2 = createClassErrorUpdate( - _workInProgress, - thenable, + workInProgress$76.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$76.lanes |= thrownValue; + var update$80 = createClassErrorUpdate( + workInProgress$76, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update2); + enqueueCapturedUpdate(workInProgress$76, update$80); break a; } } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$76 = workInProgress$76.return; + } while (null !== workInProgress$76); } - workInProgress = completeUnitOfWork(workInProgress); + completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; + workInProgress === erroredWork && + null !== erroredWork && + (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$2.current; + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } -function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { - expirationTime < workInProgressRootLatestProcessedExpirationTime && - 2 < expirationTime && - (workInProgressRootLatestProcessedExpirationTime = expirationTime); - null !== suspenseConfig && - expirationTime < workInProgressRootLatestSuspenseTimeout && - 2 < expirationTime && - ((workInProgressRootLatestSuspenseTimeout = expirationTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); -} -function markUnprocessedUpdateTime(expirationTime) { - expirationTime > workInProgressRootNextUnprocessedUpdateTime && - (workInProgressRootNextUnprocessedUpdateTime = expirationTime); -} -function renderRootSync(root, expirationTime) { +function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= RenderContext; + executionContext |= 16; var prevDispatcher = pushDispatcher(); - (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || - prepareFreshStack(root, expirationTime); + (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) || + prepareFreshStack(root, lanes); do try { workLoopSync(); @@ -6245,142 +6515,144 @@ function renderRootSync(root, expirationTime) { while (1); resetContextDependencies(); executionContext = prevExecutionContext; - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher$2.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; + workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) - workInProgress = performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) performUnitOfWork(workInProgress); } function workLoopConcurrent() { - for (; null !== workInProgress && !shouldYield(); ) - workInProgress = performUnitOfWork(workInProgress); + for (; null !== workInProgress && !Scheduler_shouldYield(); ) + performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { - var next = beginWork$1( - unitOfWork.alternate, - unitOfWork, - renderExpirationTime$1 - ); + var next = beginWork$1(unitOfWork.alternate, unitOfWork, subtreeRenderLanes); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === next && (next = completeUnitOfWork(unitOfWork)); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); ReactCurrentOwner$2.current = null; - return next; } function completeUnitOfWork(unitOfWork) { - workInProgress = unitOfWork; + var completedWork = unitOfWork; do { - var current = workInProgress.alternate; - unitOfWork = workInProgress.return; - if (0 === (workInProgress.effectTag & 2048)) { - current = completeWork(current, workInProgress, renderExpirationTime$1); + var current = completedWork.alternate; + unitOfWork = completedWork.return; + if (0 === (completedWork.flags & 4096)) { + current = completeWork(current, completedWork, subtreeRenderLanes); + if (null !== current) { + workInProgress = current; + return; + } + current = completedWork; if ( - 1 === renderExpirationTime$1 || - 1 !== workInProgress.childExpirationTime + (24 !== current.tag && 23 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) ) { - for ( - var newChildExpirationTime = 0, _child = workInProgress.child; - null !== _child; - - ) { - var _childUpdateExpirationTime = _child.expirationTime, - _childChildExpirationTime = _child.childExpirationTime; - _childUpdateExpirationTime > newChildExpirationTime && - (newChildExpirationTime = _childUpdateExpirationTime); - _childChildExpirationTime > newChildExpirationTime && - (newChildExpirationTime = _childChildExpirationTime); - _child = _child.sibling; - } - workInProgress.childExpirationTime = newChildExpirationTime; + for (var newChildLanes = 0, child = current.child; null !== child; ) + (newChildLanes |= child.lanes | child.childLanes), + (child = child.sibling); + current.childLanes = newChildLanes; } - if (null !== current) return current; null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = workInProgress.firstEffect), - null !== workInProgress.lastEffect && + (unitOfWork.firstEffect = completedWork.firstEffect), + null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), - (unitOfWork.lastEffect = workInProgress.lastEffect)), - 1 < workInProgress.effectTag && + (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), + (unitOfWork.lastEffect = completedWork.lastEffect)), + 1 < completedWork.flags && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = workInProgress) - : (unitOfWork.firstEffect = workInProgress), - (unitOfWork.lastEffect = workInProgress))); + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { - current = unwindWork(workInProgress); - if (null !== current) return (current.effectTag &= 2047), current; + current = unwindWork(completedWork); + if (null !== current) { + current.flags &= 4095; + workInProgress = current; + return; + } null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } - current = workInProgress.sibling; - if (null !== current) return current; - workInProgress = unitOfWork; - } while (null !== workInProgress); - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootCompleted); - return null; -} -function getRemainingExpirationTime(fiber) { - var updateExpirationTime = fiber.expirationTime; - fiber = fiber.childExpirationTime; - return updateExpirationTime > fiber ? updateExpirationTime : fiber; + completedWork = completedWork.sibling; + if (null !== completedWork) { + workInProgress = completedWork; + return; + } + workInProgress = completedWork = unitOfWork; + } while (null !== completedWork); + 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { +function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - var finishedWork = root$jscomp$0.finishedWork, - expirationTime = root$jscomp$0.finishedExpirationTime; + var finishedWork = root.finishedWork; if (null === finishedWork) return null; - root$jscomp$0.finishedWork = null; - root$jscomp$0.finishedExpirationTime = 0; - if (finishedWork === root$jscomp$0.current) + root.finishedWork = null; + root.finishedLanes = 0; + if (finishedWork === root.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root$jscomp$0.callbackNode = null; - root$jscomp$0.callbackExpirationTime = 0; - root$jscomp$0.callbackPriority = 90; - root$jscomp$0.nextKnownPendingLevel = 0; - var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( - finishedWork - ); - root$jscomp$0.firstPendingTime = remainingExpirationTimeBeforeCommit; - expirationTime <= root$jscomp$0.lastSuspendedTime - ? (root$jscomp$0.firstSuspendedTime = root$jscomp$0.lastSuspendedTime = root$jscomp$0.nextKnownPendingLevel = 0) - : expirationTime <= root$jscomp$0.firstSuspendedTime && - (root$jscomp$0.firstSuspendedTime = expirationTime - 1); - expirationTime <= root$jscomp$0.lastPingedTime && - (root$jscomp$0.lastPingedTime = 0); - expirationTime <= root$jscomp$0.lastExpiredTime && - (root$jscomp$0.lastExpiredTime = 0); - root$jscomp$0 === workInProgressRoot && + root.callbackNode = null; + var remainingLanes = finishedWork.lanes | finishedWork.childLanes, + remainingLanes$jscomp$0 = remainingLanes, + noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; + root.pendingLanes = remainingLanes$jscomp$0; + root.suspendedLanes = 0; + root.pingedLanes = 0; + root.expiredLanes &= remainingLanes$jscomp$0; + root.mutableReadLanes &= remainingLanes$jscomp$0; + root.entangledLanes &= remainingLanes$jscomp$0; + remainingLanes$jscomp$0 = root.entanglements; + for ( + var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; + 0 < noLongerPendingLanes; + + ) { + var index$12 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$12; + remainingLanes$jscomp$0[index$12] = 0; + eventTimes[index$12] = -1; + expirationTimes[index$12] = -1; + noLongerPendingLanes &= ~lane; + } + null !== rootsWithPendingDiscreteUpdates && + 0 === (remainingLanes & 24) && + rootsWithPendingDiscreteUpdates.has(root) && + rootsWithPendingDiscreteUpdates.delete(root); + root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (renderExpirationTime$1 = 0)); - 1 < finishedWork.effectTag + (workInProgressRootRenderLanes = 0)); + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (remainingExpirationTimeBeforeCommit = finishedWork) - : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); - if (null !== remainingExpirationTimeBeforeCommit) { - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - ReactCurrentOwner$2.current = null; - nextEffect = remainingExpirationTimeBeforeCommit; + (remainingLanes = finishedWork.firstEffect)) + : (remainingLanes = finishedWork) + : (remainingLanes = finishedWork.firstEffect); + if (null !== remainingLanes) { + remainingLanes$jscomp$0 = executionContext; + executionContext |= 32; + focusedInstanceHandle = ReactCurrentOwner$2.current = null; + shouldFireAfterActiveInstanceBlur = !1; + nextEffect = remainingLanes; do try { commitBeforeMutationEffects(); @@ -6390,17 +6662,13 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - nextEffect = remainingExpirationTimeBeforeCommit; + focusedInstanceHandle = null; + nextEffect = remainingLanes; do try { - for ( - var root = root$jscomp$0, - renderPriorityLevel = renderPriorityLevel$jscomp$0; - null !== nextEffect; - - ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + for (eventTimes = root; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6410,52 +6678,50 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: commitWork(nextEffect.alternate, nextEffect); break; case 8: - var current$jscomp$0 = nextEffect; - unmountHostComponents( - root, - current$jscomp$0, - renderPriorityLevel - ); - detachFiber(current$jscomp$0); + expirationTimes = nextEffect; + unmountHostComponents(eventTimes, expirationTimes); + var alternate = expirationTimes.alternate; + detachFiberMutation(expirationTimes); + null !== alternate && detachFiberMutation(alternate); } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$88) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$88); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root$jscomp$0.current = finishedWork; - nextEffect = remainingExpirationTimeBeforeCommit; + root.current = finishedWork; + nextEffect = remainingLanes; do try { - for (effectTag = root$jscomp$0; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { @@ -6474,55 +6740,71 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$89) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$89); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - executionContext = prevExecutionContext; - } else root$jscomp$0.current = finishedWork; + executionContext = remainingLanes$jscomp$0; + } else root.current = finishedWork; if (rootDoesHavePassiveEffects) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root$jscomp$0), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$0); + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel); else - for ( - nextEffect = remainingExpirationTimeBeforeCommit; - null !== nextEffect; - - ) - (renderPriorityLevel$jscomp$0 = nextEffect.nextEffect), + for (nextEffect = remainingLanes; null !== nextEffect; ) + (renderPriorityLevel = nextEffect.nextEffect), (nextEffect.nextEffect = null), - (nextEffect = renderPriorityLevel$jscomp$0); - renderPriorityLevel$jscomp$0 = root$jscomp$0.firstPendingTime; - 0 === renderPriorityLevel$jscomp$0 && - (legacyErrorBoundariesThatAlreadyFailed = null); - 1073741823 === renderPriorityLevel$jscomp$0 - ? root$jscomp$0 === rootWithNestedUpdates + nextEffect.flags & 8 && + ((flags$jscomp$0 = nextEffect), + (flags$jscomp$0.sibling = null), + (flags$jscomp$0.stateNode = null)), + (nextEffect = renderPriorityLevel); + remainingLanes = root.pendingLanes; + 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); + 1 === remainingLanes + ? root === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$0)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode, expirationTime); - ensureRootIsScheduled(root$jscomp$0); + finishedWork = finishedWork.stateNode; + if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) + try { + injectedHook.onCommitFiberRoot( + rendererID, + finishedWork, + void 0, + 64 === (finishedWork.current.flags & 64) + ); + } catch (err) {} + ensureRootIsScheduled(root, now()); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root$jscomp$0 = firstUncaughtError), + (root = firstUncaughtError), (firstUncaughtError = null), - root$jscomp$0); - if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; + root); + if (0 !== (executionContext & 8)) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); - 0 === (effectTag & 512) || + var current = nextEffect.alternate; + shouldFireAfterActiveInstanceBlur || + null === focusedInstanceHandle || + (0 !== (nextEffect.flags & 8) + ? doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0) + : 13 === nextEffect.tag && + isSuspenseBoundaryBeingHidden(current, nextEffect) && + doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0)); + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -6541,45 +6823,81 @@ function flushPassiveEffects() { pendingPassiveEffectsRenderPriority = 90; return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } + return !1; +} +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= CommitContext; - for (root = root.current.firstEffect; null !== root; ) { + executionContext |= 32; + var unmountEffects = pendingPassiveHookEffectsUnmount; + pendingPassiveHookEffectsUnmount = []; + for (var i = 0; i < unmountEffects.length; i += 2) { + var effect$94 = unmountEffects[i], + fiber = unmountEffects[i + 1], + destroy = effect$94.destroy; + effect$94.destroy = void 0; + if ("function" === typeof destroy) + try { + destroy(); + } catch (error) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error); + } + } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$94 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; try { - var finishedWork = root; - if (0 !== (finishedWork.effectTag & 512)) - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - case 22: - commitHookEffectListUnmount(5, finishedWork), - commitHookEffectListMount(5, finishedWork); - } - } catch (error) { - if (null === root) throw Error("Should be working on an effect."); - captureCommitPhaseError(root, error); + var create$98 = effect$94.create; + effect$94.destroy = create$98(); + } catch (error$99) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error$99); } - finishedWork = root.nextEffect; - root.nextEffect = null; - root = finishedWork; } + for (create$98 = root.current.firstEffect; null !== create$98; ) + (root = create$98.nextEffect), + (create$98.nextEffect = null), + create$98.flags & 8 && + ((create$98.sibling = null), (create$98.stateNode = null)), + (create$98 = root); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); enqueueUpdate(rootFiber, sourceFiber); - rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); - null !== rootFiber && ensureRootIsScheduled(rootFiber); + sourceFiber = requestEventTime(); + rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); + null !== rootFiber && + (markRootUpdated(rootFiber, 1, sourceFiber), + ensureRootIsScheduled(rootFiber, sourceFiber)); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -6598,145 +6916,166 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); - null !== fiber && ensureRootIsScheduled(fiber); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); + fiber = markUpdateLaneFromFiberToRoot(fiber, 1); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, thenable, suspendedTime) { +function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - workInProgressRoot === root && renderExpirationTime$1 === suspendedTime - ? workInProgressRootExitStatus === RootSuspendedWithDelay || - (workInProgressRootExitStatus === RootSuspended && - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) - ? prepareFreshStack(root, renderExpirationTime$1) - : (workInProgressRootHasPendingPing = !0) - : isRootSuspendedAtTime(root, suspendedTime) && - ((thenable = root.lastPingedTime), - (0 !== thenable && thenable < suspendedTime) || - ((root.lastPingedTime = suspendedTime), ensureRootIsScheduled(root))); -} -function resolveRetryThenable(boundaryFiber, thenable) { + null !== pingCache && pingCache.delete(wakeable); + wakeable = requestEventTime(); + root.pingedLanes |= root.suspendedLanes & pingedLanes; + workInProgressRoot === root && + (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && + (4 === workInProgressRootExitStatus || + (3 === workInProgressRootExitStatus && + (workInProgressRootRenderLanes & 62914560) === + workInProgressRootRenderLanes && + 500 > now() - globalMostRecentFallbackTime) + ? prepareFreshStack(root, 0) + : (workInProgressRootPingedLanes |= pingedLanes)); + ensureRootIsScheduled(root, wakeable); +} +function resolveRetryWakeable(boundaryFiber, wakeable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(thenable); - thenable = 0; - 0 === thenable && - ((thenable = requestCurrentTimeForUpdate()), - (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); - boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); - null !== boundaryFiber && ensureRootIsScheduled(boundaryFiber); + null !== retryCache && retryCache.delete(wakeable); + wakeable = 0; + 0 === wakeable && + ((wakeable = boundaryFiber.mode), + 0 === (wakeable & 2) + ? (wakeable = 1) + : 0 === (wakeable & 4) + ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); + retryCache = requestEventTime(); + boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); + null !== boundaryFiber && + (markRootUpdated(boundaryFiber, wakeable, retryCache), + ensureRootIsScheduled(boundaryFiber, retryCache)); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; +beginWork$1 = function(current, workInProgress, renderLanes) { + var updateLanes = workInProgress.lanes; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (updateExpirationTime < renderExpirationTime) { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case 10: + updateLanes = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue); + context._currentValue = updateLanes; + break; + case 13: + if (null !== workInProgress.memoizedState) { + if (0 !== (renderLanes & workInProgress.child.childLanes)) + return updateSuspenseComponent( + current, + workInProgress, + renderLanes + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( + current, workInProgress, - workInProgress.stateNode.containerInfo + renderLanes ); - break; - case 10: - updateExpirationTime = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue); - context._currentValue = updateExpirationTime; - break; - case 13: - if (null !== workInProgress.memoizedState) { - updateExpirationTime = workInProgress.child.childExpirationTime; - if ( - 0 !== updateExpirationTime && - updateExpirationTime >= renderExpirationTime - ) - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateLanes = 0 !== (renderLanes & workInProgress.childLanes); + if (0 !== (current.flags & 64)) { + if (updateLanes) + return updateSuspenseListComponent( current, workInProgress, - renderExpirationTime + renderLanes ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateExpirationTime = - workInProgress.childExpirationTime >= renderExpirationTime; - if (0 !== (current.effectTag & 64)) { - if (updateExpirationTime) - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), (context.tail = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (!updateExpirationTime) return null; - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + workInProgress.flags |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), + (context.tail = null), + (context.lastEffect = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (updateLanes) break; + else return null; + case 23: + case 24: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; - workInProgress.expirationTime = 0; + workInProgress.lanes = 0; switch (workInProgress.tag) { case 2: - updateExpirationTime = workInProgress.type; + updateLanes = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); context = renderWithHooks( null, workInProgress, - updateExpirationTime, + updateLanes, current, context, - renderExpirationTime + renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -6746,7 +7085,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateExpirationTime)) { + if (isContextProvider(updateLanes)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -6755,53 +7094,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = - updateExpirationTime.getDerivedStateFromProps; + var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateExpirationTime, + updateLanes, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternalFiber = workInProgress; - mountClassInstance( - workInProgress, - updateExpirationTime, - current, - renderExpirationTime - ); + context._reactInternals = workInProgress; + mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, hasContext, - renderExpirationTime + renderLanes ); } else (workInProgress.tag = 0), - reconcileChildren( - null, - workInProgress, - context, - renderExpirationTime - ), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: + context = workInProgress.elementType; a: { - context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - initializeLazyComponentType(context); - if (1 !== context._status) throw context._result; - context = context._result; + hasContext = context._init; + context = hasContext(context._payload); workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -6812,7 +7139,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 1: @@ -6821,7 +7148,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 11: @@ -6830,7 +7157,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 14: @@ -6839,8 +7166,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, resolveDefaultProps(context.type, current), - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); break a; } @@ -6853,126 +7180,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return workInProgress; case 0: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 1: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 3: pushHostRootContext(workInProgress); - updateExpirationTime = workInProgress.updateQueue; - if (null === current || null === updateExpirationTime) + updateLanes = workInProgress.updateQueue; + if (null === current || null === updateLanes) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); - updateExpirationTime = workInProgress.pendingProps; + updateLanes = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue( - workInProgress, - updateExpirationTime, - null, - renderExpirationTime - ); - updateExpirationTime = workInProgress.memoizedState.element; - updateExpirationTime === context + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes )) - : (reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (updateLanes = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child), - workInProgress + reconcileChildren(current, workInProgress, updateLanes, renderLanes), + workInProgress.child ); case 6: return null; case 13: - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseComponent(current, workInProgress, renderLanes); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (updateLanes = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes )) : reconcileChildren( current, workInProgress, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ), workInProgress.child ); case 11: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 7: @@ -6981,7 +7288,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps, - renderExpirationTime + renderLanes ), workInProgress.child ); @@ -6991,7 +7298,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); @@ -7001,13 +7308,13 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); case 10: a: { - updateExpirationTime = workInProgress.type._context; + updateLanes = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -7019,9 +7326,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( context$jscomp$0, hasContext ) @@ -7035,7 +7341,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); break a; } @@ -7056,25 +7362,24 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ) { if ( - dependency.context === updateExpirationTime && + dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate(renderExpirationTime, null)), + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.expirationTime < renderExpirationTime && - (context$jscomp$0.expirationTime = renderExpirationTime); + context$jscomp$0.lanes |= renderLanes; dependency = context$jscomp$0.alternate; - null !== dependency && - dependency.expirationTime < renderExpirationTime && - (dependency.expirationTime = renderExpirationTime); + null !== dependency && (dependency.lanes |= renderLanes); scheduleWorkOnParentPath( context$jscomp$0.return, - renderExpirationTime + renderLanes ); - list.expirationTime < renderExpirationTime && - (list.expirationTime = renderExpirationTime); + list.lanes |= renderLanes; break; } dependency = dependency.next; @@ -7112,7 +7417,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, context.children, - renderExpirationTime + renderLanes ); workInProgress = workInProgress.child; } @@ -7121,17 +7426,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateExpirationTime = hasContext.children), - prepareToReadContext(workInProgress, renderExpirationTime), + (updateLanes = hasContext.children), + prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(context)), - (workInProgress.effectTag |= 1), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + (updateLanes = updateLanes(context)), + (workInProgress.flags |= 1), + reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: @@ -7147,8 +7447,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, hasContext, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); case 15: @@ -7157,48 +7457,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); case 17: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), - isContextProvider(updateExpirationTime) + isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderExpirationTime), - constructClassInstance(workInProgress, updateExpirationTime, context), - mountClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), + prepareToReadContext(workInProgress, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, current, - renderExpirationTime + renderLanes ) ); case 19: - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseListComponent(current, workInProgress, renderLanes); + case 23: + return updateOffscreenComponent(current, workInProgress, renderLanes); + case 24: + return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( "Unknown unit of work tag (" + @@ -7206,32 +7501,6 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { "). This error is likely caused by a bug in React. Please file an issue." ); }; -var onCommitFiberRoot = null, - onCommitFiberUnmount = null; -function injectInternals(internals) { - if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (hook.isDisabled || !hook.supportsFiber) return !0; - try { - var rendererID = hook.inject(internals); - onCommitFiberRoot = function(root) { - try { - hook.onCommitFiberRoot( - rendererID, - root, - void 0, - 64 === (root.current.effectTag & 64) - ); - } catch (err) {} - }; - onCommitFiberUnmount = function(fiber) { - try { - hook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) {} - }; - } catch (err) {} - return !0; -} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7241,11 +7510,14 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childExpirationTime = this.expirationTime = 0; + this.childLanes = this.lanes = 0; this.alternate = null; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); @@ -7263,7 +7535,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, @@ -7275,12 +7547,13 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.effectTag = 0), + (workInProgress.type = current.type), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7289,11 +7562,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.dependencies = null === pendingProps ? null - : { - expirationTime: pendingProps.expirationTime, - firstContext: pendingProps.firstContext, - responders: pendingProps.responders - }; + : { lanes: pendingProps.lanes, firstContext: pendingProps.firstContext }; workInProgress.sibling = current.sibling; workInProgress.index = current.index; workInProgress.ref = current.ref; @@ -7305,7 +7574,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - expirationTime + lanes ) { var fiberTag = 2; owner = type; @@ -7314,15 +7583,10 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment( - pendingProps.children, - mode, - expirationTime, - key - ); - case REACT_CONCURRENT_MODE_TYPE: + return createFiberFromFragment(pendingProps.children, mode, lanes, key); + case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 7; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7330,25 +7594,34 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(12, pendingProps, key, mode | 8)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), type ); case REACT_SUSPENSE_TYPE: return ( - (type = new FiberNode(13, pendingProps, key, mode)), + (type = createFiber(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = new FiberNode(19, pendingProps, key, mode)), + (type = createFiber(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), + type + ); + case REACT_OFFSCREEN_TYPE: + return createFiberFromOffscreen(pendingProps, mode, lanes, key); + case REACT_LEGACY_HIDDEN_TYPE: + return ( + (type = createFiber(24, pendingProps, key, mode)), + (type.elementType = REACT_LEGACY_HIDDEN_TYPE), + (type.lanes = lanes), type ); default: @@ -7380,30 +7653,36 @@ function createFiberFromTypeAndProps( "." ); } - key = new FiberNode(fiberTag, pendingProps, key, mode); + key = createFiber(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.expirationTime = expirationTime; + key.lanes = lanes; return key; } -function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(7, elements, key, mode); - elements.expirationTime = expirationTime; +function createFiberFromFragment(elements, mode, lanes, key) { + elements = createFiber(7, elements, key, mode); + elements.lanes = lanes; return elements; } -function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); - content.expirationTime = expirationTime; +function createFiberFromOffscreen(pendingProps, mode, lanes, key) { + pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps.elementType = REACT_OFFSCREEN_TYPE; + pendingProps.lanes = lanes; + return pendingProps; +} +function createFiberFromText(content, mode, lanes) { + content = createFiber(6, content, null, mode); + content.lanes = lanes; return content; } -function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( +function createFiberFromPortal(portal, mode, lanes) { + mode = createFiber( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.expirationTime = expirationTime; + mode.lanes = lanes; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -7413,51 +7692,31 @@ function createFiberFromPortal(portal, mode, expirationTime) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; - this.current = null; this.containerInfo = containerInfo; - this.pingCache = this.pendingChildren = null; - this.finishedExpirationTime = 0; - this.finishedWork = null; + this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 90; - this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; -} -function isRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - root = root.lastSuspendedTime; - return ( - 0 !== firstSuspendedTime && - firstSuspendedTime >= expirationTime && - root <= expirationTime - ); + this.callbackPriority = 0; + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); + this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; + this.entanglements = createLaneMap(0); } -function markRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime, - lastSuspendedTime = root.lastSuspendedTime; - firstSuspendedTime < expirationTime && - (root.firstSuspendedTime = expirationTime); - if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) - root.lastSuspendedTime = expirationTime; - expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); - expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); -} -function markRootUpdatedAtTime(root, expirationTime) { - expirationTime > root.firstPendingTime && - (root.firstPendingTime = expirationTime); - var firstSuspendedTime = root.firstSuspendedTime; - 0 !== firstSuspendedTime && - (expirationTime >= firstSuspendedTime - ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) - : expirationTime >= root.lastSuspendedTime && - (root.lastSuspendedTime = expirationTime + 1), - expirationTime > root.nextKnownPendingLevel && - (root.nextKnownPendingLevel = expirationTime)); +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findHostInstance(component) { - var fiber = component._reactInternalFiber; + var fiber = component._reactInternals; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -7471,11 +7730,10 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); + eventTime = requestEventTime(), + lane = requestUpdateLane(current); a: if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; + parentComponent = parentComponent._reactInternals; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -7484,22 +7742,23 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var parentContext = parentComponent; + var JSCompiler_inline_result = parentComponent; do { - switch (parentContext.tag) { + switch (JSCompiler_inline_result.tag) { case 3: - parentContext = parentContext.stateNode.context; + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode.context; break b; case 1: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode + if (isContextProvider(JSCompiler_inline_result.type)) { + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - parentContext = parentContext.return; - } while (null !== parentContext); + JSCompiler_inline_result = JSCompiler_inline_result.return; + } while (null !== JSCompiler_inline_result); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -7510,34 +7769,26 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - parentContext + JSCompiler_inline_result ); break a; } } - parentComponent = parentContext; + parentComponent = JSCompiler_inline_result; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(currentTime, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleWork(current, currentTime); - return currentTime; + scheduleUpdateOnFiber(current, lane, eventTime); + return lane; } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function emptyFindFiberByHostInstance() { + return null; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7566,53 +7817,70 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - executionContext === NoContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; -var roots = new Map(); -(function(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals({ - bundleType: devToolsConfig.bundleType, - version: devToolsConfig.version, - rendererPackageName: devToolsConfig.rendererPackageName, - rendererConfig: devToolsConfig.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; - }, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null - }); -})({ - findFiberByHostInstance: getInstanceFromTag, - bundleType: 0, - version: "16.13.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } -}); +var roots = new Map(), + devToolsConfig$jscomp$inline_908 = { + findFiberByHostInstance: getInstanceFromTag, + bundleType: 0, + version: "17.0.1-4e5d7faf5", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } + }; +var internals$jscomp$inline_1115 = { + bundleType: devToolsConfig$jscomp$inline_908.bundleType, + version: devToolsConfig$jscomp$inline_908.version, + rendererPackageName: devToolsConfig$jscomp$inline_908.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_908.rendererConfig, + overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, + overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: + devToolsConfig$jscomp$inline_908.findFiberByHostInstance || + emptyFindFiberByHostInstance, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null +}; +if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { + var hook$jscomp$inline_1116 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if ( + !hook$jscomp$inline_1116.isDisabled && + hook$jscomp$inline_1116.supportsFiber + ) + try { + (rendererID = hook$jscomp$inline_1116.inject( + internals$jscomp$inline_1115 + )), + (injectedHook = hook$jscomp$inline_1116); + } catch (err) {} +} exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function(reactTag) { return (reactTag = getInstanceFromTag(reactTag)) @@ -7659,7 +7927,7 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var uninitializedFiber = new FiberNode(3, null, null, 0); + var uninitializedFiber = createFiber(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; initializeUpdateQueue(uninitializedFiber); diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 315906ade58741..9beda430185462 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -920,7 +920,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_232 = { +var injectedNamesToPlugins$jscomp$inline_226 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -955,34 +955,34 @@ var injectedNamesToPlugins$jscomp$inline_232 = { } } }, - isOrderingDirty$jscomp$inline_233 = !1, - pluginName$jscomp$inline_234; -for (pluginName$jscomp$inline_234 in injectedNamesToPlugins$jscomp$inline_232) + isOrderingDirty$jscomp$inline_227 = !1, + pluginName$jscomp$inline_228; +for (pluginName$jscomp$inline_228 in injectedNamesToPlugins$jscomp$inline_226) if ( - injectedNamesToPlugins$jscomp$inline_232.hasOwnProperty( - pluginName$jscomp$inline_234 + injectedNamesToPlugins$jscomp$inline_226.hasOwnProperty( + pluginName$jscomp$inline_228 ) ) { - var pluginModule$jscomp$inline_235 = - injectedNamesToPlugins$jscomp$inline_232[pluginName$jscomp$inline_234]; + var pluginModule$jscomp$inline_229 = + injectedNamesToPlugins$jscomp$inline_226[pluginName$jscomp$inline_228]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_234) || - namesToPlugins[pluginName$jscomp$inline_234] !== - pluginModule$jscomp$inline_235 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_228) || + namesToPlugins[pluginName$jscomp$inline_228] !== + pluginModule$jscomp$inline_229 ) { - if (namesToPlugins[pluginName$jscomp$inline_234]) + if (namesToPlugins[pluginName$jscomp$inline_228]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_234 + + pluginName$jscomp$inline_228 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_234 - ] = pluginModule$jscomp$inline_235; - isOrderingDirty$jscomp$inline_233 = !0; + pluginName$jscomp$inline_228 + ] = pluginModule$jscomp$inline_229; + isOrderingDirty$jscomp$inline_227 = !0; } } -isOrderingDirty$jscomp$inline_233 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_227 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1222,7 +1222,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1739,7 +1739,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1779,31 +1779,27 @@ if ( null == tracing.__interactionsRef.current ) throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); Scheduler_now(); -var return_highestLanePriority = 10; +var return_highestLanePriority = 8; function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; if (0 !== inputDiscreteLanes) return (return_highestLanePriority = 6), inputDiscreteLanes; inputDiscreteLanes = 62914560 & lanes; @@ -1817,18 +1813,18 @@ function getHighestPriorityLanes(lanes) { return (return_highestLanePriority = 2), inputDiscreteLanes; if (0 !== (1073741824 & lanes)) return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; + return_highestLanePriority = 8; return lanes; } function schedulerPriorityToLanePriority(schedulerPriorityLevel) { switch (schedulerPriorityLevel) { case 99: - return 17; + return 15; case 98: - return 12; + return 10; case 97: case 96: - return 10; + return 8; case 95: return 2; default: @@ -1837,16 +1833,14 @@ function schedulerPriorityToLanePriority(schedulerPriorityLevel) { } function lanePriorityToSchedulerPriority(lanePriority) { switch (lanePriority) { - case 17: - case 16: - return 99; case 15: case 14: + return 99; case 13: case 12: - return 98; case 11: case 10: + return 98; case 9: case 8: case 7: @@ -1876,7 +1870,7 @@ function getNextLanes(root, wipLanes) { pingedLanes = root.pingedLanes; if (0 !== expiredLanes) (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); + (nextLanePriority = return_highestLanePriority = 15); else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; 0 !== nonIdleUnblockedLanes @@ -1915,42 +1909,31 @@ function getNextLanes(root, wipLanes) { (wipLanes &= ~nextLanePriority); return nextLanes; } -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6; - index$6 = root[index$6]; - index$6 > mostRecentEventTime && (mostRecentEventTime = index$6); - lanes &= ~lane; - } - return mostRecentEventTime; -} function getLanesToRetrySynchronouslyOnError(root) { root = root.pendingLanes & -1073741825; return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; } function findUpdateLane(lanePriority, wipLanes) { switch (lanePriority) { - case 17: + case 15: return 1; - case 16: - return 2; case 14: + return 2; + case 12: return ( (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority ); - case 12: + case 10: return ( (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority ); - case 10: + case 8: return ( (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), 0 === lanePriority && (lanePriority = 512)), lanePriority ); @@ -1968,8 +1951,9 @@ function findUpdateLane(lanePriority, wipLanes) { function getHighestPriorityLane(lanes) { return lanes & -lanes; } -function pickArbitraryLane(lanes) { - return lanes & -lanes; +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; } function markRootUpdated(root, updateLane, eventTime) { root.pendingLanes |= updateLane; @@ -2004,7 +1988,7 @@ if ( null == tracing.__interactionsRef.current ) throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); var fakeCallbackNode = {}, requestPaint = @@ -2093,6 +2077,32 @@ function flushSyncCallbackQueueImpl() { } } } +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; +function is(x, y) { + return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); +} +var objectIs = "function" === typeof Object.is ? Object.is : is, + hasOwnProperty = Object.prototype.hasOwnProperty; +function shallowEqual(objA, objB) { + if (objectIs(objA, objB)) return !0; + if ( + "object" !== typeof objA || + null === objA || + "object" !== typeof objB || + null === objB + ) + return !1; + var keysA = Object.keys(objA), + keysB = Object.keys(objB); + if (keysA.length !== keysB.length) return !1; + for (keysB = 0; keysB < keysA.length; keysB++) + if ( + !hasOwnProperty.call(objB, keysA[keysB]) || + !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) + ) + return !1; + return !0; +} function describeFiber(fiber) { switch (fiber.tag) { case 5: @@ -2129,31 +2139,6 @@ function getStackByFiberInDevAndProd(workInProgress) { return "\nError generating stack: " + x.message + "\n" + x.stack; } } -function is(x, y) { - return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); -} -var objectIs = "function" === typeof Object.is ? Object.is : is, - hasOwnProperty = Object.prototype.hasOwnProperty; -function shallowEqual(objA, objB) { - if (objectIs(objA, objB)) return !0; - if ( - "object" !== typeof objA || - null === objA || - "object" !== typeof objB || - null === objB - ) - return !1; - var keysA = Object.keys(objA), - keysB = Object.keys(objB); - if (keysA.length !== keysB.length) return !1; - for (keysB = 0; keysB < keysA.length; keysB++) - if ( - !hasOwnProperty.call(objB, keysA[keysB]) || - !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) - ) - return !1; - return !0; -} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2247,11 +2232,10 @@ function cloneUpdateQueue(current, workInProgress) { effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(eventTime, lane) { return { eventTime: eventTime, lane: lane, - suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, @@ -2284,7 +2268,6 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { var clone = { eventTime: queue.eventTime, lane: queue.lane, - suspenseConfig: queue.suspenseConfig, tag: queue.tag, payload: queue.payload, callback: queue.callback, @@ -2358,16 +2341,11 @@ function processUpdateQueue( (current = current.next = { eventTime: updateEventTime, lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, next: null }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); a: { var workInProgress = workInProgress$jscomp$0, update = firstBaseUpdate; @@ -2387,8 +2365,7 @@ function processUpdateQueue( currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; pendingQueue = @@ -2411,7 +2388,7 @@ function processUpdateQueue( } } null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), + ((workInProgress$jscomp$0.flags |= 32), (pendingQueue = queue.effects), null === pendingQueue ? (queue.effects = [firstBaseUpdate]) @@ -2420,7 +2397,6 @@ function processUpdateQueue( (updateEventTime = { eventTime: updateEventTime, lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, tag: firstBaseUpdate.tag, payload: firstBaseUpdate.payload, callback: firstBaseUpdate.callback, @@ -2472,8 +2448,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2499,41 +2474,32 @@ var classComponentUpdater = { enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); scheduleUpdateOnFiber(inst, lane, eventTime); } }; @@ -2626,7 +2592,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2641,7 +2607,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2675,7 +2641,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2699,7 +2665,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2731,16 +2697,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -3274,12 +3240,14 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3339,7 +3307,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim() || shim())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3371,7 +3339,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3496,40 +3464,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3614,10 +3576,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), + (maybeNewVersion = requestUpdateLane(fiber)), (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); maybeNewVersion = root.mutableReadLanes; root.entangledLanes |= maybeNewVersion; @@ -3626,9 +3585,9 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { 0 < lanes; ) { - var index$14 = 31 - clz32(lanes), - lane = 1 << index$14; - entanglements[index$14] |= maybeNewVersion; + var index$13 = 31 - clz32(lanes), + lane = 1 << index$13; + entanglements[index$13] |= maybeNewVersion; lanes &= ~lane; } } @@ -3642,7 +3601,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { latestSetSnapshot = refs.setSnapshot; try { latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); + var lane = requestUpdateLane(fiber); root.mutableReadLanes |= lane & root.pendingLanes; } catch (error) { latestSetSnapshot(function() { @@ -3713,17 +3672,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3731,12 +3690,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3775,13 +3734,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3809,39 +3761,36 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); - suspenseConfig = { - eventTime: eventTime, - lane: lane, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3857,8 +3806,8 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { @@ -3886,7 +3835,13 @@ var ContextOnlyDispatcher = { }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3932,36 +3887,30 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; }, useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); @@ -3991,36 +3940,27 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -4042,36 +3982,27 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; }, useMutableSource: updateMutableSource, useOpaqueIdentifier: function() { @@ -4128,11 +4059,11 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } @@ -4169,7 +4100,7 @@ function updateMemoComponent( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, renderLanes ); @@ -4186,7 +4117,7 @@ function updateMemoComponent( Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4206,7 +4137,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -4241,9 +4172,7 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { return ( (current = null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [1073741824]) - : spawnedWorkDuringRender.push(1073741824), + markSpawnedWork(1073741824), (workInProgress.lanes = workInProgress.childLanes = 1073741824), (workInProgress.memoizedState = { baseLanes: current }), pushRenderLanes(workInProgress, current), @@ -4264,7 +4193,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4289,11 +4218,11 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } @@ -4313,7 +4242,7 @@ function updateClassComponent( null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); @@ -4379,9 +4308,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -4389,7 +4318,7 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); } else { instance = workInProgress.stateNode; @@ -4462,17 +4391,17 @@ function updateClassComponent( oldContext )), "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4482,11 +4411,11 @@ function updateClassComponent( : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4507,7 +4436,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4522,7 +4451,7 @@ function finishClassComponent( var nextChildren = null; profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((didCaptureError = nextChildren), (workInProgress.child = reconcileChildFibers( @@ -4560,55 +4489,49 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { + current = nextProps.children; + suspenseContext = nextProps.fallback; if (showFallback) return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps), - workInProgress.mode & 8 && - ((showFallback.actualDuration = 0), - (showFallback.actualStartTime = -1), - (showFallback.selfBaseDuration = 0), - (showFallback.treeBaseDuration = 0))) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( + (current = mountSuspenseFallbackChildren( + workInProgress, current, suspenseContext, - renderLanes, - null + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + current + ); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432), current ); renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, + { mode: "visible", children: current }, workInProgress.mode, renderLanes, null @@ -4626,13 +4549,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4654,13 +4577,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { nextProps.fallback, renderLanes )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps ); @@ -4673,6 +4596,41 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { workInProgress.memoizedState = null; return renderLanes; } +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren), + workInProgress.mode & 8 && + ((progressedPrimaryFragment.actualDuration = 0), + (progressedPrimaryFragment.actualStartTime = -1), + (progressedPrimaryFragment.selfBaseDuration = 0), + (progressedPrimaryFragment.treeBaseDuration = 0))) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; +} function updateSuspensePrimaryChildren( current, workInProgress, @@ -4690,7 +4648,7 @@ function updateSuspensePrimaryChildren( primaryChildren.sibling = null; null !== current && ((current.nextEffect = null), - (current.effectTag = 8), + (current.flags = 8), (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } @@ -4734,7 +4692,7 @@ function updateSuspenseFallbackChildren( renderLanes, null )), - (fallbackChildren.effectTag |= 2)); + (fallbackChildren.flags |= 2)); fallbackChildren.return = workInProgress; primaryChildren.return = workInProgress; primaryChildren.sibling = fallbackChildren; @@ -4763,7 +4721,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4772,7 +4729,6 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } @@ -4783,9 +4739,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4921,10 +4877,10 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && (requiredContext(contextStackCursor$1.current), (workInProgress.updateQueue = UPDATE_SIGNAL)) && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); }; updateHostText$1 = function(current, workInProgress, oldText, newText) { - oldText !== newText && (workInProgress.effectTag |= 4); + oldText !== newText && (workInProgress.flags |= 4); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4978,7 +4934,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.effectTag |= 256), + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -4996,8 +4952,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -5031,8 +4986,8 @@ function completeWork(current, workInProgress, renderLanes) { appendAllChildren(rootContainerInstance, workInProgress, !1, !1); workInProgress.stateNode = rootContainerInstance; finalizeInitialChildren(rootContainerInstance) && - (workInProgress.effectTag |= 4); - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + (workInProgress.flags |= 4); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -5067,7 +5022,7 @@ function completeWork(current, workInProgress, renderLanes) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) + if (0 !== (workInProgress.flags & 64)) return ( (workInProgress.lanes = renderLanes), 0 !== (workInProgress.mode & 8) && @@ -5100,7 +5055,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; + if (newProps || rootContainerInstance) workInProgress.flags |= 4; return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -5112,24 +5067,24 @@ function completeWork(current, workInProgress, renderLanes) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.effectTag & 64)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; @@ -5137,7 +5092,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (updatePayload = current), - (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), @@ -5185,6 +5140,13 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); } else { if (!rootContainerInstance) @@ -5192,12 +5154,12 @@ function completeWork(current, workInProgress, renderLanes) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -5210,15 +5172,14 @@ function completeWork(current, workInProgress, renderLanes) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [renderLanes]) - : spawnedWorkDuringRender.push(renderLanes)); + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5229,9 +5190,7 @@ function completeWork(current, workInProgress, renderLanes) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -5254,7 +5213,7 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), null ); } @@ -5268,9 +5227,9 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) @@ -5280,21 +5239,21 @@ function unwindWork(workInProgress) { pop(didPerformWorkStackCursor); pop(contextStackCursor); resetWorkInProgressVersions(); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) @@ -5344,7 +5303,7 @@ function logCapturedError(boundary, errorInfo) { } var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; lane.payload = { element: null }; var error = errorInfo.value; @@ -5355,7 +5314,7 @@ function createRootErrorUpdate(fiber, errorInfo, lane) { return lane; } function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); + lane = createUpdate(-1, lane); lane.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { @@ -5401,7 +5360,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -5462,7 +5421,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && + finishedWork.flags & 4 && (null === current ? finishedRoot.componentDidMount() : ((create$82 = @@ -5687,7 +5646,7 @@ function commitPlacement(finishedWork) { "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } - parentFiber.effectTag & 16 && (parentFiber.effectTag &= -17); + parentFiber.flags & 16 && (parentFiber.flags &= -17); a: b: for (parentFiber = finishedWork; ; ) { for (; null === parentFiber.sibling; ) { if (null === parentFiber.return || isHostParent(parentFiber.return)) { @@ -5702,13 +5661,13 @@ function commitPlacement(finishedWork) { 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag; ) { - if (parentFiber.effectTag & 2) continue b; + if (parentFiber.flags & 2) continue b; if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); } - if (!(parentFiber.effectTag & 2)) { + if (!(parentFiber.flags & 2)) { parentFiber = parentFiber.stateNode; break a; } @@ -6031,14 +5990,13 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, - workInProgressRootCanSuspendUsingConfig = null, workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -6065,46 +6023,33 @@ function requestEventTime() { ? currentEventTime : (currentEventTime = now()); } -function requestUpdateLane(fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; if (0 === (fiber & 2)) return 1; if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; 0 === currentEventWipLanes && (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; + if (0 !== ReactCurrentBatchConfig.transition) { 0 !== currentEventPendingLanes && (currentEventPendingLanes = null !== mostRecentlyUpdatedRoot ? mostRecentlyUpdatedRoot.pendingLanes : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (50 < nestedUpdateCount) @@ -6126,7 +6071,9 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber)) : (ensureRootIsScheduled(fiber, eventTime), schedulePendingInteractions(fiber, lane), - 0 === executionContext && flushSyncCallbackQueue()) + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) : (0 === (executionContext & 4) || (98 !== priorityLevel && 99 !== priorityLevel) || (null === rootsWithPendingDiscreteUpdates @@ -6168,8 +6115,8 @@ function ensureRootIsScheduled(root, currentTime) { getHighestPriorityLanes(lane); var priority = return_highestLanePriority; expirationTimes[index$7] = - 12 <= priority - ? expirationTime + 1e3 + 10 <= priority + ? expirationTime + 250 : 6 <= priority ? expirationTime + 5e3 : -1; @@ -6194,7 +6141,7 @@ function ensureRootIsScheduled(root, currentTime) { existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode); } - 17 === currentTime + 15 === currentTime ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), null === syncQueue ? ((syncQueue = [existingCallbackNode]), @@ -6204,7 +6151,7 @@ function ensureRootIsScheduled(root, currentTime) { ))) : syncQueue.push(existingCallbackNode), (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime + : 14 === currentTime ? (existingCallbackNode = scheduleCallback( 99, performSyncWorkOnRoot.bind(null, root) @@ -6218,7 +6165,7 @@ function ensureRootIsScheduled(root, currentTime) { root.callbackNode = existingCallbackNode; } } -function performConcurrentWorkOnRoot(root, didTimeout) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) @@ -6231,21 +6178,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); var lanes$jscomp$0 = lanes; - didTimeout = executionContext; + var exitStatus = executionContext; executionContext |= 16; var prevDispatcher = pushDispatcher(); if ( workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes$jscomp$0 ) - prepareFreshStack(root, lanes$jscomp$0), + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, lanes$jscomp$0), startWorkOnPendingInteractions(root, lanes$jscomp$0); lanes$jscomp$0 = pushInteractions(root); do @@ -6259,21 +6201,21 @@ function performConcurrentWorkOnRoot(root, didTimeout) { resetContextDependencies(); tracing.__interactionsRef.current = lanes$jscomp$0; ReactCurrentDispatcher$2.current = prevDispatcher; - executionContext = didTimeout; + executionContext = exitStatus; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = 0) : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); + (exitStatus = workInProgressRootExitStatus)); if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && + else if (0 !== exitStatus) { + 2 === exitStatus && ((executionContext |= 64), root.hydrate && (root.hydrate = !1), (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended$1(root, lanes), @@ -6281,7 +6223,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { originalCallbackNode); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; - switch (didTimeout) { + switch (exitStatus) { case 0: case 1: throw Error("Root did not complete. This is a bug in React."); @@ -6292,8 +6234,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes); if ( (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevDispatcher = root.suspendedLanes; @@ -6304,7 +6246,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -6312,33 +6254,31 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevDispatcher = -1; 0 < lanes; ) { + var index$6 = 31 - clz32(lanes); + lanes$jscomp$0 = 1 << index$6; + index$6 = exitStatus[index$6]; + index$6 > prevDispatcher && (prevDispatcher = index$6); + lanes &= ~lanes$jscomp$0; } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); + lanes = prevDispatcher; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), @@ -6349,30 +6289,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { commitRoot(root); break; case 5: - lanes$jscomp$0 = getMostRecentEventTime(root, lanes); - if ( - -1 !== lanes$jscomp$0 && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevDispatcher = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (lanes$jscomp$0 = now() - lanes$jscomp$0), - (didTimeout = - lanes$jscomp$0 <= prevDispatcher - ? 0 - : prevDispatcher + didTimeout - lanes$jscomp$0)), - 10 < didTimeout) - ) { - markRootSuspended$1(root, lanes); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - didTimeout - ); - break; - } commitRoot(root); break; default: @@ -6390,9 +6306,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$12 = 31 - clz32(suspendedLanes), - lane = 1 << index$12; - root[index$12] = -1; + var index$11 = 31 - clz32(suspendedLanes), + lane = 1 << index$11; + root[index$11] = -1; suspendedLanes &= ~lane; } } @@ -6486,8 +6402,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; - workInProgressRootCanSuspendUsingConfig = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; spawnedWorkDuringRender = null; } @@ -6527,7 +6441,7 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.effectTag |= 2048; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -6573,13 +6487,13 @@ function handleError(root$jscomp$0, thrownValue) { workInProgress$77.updateQueue = updateQueue; } else wakeables.add(wakeable); if (0 === (workInProgress$77.mode & 2)) { - workInProgress$77.effectTag |= 64; - sourceFiber.effectTag |= 16384; - sourceFiber.effectTag &= -2981; + workInProgress$77.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } @@ -6606,7 +6520,7 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$77.effectTag |= 4096; + workInProgress$77.flags |= 8192; workInProgress$77.lanes = thrownValue; break a; } @@ -6625,7 +6539,7 @@ function handleError(root$jscomp$0, thrownValue) { switch (workInProgress$77.tag) { case 3: root = value; - workInProgress$77.effectTag |= 4096; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; workInProgress$77.lanes |= thrownValue; var update$78 = createRootErrorUpdate( @@ -6640,14 +6554,14 @@ function handleError(root$jscomp$0, thrownValue) { var ctor = workInProgress$77.type, instance = workInProgress$77.stateNode; if ( - 0 === (workInProgress$77.effectTag & 64) && + 0 === (workInProgress$77.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$77.effectTag |= 4096; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; workInProgress$77.lanes |= thrownValue; var update$81 = createClassErrorUpdate( @@ -6683,13 +6597,6 @@ function pushInteractions(root) { tracing.__interactionsRef.current = root.memoizedInteractions; return prevInteractions; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); -} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 16; @@ -6743,7 +6650,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { + if (0 === (completedWork.flags & 4096)) { if (0 === (completedWork.mode & 8)) current = completeWork(current, completedWork, subtreeRenderLanes); else { @@ -6796,14 +6703,14 @@ function completeUnitOfWork(unitOfWork) { current.childLanes = fiber; } null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && (unitOfWork.firstEffect = completedWork.firstEffect), null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + 1 < completedWork.flags && (null !== unitOfWork.lastEffect ? (unitOfWork.lastEffect.nextEffect = completedWork) : (unitOfWork.firstEffect = completedWork), @@ -6811,7 +6718,7 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.effectTag &= 2047; + current.flags &= 4095; workInProgress = current; return; } @@ -6824,7 +6731,7 @@ function completeUnitOfWork(unitOfWork) { } null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -6870,11 +6777,11 @@ function commitRootImpl(root, renderPriorityLevel) { 0 < noLongerPendingLanes; ) { - var index$13 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$13; - remainingLanes$jscomp$0[index$13] = 0; - eventTimes[index$13] = -1; - expirationTimes[index$13] = -1; + var index$12 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$12; + remainingLanes$jscomp$0[index$12] = 0; + eventTimes[index$12] = -1; + expirationTimes[index$12] = -1; noLongerPendingLanes &= ~lane; } null !== rootsWithPendingDiscreteUpdates && @@ -6884,7 +6791,7 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - 1 < finishedWork.effectTag + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), (remainingLanes = finishedWork.firstEffect)) @@ -6912,8 +6819,8 @@ function commitRootImpl(root, renderPriorityLevel) { do try { for (expirationTimes = root; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6923,21 +6830,21 @@ function commitRootImpl(root, renderPriorityLevel) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: @@ -6952,9 +6859,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$96) { + } catch (error$91) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$96); + captureCommitPhaseError(nextEffect, error$91); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6962,11 +6869,11 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = remainingLanes; do try { - for (effectTag = root; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { @@ -6985,9 +6892,9 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$97) { + } catch (error$92) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$97); + captureCommitPhaseError(nextEffect, error$92); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); @@ -6996,7 +6903,7 @@ function commitRootImpl(root, renderPriorityLevel) { tracing.__interactionsRef.current = eventTimes; executionContext = remainingLanes$jscomp$0; } else (root.current = finishedWork), (commitTime = now$1()); - if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects)) + if ((flags$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), (rootWithPendingPassiveEffects = root), (pendingPassiveEffectsLanes = lanes), @@ -7005,7 +6912,7 @@ function commitRootImpl(root, renderPriorityLevel) { for (nextEffect = remainingLanes; null !== nextEffect; ) (ref = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && + nextEffect.flags & 8 && ((instance = nextEffect), (instance.sibling = null), (instance.stateNode = null)), @@ -7023,7 +6930,7 @@ function commitRootImpl(root, renderPriorityLevel) { scheduleInteractions(root, ref[instance], root.memoizedInteractions); schedulePendingInteractions(root, remainingLanes); } else legacyErrorBoundariesThatAlreadyFailed = null; - effectTag$jscomp$0 || finishPendingInteractions(root, lanes); + flags$jscomp$0 || finishPendingInteractions(root, lanes); 1 === remainingLanes ? root === rootWithNestedUpdates ? nestedUpdateCount++ @@ -7036,7 +6943,7 @@ function commitRootImpl(root, renderPriorityLevel) { rendererID, finishedWork, renderPriorityLevel, - 64 === (finishedWork.current.effectTag & 64) + 64 === (finishedWork.current.flags & 64) ); } catch (err) {} ensureRootIsScheduled(root, now()); @@ -7054,17 +6961,16 @@ function commitBeforeMutationEffects() { var current = nextEffect.alternate; shouldFireAfterActiveInstanceBlur || null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) + (0 !== (nextEffect.flags & 8) ? doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0) : 13 === nextEffect.tag && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle) && (shouldFireAfterActiveInstanceBlur = !0)); - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); - 0 === (effectTag & 512) || + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -7081,7 +6987,6 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } return !1; @@ -7118,10 +7023,10 @@ function flushPassiveEffectsImpl() { unmountEffects = pendingPassiveHookEffectsUnmount; pendingPassiveHookEffectsUnmount = []; for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$102 = unmountEffects[i], + var effect$97 = unmountEffects[i], fiber = unmountEffects[i + 1], - destroy = effect$102.destroy; - effect$102.destroy = void 0; + destroy = effect$97.destroy; + effect$97.destroy = void 0; if ("function" === typeof destroy) try { destroy(); @@ -7133,22 +7038,22 @@ function flushPassiveEffectsImpl() { unmountEffects = pendingPassiveHookEffectsMount; pendingPassiveHookEffectsMount = []; for (i = 0; i < unmountEffects.length; i += 2) { - effect$102 = unmountEffects[i]; + effect$97 = unmountEffects[i]; fiber = unmountEffects[i + 1]; try { - var create$106 = effect$102.create; - effect$102.destroy = create$106(); - } catch (error$107) { + var create$101 = effect$97.create; + effect$97.destroy = create$101(); + } catch (error$102) { if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$107); + captureCommitPhaseError(fiber, error$102); } } for (unmountEffects = root.current.firstEffect; null !== unmountEffects; ) - (create$106 = unmountEffects.nextEffect), + (create$101 = unmountEffects.nextEffect), (unmountEffects.nextEffect = null), - unmountEffects.effectTag & 8 && + unmountEffects.flags & 8 && ((unmountEffects.sibling = null), (unmountEffects.stateNode = null)), - (unmountEffects = create$106); + (unmountEffects = create$101); tracing.__interactionsRef.current = prevInteractions; finishPendingInteractions(root, lanes); executionContext = prevExecutionContext; @@ -7183,14 +7088,22 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); - enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); fiber = markUpdateLaneFromFiberToRoot(fiber, 1); - null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber), - schedulePendingInteractions(fiber, 1)); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update), + schedulePendingInteractions(fiber, 1); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } @@ -7245,7 +7158,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) didReceiveUpdate = !0; else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { didReceiveUpdate = !1; switch (workInProgress.tag) { @@ -7273,7 +7186,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { break; case 12: 0 !== (renderLanes & workInProgress.childLanes) && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); updateLanes = workInProgress.stateNode; updateLanes.effectDuration = 0; updateLanes.passiveEffectDuration = 0; @@ -7298,14 +7211,14 @@ beginWork$1 = function(current, workInProgress, renderLanes) { break; case 19: updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { + if (0 !== (current.flags & 64)) { if (updateLanes) return updateSuspenseListComponent( current, workInProgress, renderLanes ); - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; } context = workInProgress.memoizedState; null !== context && @@ -7332,7 +7245,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); @@ -7344,7 +7257,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { context, renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -7394,7 +7307,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; hasContext = context._init; context = hasContext(context._payload); @@ -7573,7 +7486,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 12: return ( - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (updateLanes = workInProgress.stateNode), (updateLanes.effectDuration = 0), (updateLanes.passiveEffectDuration = 0), @@ -7641,8 +7554,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 1 === context$jscomp$0.tag && ((dependency = createUpdate( -1, - renderLanes & -renderLanes, - null + renderLanes & -renderLanes )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); @@ -7704,7 +7616,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), (updateLanes = updateLanes(context)), - (workInProgress.effectTag |= 1), + (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); @@ -7745,7 +7657,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) @@ -7775,6 +7687,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) { "). This error is likely caused by a bug in React. Please file an issue." ); }; +function markSpawnedWork(lane) { + null === spawnedWorkDuringRender + ? (spawnedWorkDuringRender = [lane]) + : spawnedWorkDuringRender.push(lane); +} function scheduleInteractions(root, lane, interactions) { if (0 < interactions.size) { var pendingInteractionMap = root.pendingInteractionMap, @@ -7848,9 +7765,9 @@ function finishPendingInteractions(root, committedLanes) { if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error$108) { + } catch (error$103) { scheduleCallback(99, function() { - throw error$108; + throw error$103; }); } })); @@ -7866,7 +7783,7 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; @@ -7907,7 +7824,7 @@ function createWorkInProgress(current, pendingProps) { (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), - (workInProgress.effectTag = 0), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), @@ -8063,10 +7980,10 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.hydrate = hydrate; this.callbackNode = null; this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.entanglements = createLaneMap(0); this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); @@ -8098,8 +8015,7 @@ function findHostInstance(component) { function updateContainer(element, container, parentComponent, callback) { var current = container.current, eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + lane = requestUpdateLane(current); a: if (parentComponent) { parentComponent = parentComponent._reactInternals; b: { @@ -8147,7 +8063,7 @@ function updateContainer(element, container, parentComponent, callback) { null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); @@ -8185,14 +8101,16 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_956 = { + devToolsConfig$jscomp$inline_930 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.0-alpha.0", + version: "17.0.1-4e5d7faf5", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8207,13 +8125,17 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1172 = { - bundleType: devToolsConfig$jscomp$inline_956.bundleType, - version: devToolsConfig$jscomp$inline_956.version, - rendererPackageName: devToolsConfig$jscomp$inline_956.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_956.rendererConfig, +var internals$jscomp$inline_1148 = { + bundleType: devToolsConfig$jscomp$inline_930.bundleType, + version: devToolsConfig$jscomp$inline_930.version, + rendererPackageName: devToolsConfig$jscomp$inline_930.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_930.rendererConfig, overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, setSuspenseHandler: null, scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, @@ -8222,7 +8144,7 @@ var internals$jscomp$inline_1172 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_956.findFiberByHostInstance || + devToolsConfig$jscomp$inline_930.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -8231,16 +8153,16 @@ var internals$jscomp$inline_1172 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1173 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1149 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1173.isDisabled && - hook$jscomp$inline_1173.supportsFiber + !hook$jscomp$inline_1149.isDisabled && + hook$jscomp$inline_1149.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1173.inject( - internals$jscomp$inline_1172 + (rendererID = hook$jscomp$inline_1149.inject( + internals$jscomp$inline_1148 )), - (injectedHook = hook$jscomp$inline_1173); + (injectedHook = hook$jscomp$inline_1149); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js index c81740113065d3..3f75533f6cc439 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js @@ -17,16 +17,6 @@ var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/R React = require("react"), Scheduler = require("scheduler"), tracing = require("scheduler/tracing"); -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -97,109 +87,6 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } -function getListener(inst, registrationName) { - var listener = inst.stateNode; - if (!listener) return null; - var props = getFiberCurrentPropsFromNode(listener); - if (!props) return null; - listener = props[registrationName]; - a: switch (registrationName) { - case "onClick": - case "onClickCapture": - case "onDoubleClick": - case "onDoubleClickCapture": - case "onMouseDown": - case "onMouseDownCapture": - case "onMouseMove": - case "onMouseMoveCapture": - case "onMouseUp": - case "onMouseUpCapture": - case "onMouseEnter": - (props = !props.disabled) || - ((inst = inst.type), - (props = !( - "button" === inst || - "input" === inst || - "select" === inst || - "textarea" === inst - ))); - inst = !props; - break a; - default: - inst = !1; - } - if (inst) return null; - if (listener && "function" !== typeof listener) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - return listener; -} -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} function functionThatReturnsTrue() { return !0; } @@ -215,6 +102,7 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; + this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -294,7 +182,12 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { +function createOrGetPooledEvent( + dispatchConfig, + targetInst, + nativeEvent, + nativeInst +) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -311,8 +204,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { + EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; - EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -440,6 +333,22 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -453,65 +362,132 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" - }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" - }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" - }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" - }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies - }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies + dependencies: startDependencies + }, + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] + dependencies: ["topScroll"] + }, + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { - registrationName: "onResponderReject", - dependencies: [] + dependencies: ["topSelectionChange"] + }, + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } + dependencies: moveDependencies + }, + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies }, - ResponderEventPlugin = { + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { registrationName: "onResponderReject", dependencies: [] }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } +}; +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} +function getListener(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +var ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -572,68 +548,70 @@ var eventTypes = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp === responderInst; - JSCompiler_temp = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp; + JSCompiler_temp = targetInst === responderInst; + shouldSetEventType = ResponderSyntheticEvent.getPooled( shouldSetEventType, - JSCompiler_temp, + targetInst, nativeEvent, nativeEventTarget ); - JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; - targetInst + shouldSetEventType.touchHistory = + ResponderTouchHistoryStore.touchHistory; + JSCompiler_temp ? forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateTwoPhaseDispatchesSingle ); b: { - shouldSetEventType = JSCompiler_temp._dispatchListeners; - targetInst = JSCompiler_temp._dispatchInstances; - if (Array.isArray(shouldSetEventType)) + JSCompiler_temp = shouldSetEventType._dispatchListeners; + targetInst = shouldSetEventType._dispatchInstances; + if (Array.isArray(JSCompiler_temp)) for ( depthA = 0; - depthA < shouldSetEventType.length && - !JSCompiler_temp.isPropagationStopped(); + depthA < JSCompiler_temp.length && + !shouldSetEventType.isPropagationStopped(); depthA++ ) { if ( - shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) + JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) ) { - shouldSetEventType = targetInst[depthA]; + JSCompiler_temp = targetInst[depthA]; break b; } } else if ( - shouldSetEventType && - shouldSetEventType(JSCompiler_temp, targetInst) + JSCompiler_temp && + JSCompiler_temp(shouldSetEventType, targetInst) ) { - shouldSetEventType = targetInst; + JSCompiler_temp = targetInst; break b; } - shouldSetEventType = null; + JSCompiler_temp = null; } - JSCompiler_temp._dispatchInstances = null; - JSCompiler_temp._dispatchListeners = null; - JSCompiler_temp.isPersistent() || - JSCompiler_temp.constructor.release(JSCompiler_temp); - if (shouldSetEventType && shouldSetEventType !== responderInst) + shouldSetEventType._dispatchInstances = null; + shouldSetEventType._dispatchListeners = null; + shouldSetEventType.isPersistent() || + shouldSetEventType.constructor.release(shouldSetEventType); + if (JSCompiler_temp && JSCompiler_temp !== responderInst) if ( - ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( + ((shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), - (JSCompiler_temp.touchHistory = + (shouldSetEventType.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - JSCompiler_temp, + shouldSetEventType, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), + (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), responderInst) ) if ( @@ -660,13 +638,13 @@ var eventTypes = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [JSCompiler_temp, depthA] + [shouldSetEventType, depthA] ); - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - shouldSetEventType, + JSCompiler_temp, nativeEvent, nativeEventTarget )), @@ -683,9 +661,9 @@ var eventTypes = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - JSCompiler_temp + shouldSetEventType )), - changeResponder(shouldSetEventType, targetInst); + changeResponder(JSCompiler_temp, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -813,7 +791,6 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -830,7 +807,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -838,7 +815,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule$jscomp$0, + pluginModule, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -866,13 +843,75 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - customBubblingEventTypes = + registrationNameModules = {}; +function getListener$1(inst, registrationName) { + inst = inst.stateNode; + if (null === inst) return null; + inst = getFiberCurrentPropsFromNode(inst); + if (null === inst) return null; + if ((inst = inst[registrationName]) && "function" !== typeof inst) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof inst + + "` type." + ); + return inst; +} +var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; +function accumulateDirectionalDispatches$1(inst, phase, event) { + if ( + (phase = getListener$1( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle$1(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + for (var inst = event._targetInst, path = []; inst; ) { + path.push(inst); + do inst = inst.return; + while (inst && 5 !== inst.tag); + inst = inst ? inst : null; + } + for (inst = path.length; 0 < inst--; ) + accumulateDirectionalDispatches$1(path[inst], "captured", event); + for (inst = 0; inst < path.length; inst++) + accumulateDirectionalDispatches$1(path[inst], "bubbled", event); + } +} +function accumulateDirectDispatchesSingle$1(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener$1(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -882,7 +921,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_94 = { +var injectedNamesToPlugins$jscomp$inline_226 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -906,42 +945,45 @@ var injectedNamesToPlugins$jscomp$inline_94 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); + forEachAccumulated( + topLevelType, + accumulateTwoPhaseDispatchesSingle$1 + ); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_95 = !1, - pluginName$jscomp$inline_96; -for (pluginName$jscomp$inline_96 in injectedNamesToPlugins$jscomp$inline_94) + isOrderingDirty$jscomp$inline_227 = !1, + pluginName$jscomp$inline_228; +for (pluginName$jscomp$inline_228 in injectedNamesToPlugins$jscomp$inline_226) if ( - injectedNamesToPlugins$jscomp$inline_94.hasOwnProperty( - pluginName$jscomp$inline_96 + injectedNamesToPlugins$jscomp$inline_226.hasOwnProperty( + pluginName$jscomp$inline_228 ) ) { - var pluginModule$jscomp$inline_97 = - injectedNamesToPlugins$jscomp$inline_94[pluginName$jscomp$inline_96]; + var pluginModule$jscomp$inline_229 = + injectedNamesToPlugins$jscomp$inline_226[pluginName$jscomp$inline_228]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_96) || - namesToPlugins[pluginName$jscomp$inline_96] !== - pluginModule$jscomp$inline_97 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_228) || + namesToPlugins[pluginName$jscomp$inline_228] !== + pluginModule$jscomp$inline_229 ) { - if (namesToPlugins[pluginName$jscomp$inline_96]) + if (namesToPlugins[pluginName$jscomp$inline_228]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_96 + + pluginName$jscomp$inline_228 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_96 - ] = pluginModule$jscomp$inline_97; - isOrderingDirty$jscomp$inline_95 = !0; + pluginName$jscomp$inline_228 + ] = pluginModule$jscomp$inline_229; + isOrderingDirty$jscomp$inline_227 = !0; } } -isOrderingDirty$jscomp$inline_95 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_227 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -987,34 +1029,41 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { target = null; null != inst && (target = inst.stateNode); batchedUpdates(function() { - var events = target; - for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { - var possiblePlugin = plugins[i]; + var JSCompiler_inline_result = target; + for ( + var events = null, legacyPlugins = plugins, i = 0; + i < legacyPlugins.length; + i++ + ) { + var possiblePlugin = legacyPlugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, inst, nativeEvent, - events, - 1 + JSCompiler_inline_result )) && - (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); + (events = accumulateInto(events, possiblePlugin)); } - events = events$jscomp$0; - null !== events && (eventQueue = accumulateInto(eventQueue, events)); - events = eventQueue; + JSCompiler_inline_result = events; + null !== JSCompiler_inline_result && + (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); + JSCompiler_inline_result = eventQueue; eventQueue = null; - if (events) { - forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (JSCompiler_inline_result) { + forEachAccumulated( + JSCompiler_inline_result, + executeDispatchesAndReleaseTopLevel + ); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((events = rethrowError), + throw ((JSCompiler_inline_result = rethrowError), (hasRethrowError = !1), (rethrowError = null), - events); + JSCompiler_inline_result); } }); } @@ -1029,13 +1078,13 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ ) { var JSCompiler_temp = []; for (var i = 0; i < changedIndices.length; i++) { - var index = changedIndices[i]; - JSCompiler_temp.push(touches[index]); - touches[index] = null; + var index$0 = changedIndices[i]; + JSCompiler_temp.push(touches[index$0]); + touches[index$0] = null; } for (i = changedIndices = 0; i < touches.length; i++) - (index = touches[i]), - null !== index && (touches[changedIndices++] = index); + (index$0 = touches[i]), + null !== index$0 && (touches[changedIndices++] = index$0); touches.length = changedIndices; } else for (JSCompiler_temp = [], i = 0; i < changedIndices.length; i++) @@ -1048,10 +1097,10 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ i = JSCompiler_temp[changedIndices]; i.changedTouches = JSCompiler_temp; i.touches = touches; - index = null; + index$0 = null; var target = i.target; - null === target || void 0 === target || 1 > target || (index = target); - _receiveRootNodeIDEvent(index, eventTopLevelType, i); + null === target || void 0 === target || 1 > target || (index$0 = target); + _receiveRootNodeIDEvent(index$0, eventTopLevelType, i); } } }); @@ -1077,31 +1126,44 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; -ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || - (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); -ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || - (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); -var hasSymbol = "function" === typeof Symbol && Symbol.for, - REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, - REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, - REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, - REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, - REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, - REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, - REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, - REACT_CONCURRENT_MODE_TYPE = hasSymbol - ? Symbol.for("react.concurrent_mode") - : 60111, - REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, - REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_SUSPENSE_LIST_TYPE = hasSymbol - ? Symbol.for("react.suspense_list") - : 60120, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, + REACT_ELEMENT_TYPE = 60103, + REACT_PORTAL_TYPE = 60106, + REACT_FRAGMENT_TYPE = 60107, + REACT_STRICT_MODE_TYPE = 60108, + REACT_PROFILER_TYPE = 60114, + REACT_PROVIDER_TYPE = 60109, + REACT_CONTEXT_TYPE = 60110, + REACT_FORWARD_REF_TYPE = 60112, + REACT_SUSPENSE_TYPE = 60113, + REACT_SUSPENSE_LIST_TYPE = 60120, + REACT_MEMO_TYPE = 60115, + REACT_LAZY_TYPE = 60116, + REACT_BLOCK_TYPE = 60121, + REACT_DEBUG_TRACING_MODE_TYPE = 60129, + REACT_OFFSCREEN_TYPE = 60130, + REACT_LEGACY_HIDDEN_TYPE = 60131; +if ("function" === typeof Symbol && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor("react.element"); + REACT_PORTAL_TYPE = symbolFor("react.portal"); + REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); + REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); + REACT_PROFILER_TYPE = symbolFor("react.profiler"); + REACT_PROVIDER_TYPE = symbolFor("react.provider"); + REACT_CONTEXT_TYPE = symbolFor("react.context"); + REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); + REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); + REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); + REACT_MEMO_TYPE = symbolFor("react.memo"); + REACT_LAZY_TYPE = symbolFor("react.lazy"); + REACT_BLOCK_TYPE = symbolFor("react.block"); + symbolFor("react.scope"); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); + REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); + REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); +} +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1109,27 +1171,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function initializeLazyComponentType(lazyComponent) { - if (-1 === lazyComponent._status) { - var ctor = lazyComponent._result; - ctor || (ctor = lazyComponent._ctor); - ctor = ctor(); - lazyComponent._status = 0; - lazyComponent._result = ctor; - ctor.then( - function(moduleObject) { - 0 === lazyComponent._status && - ((moduleObject = moduleObject.default), - (lazyComponent._status = 1), - (lazyComponent._result = moduleObject)); - }, - function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); - } - ); - } -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1164,10 +1205,13 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type.render); + return getComponentName(type._render); case REACT_LAZY_TYPE: - if ((type = 1 === type._status ? type._result : null)) - return getComponentName(type); + innerType = type._payload; + type = type._init; + try { + return getComponentName(type(innerType)); + } catch (x) {} } return null; } @@ -1179,7 +1223,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.effectTag & 1026) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1219,36 +1263,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, _child = parentA.child; _child; ) { - if (_child === a) { + for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { + if (child$1 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (_child === b) { + if (child$1 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - _child = _child.sibling; + child$1 = child$1.sibling; } if (!didFindChild) { - for (_child = parentB.child; _child; ) { - if (_child === a) { + for (child$1 = parentB.child; child$1; ) { + if (child$1 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (_child === b) { + if (child$1 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - _child = _child.sibling; + child$1 = child$1.sibling; } if (!didFindChild) throw Error( @@ -1283,6 +1327,18 @@ function findCurrentHostFiber(parent) { } return null; } +function doesFiberContain(parentFiber, childFiber) { + for ( + var parentFiberAlternate = parentFiber.alternate; + null !== childFiber; + + ) { + if (childFiber === parentFiber || childFiber === parentFiberAlternate) + return !0; + childFiber = childFiber.return; + } + return !1; +} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -1487,19 +1543,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var _propKey in prevProps) - void 0 === nextProps[_propKey] && - (!(attributeConfig = validAttributes[_propKey]) || - (updatePayload && void 0 !== updatePayload[_propKey]) || - ((prevProp = prevProps[_propKey]), + for (var propKey$3 in prevProps) + void 0 === nextProps[propKey$3] && + (!(attributeConfig = validAttributes[propKey$3]) || + (updatePayload && void 0 !== updatePayload[propKey$3]) || + ((prevProp = prevProps[propKey$3]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[_propKey] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), removedKeys || (removedKeys = {}), - removedKeys[_propKey] || - ((removedKeys[_propKey] = !0), removedKeyCount++)) + removedKeys[propKey$3] || + ((removedKeys[propKey$3] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1608,9 +1664,22 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout, - valueStack = [], + cancelTimeout = clearTimeout; +function describeComponentFrame(name, source, ownerName) { + source = ""; + ownerName && (source = " (created by " + ownerName + ")"); + return "\n in " + (name || "Unknown") + source; +} +function describeFunctionComponentFrame(fn, source) { + return fn + ? describeComponentFrame(fn.displayName || fn.name || null, source, null) + : ""; +} +var valueStack = [], index = -1; +function createCursor(defaultValue) { + return { current: defaultValue }; +} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1621,8 +1690,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = { current: emptyContextObject }, - didPerformWorkStackCursor = { current: !1 }, + contextStackCursor = createCursor(emptyContextObject), + didPerformWorkStackCursor = createCursor(!1), previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1671,7 +1740,7 @@ function processChildContext(fiber, type, parentContext) { contextKey + '" is not defined in childContextTypes.' ); - return Object.assign({}, parentContext, {}, instance); + return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { workInProgress = @@ -1702,12 +1771,212 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } +var rendererID = null, + injectedHook = null, + isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__, + Scheduler_now = Scheduler.unstable_now; +if ( + null == tracing.__interactionsRef || + null == tracing.__interactionsRef.current +) + throw Error( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" + ); +Scheduler_now(); +var return_highestLanePriority = 8; +function getHighestPriorityLanes(lanes) { + if (0 !== (1 & lanes)) return (return_highestLanePriority = 15), 1; + if (0 !== (2 & lanes)) return (return_highestLanePriority = 14), 2; + if (0 !== (4 & lanes)) return (return_highestLanePriority = 13), 4; + var inputDiscreteLanes = 24 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 12), inputDiscreteLanes; + if (0 !== (lanes & 32)) return (return_highestLanePriority = 11), 32; + inputDiscreteLanes = 192 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 10), inputDiscreteLanes; + if (0 !== (lanes & 256)) return (return_highestLanePriority = 9), 256; + inputDiscreteLanes = 3584 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 8), inputDiscreteLanes; + if (0 !== (lanes & 4096)) return (return_highestLanePriority = 7), 4096; + inputDiscreteLanes = 4186112 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 6), inputDiscreteLanes; + inputDiscreteLanes = 62914560 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 5), inputDiscreteLanes; + if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; + if (0 !== (lanes & 134217728)) + return (return_highestLanePriority = 3), 134217728; + inputDiscreteLanes = 805306368 & lanes; + if (0 !== inputDiscreteLanes) + return (return_highestLanePriority = 2), inputDiscreteLanes; + if (0 !== (1073741824 & lanes)) + return (return_highestLanePriority = 1), 1073741824; + return_highestLanePriority = 8; + return lanes; +} +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case 99: + return 15; + case 98: + return 10; + case 97: + case 96: + return 8; + case 95: + return 2; + default: + return 0; + } +} +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case 15: + case 14: + return 99; + case 13: + case 12: + case 11: + case 10: + return 98; + case 9: + case 8: + case 7: + case 6: + case 4: + case 5: + return 97; + case 3: + case 2: + case 1: + return 95; + case 0: + return 90; + default: + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); + } +} +function getNextLanes(root, wipLanes) { + var pendingLanes = root.pendingLanes; + if (0 === pendingLanes) return (return_highestLanePriority = 0); + var nextLanes = 0, + nextLanePriority = 0, + expiredLanes = root.expiredLanes, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes; + if (0 !== expiredLanes) + (nextLanes = expiredLanes), + (nextLanePriority = return_highestLanePriority = 15); + else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { + var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; + 0 !== nonIdleUnblockedLanes + ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), + (nextLanePriority = return_highestLanePriority)) + : ((pingedLanes &= expiredLanes), + 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority))); + } else + (expiredLanes = pendingLanes & ~suspendedLanes), + 0 !== expiredLanes + ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), + (nextLanePriority = return_highestLanePriority)) + : 0 !== pingedLanes && + ((nextLanes = getHighestPriorityLanes(pingedLanes)), + (nextLanePriority = return_highestLanePriority)); + if (0 === nextLanes) return 0; + nextLanes = 31 - clz32(nextLanes); + nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); + if ( + 0 !== wipLanes && + wipLanes !== nextLanes && + 0 === (wipLanes & suspendedLanes) + ) { + getHighestPriorityLanes(wipLanes); + if (nextLanePriority <= return_highestLanePriority) return wipLanes; + return_highestLanePriority = nextLanePriority; + } + wipLanes = root.entangledLanes; + if (0 !== wipLanes) + for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) + (pendingLanes = 31 - clz32(wipLanes)), + (nextLanePriority = 1 << pendingLanes), + (nextLanes |= root[pendingLanes]), + (wipLanes &= ~nextLanePriority); + return nextLanes; +} +function getLanesToRetrySynchronouslyOnError(root) { + root = root.pendingLanes & -1073741825; + return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; +} +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case 15: + return 1; + case 14: + return 2; + case 12: + return ( + (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority + ); + case 10: + return ( + (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), + 0 === lanePriority ? findUpdateLane(8, wipLanes) : lanePriority + ); + case 8: + return ( + (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), + 0 === lanePriority && + ((lanePriority = getHighestPriorityLane(4186112 & ~wipLanes)), + 0 === lanePriority && (lanePriority = 512)), + lanePriority + ); + case 2: + return ( + (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), + 0 === wipLanes && (wipLanes = 268435456), + wipLanes + ); + } + throw Error( + "Invalid update priority: " + lanePriority + ". This is a bug in React." + ); +} +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} +function createLaneMap(initial) { + for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); + return laneMap; +} +function markRootUpdated(root, updateLane, eventTime) { + root.pendingLanes |= updateLane; + var higherPriorityLanes = updateLane - 1; + root.suspendedLanes &= higherPriorityLanes; + root.pingedLanes &= higherPriorityLanes; + root = root.eventTimes; + updateLane = 31 - clz32(updateLane); + root[updateLane] = eventTime; +} +var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, + log = Math.log, + LN2 = Math.LN2; +function clz32Fallback(lanes) { + return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; +} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now = Scheduler.unstable_now, + Scheduler_now$1 = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -1720,7 +1989,7 @@ if ( null == tracing.__interactionsRef.current ) throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + "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 https://reactjs.org/link/profiling" ); var fakeCallbackNode = {}, requestPaint = @@ -1728,12 +1997,12 @@ var fakeCallbackNode = {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), + initialTimeMs$1 = Scheduler_now$1(), now = - 1e4 > initialTimeMs - ? Scheduler_now + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 : function() { - return Scheduler_now() - initialTimeMs; + return Scheduler_now$1() - initialTimeMs$1; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -1775,16 +2044,6 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } -function scheduleSyncCallback(callback) { - null === syncQueue - ? ((syncQueue = [callback]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(callback); - return fakeCallbackNode; -} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -1819,19 +2078,7 @@ function flushSyncCallbackQueueImpl() { } } } -function inferPriorityFromExpirationTime(currentTime, expirationTime) { - if (1073741823 === expirationTime) return 99; - if (1 === expirationTime || 2 === expirationTime) return 95; - currentTime = - 10 * (1073741821 - expirationTime) - 10 * (1073741821 - currentTime); - return 0 >= currentTime - ? 99 - : 250 >= currentTime - ? 98 - : 5250 >= currentTime - ? 97 - : 95; -} +var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -1857,42 +2104,41 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function describeFiber(fiber) { + switch (fiber.tag) { + case 5: + return describeComponentFrame(fiber.type, null, null); + case 16: + return describeComponentFrame("Lazy", null, null); + case 13: + return describeComponentFrame("Suspense", null, null); + case 19: + return describeComponentFrame("SuspenseList", null, null); + case 0: + case 2: + case 15: + return describeFunctionComponentFrame(fiber.type, null); + case 11: + return describeFunctionComponentFrame(fiber.type.render, null); + case 22: + return describeFunctionComponentFrame(fiber.type._render, null); + case 1: + return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; + default: + return ""; + } +} function getStackByFiberInDevAndProd(workInProgress) { - var info = ""; - do { - a: switch (workInProgress.tag) { - case 3: - case 4: - case 6: - case 7: - case 10: - case 9: - var JSCompiler_inline_result = ""; - break a; - default: - var owner = workInProgress._debugOwner, - source = workInProgress._debugSource, - name = getComponentName(workInProgress.type); - JSCompiler_inline_result = null; - owner && (JSCompiler_inline_result = getComponentName(owner.type)); - owner = name; - name = ""; - source - ? (name = - " (at " + - source.fileName.replace(BEFORE_SLASH_RE, "") + - ":" + - source.lineNumber + - ")") - : JSCompiler_inline_result && - (name = " (created by " + JSCompiler_inline_result + ")"); - JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; - } - info += JSCompiler_inline_result; - workInProgress = workInProgress.return; - } while (workInProgress); - return info; + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } } function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { @@ -1901,10 +2147,11 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); + return baseProps; } return baseProps; } -var valueCursor = { current: null }, +var valueCursor = createCursor(null), currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -1916,31 +2163,29 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue = currentValue; } -function scheduleWorkOnParentPath(parent, renderExpirationTime) { +function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { var alternate = parent.alternate; - if (parent.childExpirationTime < renderExpirationTime) - (parent.childExpirationTime = renderExpirationTime), - null !== alternate && - alternate.childExpirationTime < renderExpirationTime && - (alternate.childExpirationTime = renderExpirationTime); - else if ( - null !== alternate && - alternate.childExpirationTime < renderExpirationTime - ) - alternate.childExpirationTime = renderExpirationTime; - else break; + if ((parent.childLanes & renderLanes) === renderLanes) + if ( + null === alternate || + (alternate.childLanes & renderLanes) === renderLanes + ) + break; + else alternate.childLanes |= renderLanes; + else + (parent.childLanes |= renderLanes), + null !== alternate && (alternate.childLanes |= renderLanes); parent = parent.return; } } -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress, renderLanes) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (workInProgress.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0), + (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -1959,7 +2204,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - expirationTime: 0, + lanes: 0, firstContext: observedBits, responders: null }; @@ -1971,7 +2216,8 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - baseQueue: null, + firstBaseUpdate: null, + lastBaseUpdate: null, shared: { pending: null }, effects: null }; @@ -1981,21 +2227,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - baseQueue: current.baseQueue, + firstBaseUpdate: current.firstBaseUpdate, + lastBaseUpdate: current.lastBaseUpdate, shared: current.shared, effects: current.effects }); } -function createUpdate(expirationTime, suspenseConfig) { - expirationTime = { - expirationTime: expirationTime, - suspenseConfig: suspenseConfig, +function createUpdate(eventTime, lane) { + return { + eventTime: eventTime, + lane: lane, tag: 0, payload: null, callback: null, next: null }; - return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -2008,132 +2254,177 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, update) { - var current = workInProgress.alternate; - null !== current && cloneUpdateQueue(current, workInProgress); - workInProgress = workInProgress.updateQueue; - current = workInProgress.baseQueue; - null === current - ? ((workInProgress.baseQueue = update.next = update), - (update.next = update)) - : ((update.next = current.next), (current.next = update)); +function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + var queue = workInProgress.updateQueue, + current = workInProgress.alternate; + if ( + null !== current && + ((current = current.updateQueue), queue === current) + ) { + var newFirst = null, + newLast = null; + queue = queue.firstBaseUpdate; + if (null !== queue) { + do { + var clone = { + eventTime: queue.eventTime, + lane: queue.lane, + tag: queue.tag, + payload: queue.payload, + callback: queue.callback, + next: null + }; + null === newLast + ? (newFirst = newLast = clone) + : (newLast = newLast.next = clone); + queue = queue.next; + } while (null !== queue); + null === newLast + ? (newFirst = newLast = capturedUpdate) + : (newLast = newLast.next = capturedUpdate); + } else newFirst = newLast = capturedUpdate; + queue = { + baseState: current.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: current.shared, + effects: current.effects + }; + workInProgress.updateQueue = queue; + return; + } + workInProgress = queue.lastBaseUpdate; + null === workInProgress + ? (queue.firstBaseUpdate = capturedUpdate) + : (workInProgress.next = capturedUpdate); + queue.lastBaseUpdate = capturedUpdate; } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderExpirationTime + renderLanes ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var baseQueue = queue.baseQueue, + var firstBaseUpdate = queue.firstBaseUpdate, + lastBaseUpdate = queue.lastBaseUpdate, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - if (null !== baseQueue) { - var baseFirst = baseQueue.next; - baseQueue.next = pendingQueue.next; - pendingQueue.next = baseFirst; - } - baseQueue = pendingQueue; queue.shared.pending = null; - baseFirst = workInProgress$jscomp$0.alternate; - null !== baseFirst && - ((baseFirst = baseFirst.updateQueue), - null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); + var lastPendingUpdate = pendingQueue, + firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; + null === lastBaseUpdate + ? (firstBaseUpdate = firstPendingUpdate) + : (lastBaseUpdate.next = firstPendingUpdate); + lastBaseUpdate = lastPendingUpdate; + var current = workInProgress$jscomp$0.alternate; + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate + ? (current.firstBaseUpdate = firstPendingUpdate) + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } - if (null !== baseQueue) { - baseFirst = baseQueue.next; - var newState = queue.baseState, - newExpirationTime = 0, - newBaseState = null, - newBaseQueueFirst = null, - newBaseQueueLast = null; - if (null !== baseFirst) { - var update = baseFirst; - do { - pendingQueue = update.expirationTime; - if (pendingQueue < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, + if (null !== firstBaseUpdate) { + currentLastBaseUpdate = queue.baseState; + lastBaseUpdate = 0; + current = firstPendingUpdate = lastPendingUpdate = null; + do { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { + null !== current && + (current = current.next = { + eventTime: updateEventTime, + lane: 0, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (newBaseState = newState)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - pendingQueue > newExpirationTime && - (newExpirationTime = pendingQueue); - } else { - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }); - markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); - a: { - var workInProgress = workInProgress$jscomp$0, - update$jscomp$0 = update; - pendingQueue = props; - clone = instance; - switch (update$jscomp$0.tag) { - case 1: - workInProgress = update$jscomp$0.payload; - if ("function" === typeof workInProgress) { - newState = workInProgress.call(clone, newState, pendingQueue); - break a; - } - newState = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update$jscomp$0.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call(clone, newState, pendingQueue) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - newState = Object.assign({}, newState, pendingQueue); + }); + a: { + var workInProgress = workInProgress$jscomp$0, + update = firstBaseUpdate; + pendingQueue = props; + updateEventTime = instance; + switch (update.tag) { + case 1: + workInProgress = update.payload; + if ("function" === typeof workInProgress) { + currentLastBaseUpdate = workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ); break a; - case 2: - hasForceUpdate = !0; - } + } + currentLastBaseUpdate = workInProgress; + break a; + case 3: + workInProgress.flags = (workInProgress.flags & -8193) | 64; + case 0: + workInProgress = update.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); + break a; + case 2: + hasForceUpdate = !0; } - null !== update.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [update]) - : pendingQueue.push(update)); } - update = update.next; - if (null === update || update === baseFirst) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (update = baseQueue.next = pendingQueue.next), - (pendingQueue.next = baseFirst), - (queue.baseQueue = baseQueue = pendingQueue), - (queue.shared.pending = null); - } while (1); - } - null === newBaseQueueLast - ? (newBaseState = newState) - : (newBaseQueueLast.next = newBaseQueueFirst); - queue.baseState = newBaseState; - queue.baseQueue = newBaseQueueLast; - markUnprocessedUpdateTime(newExpirationTime); - workInProgress$jscomp$0.expirationTime = newExpirationTime; - workInProgress$jscomp$0.memoizedState = newState; + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); + } else + (updateEventTime = { + eventTime: updateEventTime, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, + next: null + }), + null === current + ? ((firstPendingUpdate = current = updateEventTime), + (lastPendingUpdate = currentLastBaseUpdate)) + : (current = current.next = updateEventTime), + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), + (queue.shared.pending = null); + } while (1); + null === current && (lastPendingUpdate = currentLastBaseUpdate); + queue.baseState = lastPendingUpdate; + queue.firstBaseUpdate = firstPendingUpdate; + queue.lastBaseUpdate = current; + workInProgressRootSkippedLanes |= lastBaseUpdate; + workInProgress$jscomp$0.lanes = lastBaseUpdate; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2158,8 +2449,7 @@ function commitUpdateQueue(finishedWork, finishedQueue, instance) { } } } -var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2173,54 +2463,45 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.expirationTime && + 0 === workInProgress.lanes && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternalFiber) + return (component = component._reactInternals) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 1; - suspenseConfig.payload = payload; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 1; + update.payload = payload; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternalFiber; - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); - suspenseConfig = createUpdate(currentTime, suspenseConfig); - suspenseConfig.tag = 2; - void 0 !== callback && - null !== callback && - (suspenseConfig.callback = callback); - enqueueUpdate(inst, suspenseConfig); - scheduleWork(inst, currentTime); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); + update.tag = 2; + void 0 !== callback && null !== callback && (update.callback = callback); + enqueueUpdate(inst, update); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2258,7 +2539,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternalFiber = workInProgress; + ctor._reactInternals = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2279,12 +2560,7 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance( - workInProgress, - ctor, - newProps, - renderExpirationTime -) { +function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2297,7 +2573,7 @@ function mountClassInstance( ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); + processUpdateQueue(workInProgress, newProps, instance, renderLanes); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2314,15 +2590,10 @@ function mountClassInstance( instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue( - workInProgress, - newProps, - instance, - renderExpirationTime - ), + processUpdateQueue(workInProgress, newProps, instance, renderLanes), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); } var isArray = Array.isArray; function coerceRef(returnFiber, current, element) { @@ -2337,7 +2608,7 @@ function coerceRef(returnFiber, current, element) { if (element) { if (1 !== element.tag) throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" + "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); var inst = element.stateNode; } @@ -2371,7 +2642,7 @@ function coerceRef(returnFiber, current, element) { throw Error( "Element ref was specified as a string (" + returnFiber + - ") 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." + ") 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://reactjs.org/link/refs-must-have-owner for more information." ); } return returnFiber; @@ -2383,7 +2654,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - ")." + "). If you meant to render a collection of children, use an array instead." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2395,7 +2666,7 @@ function ChildReconciler(shouldTrackSideEffects) { (returnFiber.lastEffect = childToDelete)) : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); childToDelete.nextEffect = null; - childToDelete.effectTag = 8; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2427,26 +2698,22 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.effectTag = 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.effectTag = 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.effectTag = 2); + (newFiber.flags = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, expirationTime) { + function updateTextNode(returnFiber, current, textContent, lanes) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText( - textContent, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromText(textContent, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2454,27 +2721,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, expirationTime) { + function updateElement(returnFiber, current, element, lanes) { if (null !== current && current.elementType === element.type) return ( - (expirationTime = useFiber(current, element.props)), - (expirationTime.ref = coerceRef(returnFiber, current, element)), - (expirationTime.return = returnFiber), - expirationTime + (lanes = useFiber(current, element.props)), + (lanes.ref = coerceRef(returnFiber, current, element)), + (lanes.return = returnFiber), + lanes ); - expirationTime = createFiberFromTypeAndProps( + lanes = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - expirationTime + lanes ); - expirationTime.ref = coerceRef(returnFiber, current, element); - expirationTime.return = returnFiber; - return expirationTime; + lanes.ref = coerceRef(returnFiber, current, element); + lanes.return = returnFiber; + return lanes; } - function updatePortal(returnFiber, current, portal, expirationTime) { + function updatePortal(returnFiber, current, portal, lanes) { if ( null === current || 4 !== current.tag || @@ -2482,11 +2749,7 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal( - portal, - returnFiber.mode, - expirationTime - )), + (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), (current.return = returnFiber), current ); @@ -2494,13 +2757,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, expirationTime, key) { + function updateFragment(returnFiber, current, fragment, lanes, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - expirationTime, + lanes, key )), (current.return = returnFiber), @@ -2510,13 +2773,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, expirationTime) { + function createChild(returnFiber, newChild, lanes) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2525,24 +2788,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( + (lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef(returnFiber, null, newChild)), - (expirationTime.return = returnFiber), - expirationTime + (lanes.ref = coerceRef(returnFiber, null, newChild)), + (lanes.return = returnFiber), + lanes ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes )), (newChild.return = returnFiber), newChild @@ -2553,7 +2816,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - expirationTime, + lanes, null )), (newChild.return = returnFiber), @@ -2563,12 +2826,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { + function updateSlot(returnFiber, oldFiber, newChild, lanes) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); + : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2578,26 +2841,20 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - expirationTime, + lanes, key ) - : updateElement(returnFiber, oldFiber, newChild, expirationTime) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) + ? updatePortal(returnFiber, oldFiber, newChild, lanes) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment( - returnFiber, - oldFiber, - newChild, - expirationTime, - null - ); + : updateFragment(returnFiber, oldFiber, newChild, lanes, null); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2607,17 +2864,12 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - expirationTime + lanes ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode( - returnFiber, - existingChildren, - "" + newChild, - expirationTime - ) + updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2632,15 +2884,10 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - expirationTime, + lanes, newChild.key ) - : updateElement( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -2648,24 +2895,13 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal( - returnFiber, - existingChildren, - newChild, - expirationTime - ) + updatePortal(returnFiber, existingChildren, newChild, lanes) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment( - returnFiber, - existingChildren, - newChild, - expirationTime, - null - ) + updateFragment(returnFiber, existingChildren, newChild, lanes, null) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2675,7 +2911,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - expirationTime + lanes ) { for ( var resultingFirstChild = null, @@ -2693,7 +2929,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - expirationTime + lanes ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2716,11 +2952,7 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )), + (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -2743,7 +2975,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - expirationTime + lanes )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -2770,7 +3002,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - expirationTime + lanes ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -2792,12 +3024,7 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot( - returnFiber, - oldFiber, - step.value, - expirationTime - ); + var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -2817,7 +3044,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, expirationTime)), + (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -2831,13 +3058,7 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap( - oldFiber, - returnFiber, - newIdx, - step.value, - expirationTime - )), + (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -2853,7 +3074,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, expirationTime) { + return function(returnFiber, currentFirstChild, newChild, lanes) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -2919,26 +3140,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - expirationTime, + lanes, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( + : ((lanes = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - expirationTime + lanes )), - (expirationTime.ref = coerceRef( + (lanes.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (expirationTime.return = returnFiber), - (returnFiber = expirationTime)); + (lanes.return = returnFiber), + (returnFiber = lanes)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -2977,7 +3198,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - expirationTime + lanes ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -2996,7 +3217,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - expirationTime + lanes )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -3007,25 +3228,27 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - expirationTime + lanes ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: + case 22: case 0: - throw ((returnFiber = returnFiber.type), - Error( - (returnFiber.displayName || returnFiber.name || "Component") + + case 11: + case 15: + throw Error( + (getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - )); + ); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3033,9 +3256,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = { current: NO_CONTEXT }, - contextFiberStackCursor = { current: NO_CONTEXT }, - rootInstanceStackCursor = { current: NO_CONTEXT }; + contextStackCursor$1 = createCursor(NO_CONTEXT), + contextFiberStackCursor = createCursor(NO_CONTEXT), + rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3058,26 +3281,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var nextContext = fiber.type; - nextContext = - "AndroidTextInput" === nextContext || - "RCTMultilineTextInputView" === nextContext || - "RCTSinglelineTextInputView" === nextContext || - "RCTText" === nextContext || - "RCTVirtualText" === nextContext; - nextContext = - context.isInAParentText !== nextContext - ? { isInAParentText: nextContext } + var JSCompiler_inline_result = fiber.type; + JSCompiler_inline_result = + "AndroidTextInput" === JSCompiler_inline_result || + "RCTMultilineTextInputView" === JSCompiler_inline_result || + "RCTSinglelineTextInputView" === JSCompiler_inline_result || + "RCTText" === JSCompiler_inline_result || + "RCTVirtualText" === JSCompiler_inline_result; + JSCompiler_inline_result = + context.isInAParentText !== JSCompiler_inline_result + ? { isInAParentText: JSCompiler_inline_result } : context; - context !== nextContext && + context !== JSCompiler_inline_result && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, nextContext)); + push(contextStackCursor$1, JSCompiler_inline_result)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = { current: 0 }; +var suspenseStackCursor = createCursor(0); function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3085,7 +3308,7 @@ function findFirstSuspended(row) { if (null !== state && (null === state.dehydrated || shim() || shim())) return node; } else if (19 === node.tag && void 0 !== node.memoizedProps.revealOrder) { - if (0 !== (node.effectTag & 64)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3101,19 +3324,23 @@ function findFirstSuspended(row) { } return null; } -function createDeprecatedResponderListener(responder, props) { - return { responder: responder, props: props }; +var workInProgressSources = []; +function resetWorkInProgressVersions() { + for (var i = 0; i < workInProgressSources.length; i++) + workInProgressSources[i]._workInProgressVersionPrimary = null; + workInProgressSources.length = 0; } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderExpirationTime = 0, + renderLanes = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1; + didScheduleRenderPhaseUpdate = !1, + didScheduleRenderPhaseUpdateDuringThisPass = !1; function throwInvalidHookError() { throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3128,36 +3355,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderExpirationTime + nextRenderLanes ) { - renderExpirationTime = nextRenderExpirationTime; + renderLanes = nextRenderLanes; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.expirationTime = 0; - ReactCurrentDispatcher.current = + workInProgress.lanes = 0; + ReactCurrentDispatcher$1.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (workInProgress.expirationTime === renderExpirationTime) { - nextRenderExpirationTime = 0; + if (didScheduleRenderPhaseUpdateDuringThisPass) { + nextRenderLanes = 0; do { - workInProgress.expirationTime = 0; - if (!(25 > nextRenderExpirationTime)) + didScheduleRenderPhaseUpdateDuringThisPass = !1; + if (!(25 > nextRenderLanes)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderExpirationTime += 1; + nextRenderLanes += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (workInProgress.expirationTime === renderExpirationTime); + } while (didScheduleRenderPhaseUpdateDuringThisPass); } - ReactCurrentDispatcher.current = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3238,40 +3465,34 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var updateExpirationTime = update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { - var clone = { - expirationTime: update.expirationTime, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }; - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - updateExpirationTime > currentlyRenderingFiber$1.expirationTime && - ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), - markUnprocessedUpdateTime(updateExpirationTime)); - } else + var updateLane = update.lane; + if ((renderLanes & updateLane) === updateLane) null !== newBaseQueueLast && (newBaseQueueLast = newBaseQueueLast.next = { - expirationTime: 1073741823, - suspenseConfig: update.suspenseConfig, + lane: 0, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - markRenderEventTimeAndConfig( - updateExpirationTime, - update.suspenseConfig - ), (current = update.eagerReducer === reducer ? update.eagerState : reducer(current, update.action)); + else { + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + currentlyRenderingFiber$1.lanes |= updateLane; + workInProgressRootSkippedLanes |= updateLane; + } update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3308,6 +3529,114 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } +function readFromUnsubcribedMutableSource(root, source, getSnapshot) { + var getVersion = source._getVersion; + getVersion = getVersion(source._source); + var JSCompiler_inline_result = source._workInProgressVersionPrimary; + if (null !== JSCompiler_inline_result) + root = JSCompiler_inline_result === getVersion; + else if ( + ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) + ) + (source._workInProgressVersionPrimary = getVersion), + workInProgressSources.push(source); + if (root) return getSnapshot(source._source); + workInProgressSources.push(source); + throw Error( + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." + ); +} +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = workInProgressRoot; + if (null === root) + throw Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + var getVersion = source._getVersion, + version = getVersion(source._source), + dispatcher = ReactCurrentDispatcher$1.current, + _dispatcher$useState = dispatcher.useState(function() { + return readFromUnsubcribedMutableSource(root, source, getSnapshot); + }), + setSnapshot = _dispatcher$useState[1], + snapshot = _dispatcher$useState[0]; + _dispatcher$useState = workInProgressHook; + var memoizedState = hook.memoizedState, + refs = memoizedState.refs, + prevGetSnapshot = refs.getSnapshot, + prevSource = memoizedState.source; + memoizedState = memoizedState.subscribe; + var fiber = currentlyRenderingFiber$1; + hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; + dispatcher.useEffect( + function() { + refs.getSnapshot = getSnapshot; + refs.setSnapshot = setSnapshot; + var maybeNewVersion = getVersion(source._source); + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); + maybeNewVersion = root.mutableReadLanes; + root.entangledLanes |= maybeNewVersion; + for ( + var entanglements = root.entanglements, lanes = maybeNewVersion; + 0 < lanes; + + ) { + var index$13 = 31 - clz32(lanes), + lane = 1 << index$13; + entanglements[index$13] |= maybeNewVersion; + lanes &= ~lane; + } + } + }, + [getSnapshot, source, subscribe] + ); + dispatcher.useEffect( + function() { + return subscribe(source._source, function() { + var latestGetSnapshot = refs.getSnapshot, + latestSetSnapshot = refs.setSnapshot; + try { + latestSetSnapshot(latestGetSnapshot(source._source)); + var lane = requestUpdateLane(fiber); + root.mutableReadLanes |= lane & root.pendingLanes; + } catch (error) { + latestSetSnapshot(function() { + throw error; + }); + } + }); + }, + [source, subscribe] + ); + (objectIs(prevGetSnapshot, getSnapshot) && + objectIs(prevSource, source) && + objectIs(memoizedState, subscribe)) || + ((hook = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), + (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); + return snapshot; +} +function updateMutableSource(source, getSnapshot, subscribe) { + var hook = updateWorkInProgressHook(); + return useMutableSource(hook, source, getSnapshot, subscribe); +} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3344,17 +3673,17 @@ function pushEffect(tag, create, destroy, deps) { function updateRef() { return updateWorkInProgressHook().memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function mountEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = mountWorkInProgressHook(); - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + currentlyRenderingFiber$1.flags |= fiberFlags; hook.memoizedState = pushEffect( - 1 | hookEffectTag, + 1 | hookFlags, create, void 0, void 0 === deps ? null : deps ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { +function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; var destroy = void 0; @@ -3362,12 +3691,12 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(hookEffectTag, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } - currentlyRenderingFiber$1.effectTag |= fiberEffectTag; - hook.memoizedState = pushEffect(1 | hookEffectTag, create, destroy, deps); + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { return mountEffectImpl(516, 4, create, deps); @@ -3406,13 +3735,6 @@ function updateImperativeHandle(ref, create, deps) { ); } function mountDebugValue() {} -function mountCallback(callback, deps) { - mountWorkInProgressHook().memoizedState = [ - callback, - void 0 === deps ? null : deps - ]; - return callback; -} function updateCallback(callback, deps) { var hook = updateWorkInProgressHook(); deps = void 0 === deps ? null : deps; @@ -3440,65 +3762,60 @@ function updateMemo(nextCreate, deps) { hook.memoizedState = [nextCreate, deps]; return nextCreate; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority(98 > priorityLevel ? 98 : priorityLevel, function() { setPending(!0); }); runWithPriority(97 < priorityLevel ? 97 : priorityLevel, function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setPending(!1), callback(); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }); } function dispatchAction(fiber, queue, action) { - var currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); - suspenseConfig = { - expirationTime: currentTime, - suspenseConfig: suspenseConfig, - action: action, - eagerReducer: null, - eagerState: null, - next: null - }; - var pending = queue.pending; + var eventTime = requestEventTime(), + lane = requestUpdateLane(fiber), + update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }, + pending = queue.pending; null === pending - ? (suspenseConfig.next = suspenseConfig) - : ((suspenseConfig.next = pending.next), (pending.next = suspenseConfig)); - queue.pending = suspenseConfig; + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdate = !0), - (suspenseConfig.expirationTime = renderExpirationTime), - (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { if ( - 0 === fiber.expirationTime && - (null === pending || 0 === pending.expirationTime) && + 0 === fiber.lanes && + (null === pending || 0 === pending.lanes) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, eagerState = pending(currentState, action); - suspenseConfig.eagerReducer = pending; - suspenseConfig.eagerState = eagerState; + update.eagerReducer = pending; + update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } -function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3511,14 +3828,21 @@ var ContextOnlyDispatcher = { useRef: throwInvalidHookError, useState: throwInvalidHookError, useDebugValue: throwInvalidHookError, - useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useEvent: throwInvalidHookError + useMutableSource: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, + unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { readContext: readContext, - useCallback: mountCallback, + useCallback: function(callback, deps) { + mountWorkInProgressHook().memoizedState = [ + callback, + void 0 === deps ? null : deps + ]; + return callback; + }, useContext: readContext, useEffect: mountEffect, useImperativeHandle: function(ref, create, deps) { @@ -3564,39 +3888,44 @@ var ContextOnlyDispatcher = { }, useState: mountState, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1]; mountEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { + useTransition: function() { var _mountState2 = mountState(!1), isPending = _mountState2[0]; - _mountState2 = _mountState2[1]; - return [ - mountCallback(startTransition.bind(null, _mountState2, config), [ - _mountState2, - config - ]), - isPending - ]; + _mountState2 = startTransition.bind(null, _mountState2[1]); + mountWorkInProgressHook().memoizedState = _mountState2; + return [_mountState2, isPending]; + }, + useMutableSource: function(source, getSnapshot, subscribe) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); }, - useEvent: function() {} + unstable_isNewReconciler: !1 }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -3612,39 +3941,33 @@ var ContextOnlyDispatcher = { return updateReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _updateState = updateReducer(basicStateReducer), prevValue = _updateState[0], setValue = _updateState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _updateState2 = updateReducer(basicStateReducer), - isPending = _updateState2[0]; - _updateState2 = _updateState2[1]; - return [ - updateCallback(startTransition.bind(null, _updateState2, config), [ - _updateState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = updateReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; + }, + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; }, - useEvent: updateEventListener + unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { readContext: readContext, @@ -3660,39 +3983,33 @@ var ContextOnlyDispatcher = { return rerenderReducer(basicStateReducer); }, useDebugValue: mountDebugValue, - useResponder: createDeprecatedResponderListener, - useDeferredValue: function(value, config) { + useDeferredValue: function(value) { var _rerenderState = rerenderReducer(basicStateReducer), prevValue = _rerenderState[0], setValue = _rerenderState[1]; updateEffect( function() { - var previousConfig = ReactCurrentBatchConfig$1.suspense; - ReactCurrentBatchConfig$1.suspense = - void 0 === config ? null : config; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; try { setValue(value); } finally { - ReactCurrentBatchConfig$1.suspense = previousConfig; + ReactCurrentBatchConfig$1.transition = prevTransition; } }, - [value, config] + [value] ); return prevValue; }, - useTransition: function(config) { - var _rerenderState2 = rerenderReducer(basicStateReducer), - isPending = _rerenderState2[0]; - _rerenderState2 = _rerenderState2[1]; - return [ - updateCallback(startTransition.bind(null, _rerenderState2, config), [ - _rerenderState2, - config - ]), - isPending - ]; + useTransition: function() { + var isPending = rerenderReducer(basicStateReducer)[0]; + return [updateWorkInProgressHook().memoizedState, isPending]; + }, + useMutableSource: updateMutableSource, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; }, - useEvent: updateEventListener + unstable_isNewReconciler: !1 }, now$1 = Scheduler.unstable_now, commitTime = 0, @@ -3705,27 +4022,21 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { profilerStartTime = -1; } } +function transferActualDuration(fiber) { + for (var child = fiber.child; child; ) + (fiber.actualDuration += child.actualDuration), (child = child.sibling); +} var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime -) { +function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress.child = null === current - ? mountChildFibers( - workInProgress, - null, - nextChildren, - renderExpirationTime - ) + ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderExpirationTime + renderLanes ); } function updateForwardRef( @@ -3733,33 +4044,28 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, nextProps, renderLanes); return workInProgress.child; } function updateMemoComponent( @@ -3767,8 +4073,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { if (null === current) { var type = Component.type; @@ -3787,17 +4093,17 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); current = createFiberFromTypeAndProps( Component.type, null, nextProps, - null, + workInProgress, workInProgress.mode, - renderExpirationTime + renderLanes ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3805,19 +4111,14 @@ function updateMemoComponent( } type = current.child; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), + 0 === (updateLanes & renderLanes) && + ((updateLanes = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current.ref === workInProgress.ref) + Component(updateLanes, nextProps) && current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + workInProgress.flags |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; current.return = workInProgress; @@ -3828,26 +4129,64 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) { - return null !== current && + if ( + null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref && - ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) - ? ((workInProgress.expirationTime = current.expirationTime), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - )) - : updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderExpirationTime + current.ref === workInProgress.ref + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else + return ( + (workInProgress.lanes = current.lanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); + return updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderLanes + ); +} +function updateOffscreenComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, + nextChildren = nextProps.children, + prevState = null !== current ? current.memoizedState : null; + if ( + "hidden" === nextProps.mode || + "unstable-defer-without-hiding" === nextProps.mode + ) + if (0 === (workInProgress.mode & 4)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes(workInProgress, renderLanes); + else if (0 !== (renderLanes & 1073741824)) + (workInProgress.memoizedState = { baseLanes: 0 }), + pushRenderLanes( + workInProgress, + null !== prevState ? prevState.baseLanes : renderLanes + ); + else + return ( + (current = + null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), + markSpawnedWork(1073741824), + (workInProgress.lanes = workInProgress.childLanes = 1073741824), + (workInProgress.memoizedState = { baseLanes: current }), + pushRenderLanes(workInProgress, current), + null + ); + else + null !== prevState + ? ((nextProps = prevState.baseLanes | renderLanes), + (workInProgress.memoizedState = null)) + : (nextProps = renderLanes), + pushRenderLanes(workInProgress, nextProps); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -3855,42 +4194,37 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.effectTag |= 128; + workInProgress.flags |= 128; } function updateFunctionComponent( current, workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderExpirationTime + renderLanes ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.effectTag &= -517), - current.expirationTime <= renderExpirationTime && - (current.expirationTime = 0), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + (workInProgress.flags &= -517), + (current.lanes &= ~renderLanes), + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderExpirationTime); + workInProgress.flags |= 1; + reconcileChildren(current, workInProgress, Component, renderLanes); return workInProgress.child; } function updateClassComponent( @@ -3898,25 +4232,20 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderLanes ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ), + mountClassInstance(workInProgress, Component, nextProps, renderLanes), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -3947,12 +4276,7 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ); + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -3985,9 +4309,9 @@ function updateClassComponent( "function" === typeof instance.UNSAFE_componentWillMount && instance.UNSAFE_componentWillMount()), "function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4)) + (workInProgress.flags |= 4)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (instance.props = nextProps), @@ -3995,119 +4319,113 @@ function updateClassComponent( (instance.context = contextType), (nextProps = oldProps)) : ("function" === typeof instance.componentDidMount && - (workInProgress.effectTag |= 4), + (workInProgress.flags |= 4), (nextProps = !1)); - } else - (instance = workInProgress.stateNode), - cloneUpdateQueue(current, workInProgress), - (oldProps = workInProgress.memoizedProps), - (instance.props = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps)), - (oldContext = instance.context), - (contextType = Component.contextType), - "object" === typeof contextType && null !== contextType - ? (contextType = readContext(contextType)) - : ((contextType = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = - "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( + } else { + instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); + oldProps = workInProgress.memoizedProps; + contextType = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); + instance.props = contextType; + hasNewLifecycles = workInProgress.pendingProps; + oldState = instance.context; + oldContext = Component.contextType; + "object" === typeof oldContext && null !== oldContext + ? (oldContext = readContext(oldContext)) + : ((oldContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (oldContext = getMaskedContext(workInProgress, oldContext))); + var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; + (getDerivedStateFromProps = + "function" === typeof getDerivedStateFromProps$jscomp$0 || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== hasNewLifecycles || oldState !== oldContext) && + callComponentWillReceiveProps( + workInProgress, + instance, + nextProps, + oldContext + )); + hasForceUpdate = !1; + oldState = workInProgress.memoizedState; + instance.state = oldState; + processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + var newState = workInProgress.memoizedState; + oldProps !== hasNewLifecycles || + oldState !== newState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps$jscomp$0, + nextProps + ), + (newState = workInProgress.memoizedState)), + (contextType = + hasForceUpdate || + checkShouldComponentUpdate( workInProgress, - instance, + Component, + contextType, nextProps, - contextType - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (instance.state = oldContext), - processUpdateQueue( - workInProgress, - nextProps, - instance, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState), - oldProps !== nextProps || - oldContext !== oldState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldState = workInProgress.memoizedState)), - (getDerivedStateFromProps = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - oldProps, - nextProps, - oldContext, - oldState, - contextType - )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( - nextProps, - oldState, - contextType - ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - oldState, - contextType - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), - (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldContext === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); + oldState, + newState, + oldContext + )) + ? (getDerivedStateFromProps || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate(nextProps, newState, oldContext), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + newState, + oldContext + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.flags |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.flags |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = newState)), + (instance.props = nextProps), + (instance.state = newState), + (instance.context = oldContext), + (nextProps = contextType)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldState === current.memoizedState) || + (workInProgress.flags |= 256), + (nextProps = !1)); + } return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderExpirationTime + renderLanes ); } function finishClassComponent( @@ -4116,18 +4434,14 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderExpirationTime + renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.effectTag & 64); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ) + bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4138,27 +4452,22 @@ function finishClassComponent( var nextChildren = null; profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; null !== current && didCaptureError ? ((didCaptureError = nextChildren), (workInProgress.child = reconcileChildFibers( workInProgress, current.child, null, - renderExpirationTime + renderLanes )), (workInProgress.child = reconcileChildFibers( workInProgress, null, didCaptureError, - renderExpirationTime + renderLanes ))) - : reconcileChildren( - current, - workInProgress, - nextChildren, - renderExpirationTime - ); + : reconcileChildren(current, workInProgress, nextChildren, renderLanes); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4175,169 +4484,227 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; -function updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime -) { - var mode = workInProgress.mode, - nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; +function updateSuspenseComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - nextDidTimeout = !1, + showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = - 0 !== (suspenseContext & 2) && - (null === current || null !== current.memoizedState)); + null !== current && null === current.memoizedState + ? !1 + : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + current = nextProps.children; + suspenseContext = nextProps.fallback; + if (showFallback) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + current ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - mode = nextProps.children; - workInProgress.memoizedState = null; - return (workInProgress.child = mountChildFibers( - workInProgress, - null, - mode, - renderExpirationTime - )); + if ("number" === typeof nextProps.unstable_expectedLoadTime) + return ( + (current = mountSuspenseFallbackChildren( + workInProgress, + current, + suspenseContext, + renderLanes + )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), + (workInProgress.memoizedState = SUSPENDED_MARKER), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432), + current + ); + renderLanes = createFiberFromOffscreen( + { mode: "visible", children: current }, + workInProgress.mode, + renderLanes, + null + ); + renderLanes.return = workInProgress; + return (workInProgress.child = renderLanes); } if (null !== current.memoizedState) { - current = current.child; - mode = current.sibling; - if (nextDidTimeout) { - nextProps = nextProps.fallback; - renderExpirationTime = createWorkInProgress( - current, - current.pendingProps + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - if ( - 0 === (workInProgress.mode & 2) && - ((nextDidTimeout = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child), - nextDidTimeout !== current.child) - ) - for ( - renderExpirationTime.child = nextDidTimeout; - null !== nextDidTimeout; - - ) - (nextDidTimeout.return = renderExpirationTime), - (nextDidTimeout = nextDidTimeout.sibling); - if (workInProgress.mode & 8) { - nextDidTimeout = 0; - for (current = renderExpirationTime.child; null !== current; ) - (nextDidTimeout += current.treeBaseDuration), - (current = current.sibling); - renderExpirationTime.treeBaseDuration = nextDidTimeout; - } - mode = createWorkInProgress(mode, nextProps); - mode.return = workInProgress; - renderExpirationTime.sibling = mode; - renderExpirationTime.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = renderExpirationTime; - return mode; - } - renderExpirationTime = reconcileChildFibers( + renderLanes = updateSuspensePrimaryChildren( + current, workInProgress, - current.child, nextProps.children, - renderExpirationTime + renderLanes ); workInProgress.memoizedState = null; - return (workInProgress.child = renderExpirationTime); + return renderLanes; } - current = current.child; - if (nextDidTimeout) { - nextDidTimeout = nextProps.fallback; - nextProps = createFiberFromFragment(null, mode, 0, null); - nextProps.return = workInProgress; - nextProps.child = current; - null !== current && (current.return = nextProps); - if (0 === (workInProgress.mode & 2)) - for ( - current = - null !== workInProgress.memoizedState - ? workInProgress.child.child - : workInProgress.child, - nextProps.child = current; - null !== current; - - ) - (current.return = nextProps), (current = current.sibling); - if (workInProgress.mode & 8) { - current = 0; - for (suspenseContext = nextProps.child; null !== suspenseContext; ) - (current += suspenseContext.treeBaseDuration), - (suspenseContext = suspenseContext.sibling); - nextProps.treeBaseDuration = current; - } - renderExpirationTime = createFiberFromFragment( - nextDidTimeout, - mode, - renderExpirationTime, - null + if (showFallback) + return ( + (nextProps = updateSuspenseFallbackChildren( + current, + workInProgress, + nextProps.children, + nextProps.fallback, + renderLanes + )), + (showFallback = workInProgress.child), + (suspenseContext = current.child.memoizedState), + (showFallback.memoizedState = + null === suspenseContext + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), + (showFallback.childLanes = current.childLanes & ~renderLanes), + (workInProgress.memoizedState = SUSPENDED_MARKER), + nextProps ); - renderExpirationTime.return = workInProgress; - nextProps.sibling = renderExpirationTime; - renderExpirationTime.effectTag |= 2; - nextProps.childExpirationTime = 0; - workInProgress.memoizedState = SUSPENDED_MARKER; - workInProgress.child = nextProps; - return renderExpirationTime; - } - workInProgress.memoizedState = null; - return (workInProgress.child = reconcileChildFibers( - workInProgress, + renderLanes = updateSuspensePrimaryChildren( current, + workInProgress, nextProps.children, - renderExpirationTime - )); + renderLanes + ); + workInProgress.memoizedState = null; + return renderLanes; +} +function mountSuspenseFallbackChildren( + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + progressedPrimaryFragment = workInProgress.child; + primaryChildren = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = primaryChildren), + workInProgress.mode & 8 && + ((progressedPrimaryFragment.actualDuration = 0), + (progressedPrimaryFragment.actualStartTime = -1), + (progressedPrimaryFragment.selfBaseDuration = 0), + (progressedPrimaryFragment.treeBaseDuration = 0))) + : (progressedPrimaryFragment = createFiberFromOffscreen( + primaryChildren, + mode, + 0, + null + )); + fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + fallbackChildren.return = workInProgress; + progressedPrimaryFragment.sibling = fallbackChildren; + workInProgress.child = progressedPrimaryFragment; + return fallbackChildren; } -function scheduleWorkOnFiber(fiber, renderExpirationTime) { - fiber.expirationTime < renderExpirationTime && - (fiber.expirationTime = renderExpirationTime); +function updateSuspensePrimaryChildren( + current, + workInProgress, + primaryChildren, + renderLanes +) { + var currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { + mode: "visible", + children: primaryChildren + }); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); + primaryChildren.return = workInProgress; + primaryChildren.sibling = null; + null !== current && + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); + return (workInProgress.child = primaryChildren); +} +function updateSuspenseFallbackChildren( + current, + workInProgress, + primaryChildren, + fallbackChildren, + renderLanes +) { + var mode = workInProgress.mode, + currentPrimaryChildFragment = current.child; + current = currentPrimaryChildFragment.sibling; + var primaryChildProps = { mode: "hidden", children: primaryChildren }; + 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment + ? ((primaryChildren = workInProgress.child), + (primaryChildren.childLanes = 0), + (primaryChildren.pendingProps = primaryChildProps), + workInProgress.mode & 8 && + ((primaryChildren.actualDuration = 0), + (primaryChildren.actualStartTime = -1), + (primaryChildren.selfBaseDuration = + currentPrimaryChildFragment.selfBaseDuration), + (primaryChildren.treeBaseDuration = + currentPrimaryChildFragment.treeBaseDuration)), + (currentPrimaryChildFragment = primaryChildren.lastEffect), + null !== currentPrimaryChildFragment + ? ((workInProgress.firstEffect = primaryChildren.firstEffect), + (workInProgress.lastEffect = currentPrimaryChildFragment), + (currentPrimaryChildFragment.nextEffect = null)) + : (workInProgress.firstEffect = workInProgress.lastEffect = null)) + : (primaryChildren = createWorkInProgress( + currentPrimaryChildFragment, + primaryChildProps + )); + null !== current + ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) + : ((fallbackChildren = createFiberFromFragment( + fallbackChildren, + mode, + renderLanes, + null + )), + (fallbackChildren.flags |= 2)); + fallbackChildren.return = workInProgress; + primaryChildren.return = workInProgress; + primaryChildren.sibling = fallbackChildren; + workInProgress.child = primaryChildren; + return fallbackChildren; +} +function scheduleWorkOnFiber(fiber, renderLanes) { + fiber.lanes |= renderLanes; var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < renderExpirationTime && - (alternate.expirationTime = renderExpirationTime); - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + null !== alternate && (alternate.lanes |= renderLanes); + scheduleWorkOnParentPath(fiber.return, renderLanes); } function initSuspenseListRenderState( workInProgress, @@ -4355,7 +4722,6 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailExpiration: 0, tailMode: tailMode, lastEffect: lastEffectBeforeRendering }) @@ -4364,35 +4730,24 @@ function initSuspenseListRenderState( (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailExpiration = 0), (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime -) { +function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren( - current, - workInProgress, - nextProps.children, - renderExpirationTime - ); + reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.effectTag & 64)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderExpirationTime); - else if (19 === current.tag) - scheduleWorkOnFiber(current, renderExpirationTime); + scheduleWorkOnFiber(current, renderLanes); + else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4414,30 +4769,29 @@ function updateSuspenseListComponent( else switch (revealOrder) { case "forwards": - renderExpirationTime = workInProgress.child; - for (revealOrder = null; null !== renderExpirationTime; ) - (current = renderExpirationTime.alternate), + renderLanes = workInProgress.child; + for (revealOrder = null; null !== renderLanes; ) + (current = renderLanes.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderExpirationTime), - (renderExpirationTime = renderExpirationTime.sibling); - renderExpirationTime = revealOrder; - null === renderExpirationTime + (revealOrder = renderLanes), + (renderLanes = renderLanes.sibling); + renderLanes = revealOrder; + null === renderLanes ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderExpirationTime.sibling), - (renderExpirationTime.sibling = null)); + : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderExpirationTime, + renderLanes, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderExpirationTime = null; + renderLanes = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4446,14 +4800,14 @@ function updateSuspenseListComponent( break; } current = revealOrder.sibling; - revealOrder.sibling = renderExpirationTime; - renderExpirationTime = revealOrder; + revealOrder.sibling = renderLanes; + renderLanes = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderExpirationTime, + renderLanes, null, tailMode, workInProgress.lastEffect @@ -4474,36 +4828,29 @@ function updateSuspenseListComponent( } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime -) { +function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); profilerStartTime = -1; - var updateExpirationTime = workInProgress.expirationTime; - 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); - if (workInProgress.childExpirationTime < renderExpirationTime) return null; - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderExpirationTime = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderExpirationTime; - for ( - renderExpirationTime.return = workInProgress; - null !== current.sibling; - - ) - (current = current.sibling), - (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderExpirationTime.return = workInProgress); - renderExpirationTime.sibling = null; + workInProgressRootSkippedLanes |= workInProgress.lanes; + if (0 !== (renderLanes & workInProgress.childLanes)) { + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderLanes = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderLanes; + for (renderLanes.return = workInProgress; null !== current.sibling; ) + (current = current.sibling), + (renderLanes = renderLanes.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderLanes.return = workInProgress); + renderLanes.sibling = null; + } + return workInProgress.child; } - return workInProgress.child; + return null; } var appendAllChildren, updateHostContainer, @@ -4531,10 +4878,10 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && (requiredContext(contextStackCursor$1.current), (workInProgress.updateQueue = UPDATE_SIGNAL)) && - (workInProgress.effectTag |= 4); + (workInProgress.flags |= 4); }; updateHostText$1 = function(current, workInProgress, oldText, newText) { - oldText !== newText && (workInProgress.effectTag |= 4); + oldText !== newText && (workInProgress.flags |= 4); }; function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { @@ -4550,17 +4897,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var _lastTailNode = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), + for (var lastTailNode$65 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === _lastTailNode + null === lastTailNode$65 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (_lastTailNode.sibling = null); + : (lastTailNode$65.sibling = null); } } -function completeWork(current, workInProgress, renderExpirationTime) { +function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -4581,10 +4928,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - (current = workInProgress.stateNode), - current.pendingContext && - ((current.context = current.pendingContext), - (current.pendingContext = null)), + resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)), + (null !== current && null !== current.child) || + newProps.hydrate || + (workInProgress.flags |= 256), updateHostContainer(workInProgress), null ); @@ -4593,17 +4944,16 @@ function completeWork(current, workInProgress, renderExpirationTime) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderExpirationTime = workInProgress.type; + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderExpirationTime, + renderLanes, newProps, rootContainerInstance ), - current.ref !== workInProgress.ref && - (workInProgress.effectTag |= 128); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4614,22 +4964,22 @@ function completeWork(current, workInProgress, renderExpirationTime) { } requiredContext(contextStackCursor$1.current); current = allocateTag(); - renderExpirationTime = getViewConfigForType(renderExpirationTime); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - renderExpirationTime.validAttributes + renderLanes.validAttributes ); ReactNativePrivateInterface.UIManager.createView( current, - renderExpirationTime.uiViewClassName, + renderLanes.uiViewClassName, rootContainerInstance, updatePayload ); rootContainerInstance = new ReactNativeFiberHostComponent( current, - renderExpirationTime, + renderLanes, workInProgress ); instanceCache.set(current, workInProgress); @@ -4637,8 +4987,8 @@ function completeWork(current, workInProgress, renderExpirationTime) { appendAllChildren(rootContainerInstance, workInProgress, !1, !1); workInProgress.stateNode = rootContainerInstance; finalizeInitialChildren(rootContainerInstance) && - (workInProgress.effectTag |= 4); - null !== workInProgress.ref && (workInProgress.effectTag |= 128); + (workInProgress.flags |= 4); + null !== workInProgress.ref && (workInProgress.flags |= 128); } return null; case 6: @@ -4673,52 +5023,40 @@ function completeWork(current, workInProgress, renderExpirationTime) { case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.effectTag & 64)) + if (0 !== (workInProgress.flags & 64)) return ( - (workInProgress.expirationTime = renderExpirationTime), workInProgress + (workInProgress.lanes = renderLanes), + 0 !== (workInProgress.mode & 8) && + transferActualDuration(workInProgress), + workInProgress ); newProps = null !== newProps; rootContainerInstance = !1; null !== current && - ((renderExpirationTime = current.memoizedState), - (rootContainerInstance = null !== renderExpirationTime), - newProps || - null === renderExpirationTime || - ((renderExpirationTime = current.child.sibling), - null !== renderExpirationTime && - ((updatePayload = workInProgress.firstEffect), - null !== updatePayload - ? ((workInProgress.firstEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = updatePayload)) - : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), - (renderExpirationTime.nextEffect = null)), - (renderExpirationTime.effectTag = 8)))); + (rootContainerInstance = null !== current.memoizedState); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootSuspended); + 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3); else { if ( - workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus ) - workInProgressRootExitStatus = RootSuspendedWithDelay; - 0 !== workInProgressRootNextUnprocessedUpdateTime && - null !== workInProgressRoot && - (markRootSuspendedAtTime( + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || + markRootSuspended$1( workInProgressRoot, - renderExpirationTime$1 - ), - markRootUpdatedAtTime( - workInProgressRoot, - workInProgressRootNextUnprocessedUpdateTime - )); + workInProgressRootRenderLanes + ); } - if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; + if (newProps || rootContainerInstance) workInProgress.flags |= 4; return null; case 4: return popHostContainer(), updateHostContainer(workInProgress), null; @@ -4730,71 +5068,70 @@ function completeWork(current, workInProgress, renderExpirationTime) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (null === newProps) return null; - rootContainerInstance = 0 !== (workInProgress.effectTag & 64); + rootContainerInstance = 0 !== (workInProgress.flags & 64); updatePayload = newProps.rendering; if (null === updatePayload) if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - workInProgressRootExitStatus !== RootIncomplete || - (null !== current && 0 !== (current.effectTag & 64)) + 0 !== workInProgressRootExitStatus || + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.effectTag |= 64; + workInProgress.flags |= 64; cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)); + (workInProgress.flags |= 4)); null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderExpirationTime; + current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (updatePayload = current), - (rootContainerInstance.effectTag &= 2), + (rootContainerInstance.flags &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), - (renderExpirationTime = rootContainerInstance.alternate), - null === renderExpirationTime - ? ((rootContainerInstance.childExpirationTime = 0), - (rootContainerInstance.expirationTime = updatePayload), + (renderLanes = rootContainerInstance.alternate), + null === renderLanes + ? ((rootContainerInstance.childLanes = 0), + (rootContainerInstance.lanes = updatePayload), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), (rootContainerInstance.dependencies = null), + (rootContainerInstance.stateNode = null), (rootContainerInstance.selfBaseDuration = 0), (rootContainerInstance.treeBaseDuration = 0)) - : ((rootContainerInstance.childExpirationTime = - renderExpirationTime.childExpirationTime), - (rootContainerInstance.expirationTime = - renderExpirationTime.expirationTime), - (rootContainerInstance.child = - renderExpirationTime.child), + : ((rootContainerInstance.childLanes = + renderLanes.childLanes), + (rootContainerInstance.lanes = renderLanes.lanes), + (rootContainerInstance.child = renderLanes.child), (rootContainerInstance.memoizedProps = - renderExpirationTime.memoizedProps), + renderLanes.memoizedProps), (rootContainerInstance.memoizedState = - renderExpirationTime.memoizedState), + renderLanes.memoizedState), (rootContainerInstance.updateQueue = - renderExpirationTime.updateQueue), - (updatePayload = renderExpirationTime.dependencies), + renderLanes.updateQueue), + (rootContainerInstance.type = renderLanes.type), + (updatePayload = renderLanes.dependencies), (rootContainerInstance.dependencies = null === updatePayload ? null : { - expirationTime: updatePayload.expirationTime, - firstContext: updatePayload.firstContext, - responders: updatePayload.responders + lanes: updatePayload.lanes, + firstContext: updatePayload.firstContext }), (rootContainerInstance.selfBaseDuration = - renderExpirationTime.selfBaseDuration), + renderLanes.selfBaseDuration), (rootContainerInstance.treeBaseDuration = - renderExpirationTime.treeBaseDuration)), + renderLanes.treeBaseDuration)), (newProps = newProps.sibling); push( suspenseStackCursor, @@ -4804,6 +5141,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { } current = current.sibling; } + null !== newProps.tail && + now() > workInProgressRootRenderTargetTime && + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); } else { if (!rootContainerInstance) @@ -4811,12 +5155,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.effectTag |= 64), + ((workInProgress.flags |= 64), (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), - (workInProgress.effectTag |= 4)), + (workInProgress.flags |= 4)), cutOffTailIfNeeded(newProps, !0), null === newProps.tail && "hidden" === newProps.tailMode && @@ -4829,16 +5173,14 @@ function completeWork(current, workInProgress, renderExpirationTime) { null ); } else - 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1 < renderExpirationTime && - ((workInProgress.effectTag |= 64), + 2 * now() - newProps.renderingStartTime > + workInProgressRootRenderTargetTime && + 1073741824 !== renderLanes && + ((workInProgress.flags |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (current = renderExpirationTime - 1), - (workInProgress.expirationTime = workInProgress.childExpirationTime = current), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [current]) - : spawnedWorkDuringRender.push(current)); + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -4849,9 +5191,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { (newProps.last = updatePayload)); } return null !== newProps.tail - ? (0 === newProps.tailExpiration && - (newProps.tailExpiration = now() + 500), - (current = newProps.tail), + ? ((current = newProps.tail), (newProps.rendering = current), (newProps.tail = current.sibling), (newProps.lastEffect = workInProgress.lastEffect), @@ -4866,6 +5206,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { ), current) : null; + case 23: + case 24: + return ( + popRenderLanes(), + null !== current && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && + "unstable-defer-without-hiding" !== newProps.mode && + (workInProgress.flags |= 4), + null + ); } throw Error( "Unknown unit of work tag (" + @@ -4877,30 +5228,35 @@ function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); - var effectTag = workInProgress.effectTag; - return effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + var flags = workInProgress.flags; + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && + transferActualDuration(workInProgress), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - effectTag = workInProgress.effectTag; - if (0 !== (effectTag & 64)) + resetWorkInProgressVersions(); + flags = workInProgress.flags; + if (0 !== (flags & 64)) throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.effectTag = (effectTag & -4097) | 64; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: return ( pop(suspenseStackCursor), - (effectTag = workInProgress.effectTag), - effectTag & 4096 - ? ((workInProgress.effectTag = (effectTag & -4097) | 64), + (flags = workInProgress.flags), + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && + transferActualDuration(workInProgress), workInProgress) : null ); @@ -4910,6 +5266,9 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 23: + case 24: + return popRenderLanes(), null; default: return null; } @@ -4928,51 +5287,61 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(capturedError) { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( - capturedError - ) && console.error(capturedError.error); -} -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; -function logError(boundary, errorInfo) { - var source = errorInfo.source, - stack = errorInfo.stack; - null === stack && - null !== source && - (stack = getStackByFiberInDevAndProd(source)); - errorInfo = { - componentName: null !== source ? getComponentName(source.type) : null, - componentStack: null !== stack ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: !1, - willRetry: !1 - }; - null !== boundary && - 1 === boundary.tag && - ((errorInfo.errorBoundary = boundary.stateNode), - (errorInfo.errorBoundaryName = getComponentName(boundary.type)), - (errorInfo.errorBoundaryFound = !0), - (errorInfo.willRetry = !0)); +function logCapturedError(boundary, errorInfo) { try { - logCapturedError(errorInfo); + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + componentStack: null !== errorInfo.stack ? errorInfo.stack : "", + error: errorInfo.value, + errorBoundary: + null !== boundary && 1 === boundary.tag ? boundary.stateNode : null + }) && console.error(errorInfo.value); } catch (e) { setTimeout(function() { throw e; }); } } -function safelyCallComponentWillUnmount(current, instance) { - try { - (instance.props = current.memoizedProps), - (instance.state = current.memoizedState), - instance.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, unmountError); +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + lane.payload = { element: null }; + var error = errorInfo.value; + lane.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logCapturedError(fiber, errorInfo); + }; + return lane; +} +function createClassErrorUpdate(fiber, errorInfo, lane) { + lane = createUpdate(-1, lane); + lane.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + lane.payload = function() { + logCapturedError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (lane.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logCapturedError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return lane; } +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -4992,7 +5361,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 22: return; case 1: - if (finishedWork.effectTag & 256 && null !== current) { + if (finishedWork.flags & 256 && null !== current) { var prevProps = current.memoizedProps, prevState = current.memoizedState; current = finishedWork.stateNode; @@ -5006,6 +5375,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: + return; case 5: case 6: case 4: @@ -5016,58 +5386,57 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitHookEffectListUnmount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var destroy = effect.destroy; - effect.destroy = void 0; - void 0 !== destroy && destroy(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} -function commitHookEffectListMount(tag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & tag) === tag) { - var create = effect.create; - effect.destroy = create(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - commitHookEffectListMount(3, finishedWork); + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + if (3 === (finishedRoot.tag & 3)) { + var create$82 = finishedRoot.create; + finishedRoot.destroy = create$82(); + } + finishedRoot = finishedRoot.next; + } while (finishedRoot !== current); + } + current = finishedWork.updateQueue; + current = null !== current ? current.lastEffect : null; + if (null !== current) { + finishedRoot = current = current.next; + do { + var _effect = finishedRoot; + create$82 = _effect.next; + _effect = _effect.tag; + 0 !== (_effect & 4) && + 0 !== (_effect & 1) && + (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), + enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); + finishedRoot = create$82; + } while (finishedRoot !== current); + } return; case 1: finishedRoot = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current) finishedRoot.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - finishedRoot.componentDidUpdate( - prevProps, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ); - } + finishedWork.flags & 4 && + (null === current + ? finishedRoot.componentDidMount() + : ((create$82 = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current.memoizedProps + )), + finishedRoot.componentDidUpdate( + create$82, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ))); current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5094,16 +5463,16 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 4: return; case 12: - prevProps = finishedWork.memoizedProps.onRender; - var commitTime$jscomp$0 = commitTime; - "function" === typeof prevProps && - prevProps( + create$82 = finishedWork.memoizedProps.onRender; + _effect = commitTime; + "function" === typeof create$82 && + create$82( finishedWork.memoizedProps.id, null === current ? "mount" : "update", finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, - commitTime$jscomp$0, + _effect, finishedRoot.memoizedInteractions ); return; @@ -5113,78 +5482,138 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 23: + case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$jscomp$0); - switch (current$jscomp$0.tag) { +function hideOrUnhideAllChildren(finishedWork, isHidden) { + for (var node = finishedWork; ; ) { + if (5 === node.tag) { + var instance = node.stateNode; + if (isHidden) { + var viewConfig = instance.viewConfig; + var updatePayload = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); + } else { + instance = node.stateNode; + updatePayload = node.memoizedProps; + viewConfig = instance.viewConfig; + var prevProps = Object.assign({}, updatePayload, { + style: [updatePayload.style, { display: "none" }] + }); + updatePayload = diffProperties( + null, + prevProps, + updatePayload, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); + } + } else { + if (6 === node.tag) throw Error("Not yet implemented."); + if ( + ((23 !== node.tag && 24 !== node.tag) || + null === node.memoizedState || + node === finishedWork) && + null !== node.child + ) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === finishedWork) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === finishedWork) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +} +function commitUnmount(finishedRoot, current) { + if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) + try { + injectedHook.onCommitFiberUnmount(rendererID, current); + } catch (err) {} + switch (current.tag) { case 0: case 11: case 14: case 15: case 22: - finishedRoot = current$jscomp$0.updateQueue; + finishedRoot = current.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { - var firstEffect = finishedRoot.next; - runWithPriority( - 97 < renderPriorityLevel ? 97 : renderPriorityLevel, - function() { - var effect = firstEffect; - do { - var _destroy = effect.destroy; - if (void 0 !== _destroy) { - var current = current$jscomp$0; - try { - _destroy(); - } catch (error) { - captureCommitPhaseError(current, error); - } + var effect = (finishedRoot = finishedRoot.next); + do { + var _effect2 = effect, + destroy = _effect2.destroy; + _effect2 = _effect2.tag; + if (void 0 !== destroy) + if (0 !== (_effect2 & 4)) + enqueuePendingPassiveHookEffectUnmount(current, effect); + else { + _effect2 = current; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(_effect2, error); } - effect = effect.next; - } while (effect !== firstEffect); - } - ); + } + effect = effect.next; + } while (effect !== finishedRoot); } break; case 1: - safelyDetachRef(current$jscomp$0); - renderPriorityLevel = current$jscomp$0.stateNode; - "function" === typeof renderPriorityLevel.componentWillUnmount && - safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); + safelyDetachRef(current); + finishedRoot = current.stateNode; + if ("function" === typeof finishedRoot.componentWillUnmount) + try { + (finishedRoot.props = current.memoizedProps), + (finishedRoot.state = current.memoizedState), + finishedRoot.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(current, unmountError); + } break; case 5: - safelyDetachRef(current$jscomp$0); + safelyDetachRef(current); break; case 4: - unmountHostComponents( - finishedRoot, - current$jscomp$0, - renderPriorityLevel - ); + unmountHostComponents(finishedRoot, current); } } -function detachFiber(current) { - var alternate = current.alternate; - current.return = null; - current.child = null; - current.memoizedState = null; - current.updateQueue = null; - current.dependencies = null; - current.alternate = null; - current.firstEffect = null; - current.lastEffect = null; - current.pendingProps = null; - current.memoizedProps = null; - current.stateNode = null; - null !== alternate && detachFiber(alternate); +function detachFiberMutation(fiber) { + fiber.alternate = null; + fiber.child = null; + fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.return = null; + fiber.updateQueue = null; } function isHostParent(fiber) { return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; @@ -5192,16 +5621,14 @@ function isHostParent(fiber) { function commitPlacement(finishedWork) { a: { for (var parent = finishedWork.return; null !== parent; ) { - if (isHostParent(parent)) { - var parentFiber = parent; - break a; - } + if (isHostParent(parent)) break a; parent = parent.return; } throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); } + var parentFiber = parent; parent = parentFiber.stateNode; switch (parentFiber.tag) { case 5: @@ -5220,7 +5647,7 @@ function commitPlacement(finishedWork) { "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } - parentFiber.effectTag & 16 && (parentFiber.effectTag &= -17); + parentFiber.flags & 16 && (parentFiber.flags &= -17); a: b: for (parentFiber = finishedWork; ; ) { for (; null === parentFiber.sibling; ) { if (null === parentFiber.return || isHostParent(parentFiber.return)) { @@ -5235,13 +5662,13 @@ function commitPlacement(finishedWork) { 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag; ) { - if (parentFiber.effectTag & 2) continue b; + if (parentFiber.flags & 2) continue b; if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); } - if (!(parentFiber.effectTag & 2)) { + if (!(parentFiber.flags & 2)) { parentFiber = parentFiber.stateNode; break a; } @@ -5336,11 +5763,7 @@ function insertOrAppendPlacementNode(node, before, parent) { ) insertOrAppendPlacementNode(node, before, parent), (node = node.sibling); } -function unmountHostComponents( - finishedRoot$jscomp$0, - current, - renderPriorityLevel$jscomp$0 -) { +function unmountHostComponents(finishedRoot$jscomp$0, current) { for ( var node = current, currentParentIsValid = !1, @@ -5378,13 +5801,12 @@ function unmountHostComponents( a: for ( var finishedRoot = finishedRoot$jscomp$0, root = node, - renderPriorityLevel = renderPriorityLevel$jscomp$0, node$jscomp$0 = root; ; ) if ( - (commitUnmount(finishedRoot, node$jscomp$0, renderPriorityLevel), + (commitUnmount(finishedRoot, node$jscomp$0), null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), @@ -5411,18 +5833,18 @@ function unmountHostComponents( [0] )) : ((finishedRoot = currentParent), - (renderPriorityLevel = node.stateNode), - recursivelyUncacheFiberNode(renderPriorityLevel), + (node$jscomp$0 = node.stateNode), + recursivelyUncacheFiberNode(node$jscomp$0), (root = finishedRoot._children), - (renderPriorityLevel = root.indexOf(renderPriorityLevel)), - root.splice(renderPriorityLevel, 1), + (node$jscomp$0 = root.indexOf(node$jscomp$0)), + root.splice(node$jscomp$0, 1), ReactNativePrivateInterface.UIManager.manageChildren( finishedRoot._nativeTag, [], [], [], [], - [renderPriorityLevel] + [node$jscomp$0] )); } else if (4 === node.tag) { if (null !== node.child) { @@ -5433,8 +5855,7 @@ function unmountHostComponents( continue; } } else if ( - (commitUnmount(finishedRoot$jscomp$0, node, renderPriorityLevel$jscomp$0), - null !== node.child) + (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child) ) { node.child.return = node; node = node.child; @@ -5457,31 +5878,42 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - commitHookEffectListUnmount(3, finishedWork); + var updateQueue = finishedWork.updateQueue; + updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; + if (null !== updateQueue) { + var effect = (updateQueue = updateQueue.next); + do + 3 === (effect.tag & 3) && + ((finishedWork = effect.destroy), + (effect.destroy = void 0), + void 0 !== finishedWork && finishedWork()), + (effect = effect.next); + while (effect !== updateQueue); + } return; case 1: return; case 5: - var instance = finishedWork.stateNode; - if (null != instance) { - var newProps = finishedWork.memoizedProps; - current = null !== current ? current.memoizedProps : newProps; + updateQueue = finishedWork.stateNode; + if (null != updateQueue) { + effect = finishedWork.memoizedProps; + current = null !== current ? current.memoizedProps : effect; var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - ((finishedWork = instance.viewConfig), - instanceProps.set(instance._nativeTag, newProps), - (newProps = diffProperties( + ((finishedWork = updateQueue.viewConfig), + instanceProps.set(updateQueue._nativeTag, effect), + (effect = diffProperties( null, current, - newProps, + effect, finishedWork.validAttributes )), - null != newProps && + null != effect && ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, + updateQueue._nativeTag, finishedWork.uiViewClassName, - newProps + effect )); } return; @@ -5501,72 +5933,9 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - instance = finishedWork; - null === finishedWork.memoizedState - ? (newProps = !1) - : ((newProps = !0), - (instance = finishedWork.child), - (globalMostRecentFallbackTime = now())); - if (null !== instance) - a: for (current = instance; ; ) { - if (5 === current.tag) - if (((updatePayload = current.stateNode), newProps)) { - var viewConfig = updatePayload.viewConfig; - var updatePayload$jscomp$0 = diffProperties( - null, - emptyObject, - { style: { display: "none" } }, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - updatePayload._nativeTag, - viewConfig.uiViewClassName, - updatePayload$jscomp$0 - ); - } else { - updatePayload = current.stateNode; - updatePayload$jscomp$0 = current.memoizedProps; - viewConfig = updatePayload.viewConfig; - var prevProps = Object.assign({}, updatePayload$jscomp$0, { - style: [updatePayload$jscomp$0.style, { display: "none" }] - }); - updatePayload$jscomp$0 = diffProperties( - null, - prevProps, - updatePayload$jscomp$0, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - updatePayload._nativeTag, - viewConfig.uiViewClassName, - updatePayload$jscomp$0 - ); - } - else { - if (6 === current.tag) throw Error("Not yet implemented."); - if ( - 13 === current.tag && - null !== current.memoizedState && - null === current.memoizedState.dehydrated - ) { - updatePayload = current.child.sibling; - updatePayload.return = current; - current = updatePayload; - continue; - } else if (null !== current.child) { - current.child.return = current; - current = current.child; - continue; - } - } - if (current === instance) break; - for (; null === current.sibling; ) { - if (null === current.return || current.return === instance) break a; - current = current.return; - } - current.sibling.return = current.return; - current = current.sibling; - } + null !== finishedWork.memoizedState && + ((globalMostRecentFallbackTime = now()), + hideOrUnhideAllChildren(finishedWork.child, !0)); attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -5574,93 +5943,61 @@ function commitWork(current, finishedWork) { return; case 17: return; + case 23: + case 24: + hideOrUnhideAllChildren( + finishedWork, + null !== finishedWork.memoizedState + ); + return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } function attachSuspenseRetryListeners(finishedWork) { - var thenables = finishedWork.updateQueue; - if (null !== thenables) { + var wakeables = finishedWork.updateQueue; + if (null !== wakeables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - thenables.forEach(function(thenable) { - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - retryCache.has(thenable) || - (!0 !== thenable.__reactDoNotTraceInteractions && + wakeables.forEach(function(wakeable) { + var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + retryCache.has(wakeable) || + (!0 !== wakeable.__reactDoNotTraceInteractions && (retry = tracing.unstable_wrap(retry)), - retryCache.add(thenable), - thenable.then(retry, retry)); + retryCache.add(wakeable), + wakeable.then(retry, retry)); }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - expirationTime.payload = { element: null }; - var error = errorInfo.value; - expirationTime.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logError(fiber, errorInfo); - }; - return expirationTime; -} -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime, null); - expirationTime.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - expirationTime.payload = function() { - logError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; - } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (expirationTime.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return expirationTime; +function isSuspenseBoundaryBeingHidden(current, finishedWork) { + return null !== current && + ((current = current.memoizedState), + null === current || null !== current.dehydrated) + ? ((finishedWork = finishedWork.memoizedState), + null !== finishedWork && null === finishedWork.dehydrated) + : !1; } var ceil = Math.ceil, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - NoContext = 0, - LegacyUnbatchedContext = 8, - RenderContext = 16, - CommitContext = 32, - RootIncomplete = 0, - RootFatalErrored = 1, - RootErrored = 2, - RootSuspended = 3, - RootSuspendedWithDelay = 4, - RootCompleted = 5, - executionContext = NoContext, + executionContext = 0, workInProgressRoot = null, workInProgress = null, - renderExpirationTime$1 = 0, - workInProgressRootExitStatus = RootIncomplete, + workInProgressRootRenderLanes = 0, + subtreeRenderLanes = 0, + subtreeRenderLanesCursor = createCursor(0), + workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, - workInProgressRootLatestProcessedExpirationTime = 1073741823, - workInProgressRootLatestSuspenseTimeout = 1073741823, - workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootNextUnprocessedUpdateTime = 0, - workInProgressRootHasPendingPing = !1, + workInProgressRootIncludedLanes = 0, + workInProgressRootSkippedLanes = 0, + workInProgressRootUpdatedLanes = 0, + workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, - FALLBACK_THROTTLE_MS = 500, + workInProgressRootRenderTargetTime = Infinity, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5668,201 +6005,192 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, - pendingPassiveEffectsExpirationTime = 0, + pendingPassiveEffectsLanes = 0, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, spawnedWorkDuringRender = null, - currentEventTime = 0; -function requestCurrentTimeForUpdate() { - return (executionContext & (RenderContext | CommitContext)) !== NoContext - ? 1073741821 - ((now() / 10) | 0) - : 0 !== currentEventTime + currentEventTime = -1, + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; +function requestEventTime() { + return 0 !== (executionContext & 48) + ? now() + : -1 !== currentEventTime ? currentEventTime - : (currentEventTime = 1073741821 - ((now() / 10) | 0)); + : (currentEventTime = now()); } -function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { +function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1073741823; - var priorityLevel = getCurrentPriorityLevel(); - if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; - if ((executionContext & RenderContext) !== NoContext) - return renderExpirationTime$1; - if (null !== suspenseConfig) - currentTime = - 1073741821 - - 25 * - ((((1073741821 - - currentTime + - (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / - 25) | - 0) + - 1); - else - switch (priorityLevel) { - case 99: - currentTime = 1073741823; - break; - case 98: - currentTime = - 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); - break; - case 97: - case 96: - currentTime = - 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); - break; - case 95: - currentTime = 2; - break; - default: - throw Error("Expected a valid priority level"); - } - null !== workInProgressRoot && - currentTime === renderExpirationTime$1 && - --currentTime; - return currentTime; -} -function scheduleWork(fiber, expirationTime) { + if (0 === (fiber & 2)) return 1; + if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; + 0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes); + if (0 !== ReactCurrentBatchConfig.transition) { + 0 !== currentEventPendingLanes && + (currentEventPendingLanes = + null !== mostRecentlyUpdatedRoot + ? mostRecentlyUpdatedRoot.pendingLanes + : 0); + fiber = currentEventWipLanes; + var lane = 4186112 & ~currentEventPendingLanes; + lane &= -lane; + 0 === lane && + ((fiber = 4186112 & ~fiber), + (lane = fiber & -fiber), + 0 === lane && (lane = 8192)); + return lane; + } + fiber = getCurrentPriorityLevel(); + 0 !== (executionContext & 4) && 98 === fiber + ? (fiber = findUpdateLane(12, currentEventWipLanes)) + : ((fiber = schedulerPriorityToLanePriority(fiber)), + (fiber = findUpdateLane(fiber, currentEventWipLanes))); + return fiber; +} +function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (50 < nestedUpdateCount) throw ((nestedUpdateCount = 0), (rootWithNestedUpdates = null), Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." )); - fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); - if (null !== fiber) { - var priorityLevel = getCurrentPriorityLevel(); - 1073741823 === expirationTime - ? (executionContext & LegacyUnbatchedContext) !== NoContext && - (executionContext & (RenderContext | CommitContext)) === NoContext - ? (schedulePendingInteractions(fiber, expirationTime), - performSyncWorkOnRoot(fiber)) - : (ensureRootIsScheduled(fiber), - schedulePendingInteractions(fiber, expirationTime), - executionContext === NoContext && flushSyncCallbackQueue()) - : (ensureRootIsScheduled(fiber), - schedulePendingInteractions(fiber, expirationTime)); - (executionContext & 4) === NoContext || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) - : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), - (void 0 === priorityLevel || priorityLevel > expirationTime) && - rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); - } -} -function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); - var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < expirationTime && - (alternate.expirationTime = expirationTime); - var node = fiber.return, - root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; - else - for (; null !== node; ) { - alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); - null !== alternate && - alternate.childExpirationTime < expirationTime && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { - root = node.stateNode; - break; + fiber = markUpdateLaneFromFiberToRoot(fiber, lane); + if (null === fiber) return null; + markRootUpdated(fiber, lane, eventTime); + fiber === workInProgressRoot && + ((workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(fiber, workInProgressRootRenderLanes)); + var priorityLevel = getCurrentPriorityLevel(); + 1 === lane + ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) + ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber)) + : (ensureRootIsScheduled(fiber, eventTime), + schedulePendingInteractions(fiber, lane), + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue())) + : (0 === (executionContext & 4) || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) + : rootsWithPendingDiscreteUpdates.add(fiber)), + ensureRootIsScheduled(fiber, eventTime), + schedulePendingInteractions(fiber, lane)); + mostRecentlyUpdatedRoot = fiber; +} +function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + sourceFiber.lanes |= lane; + var alternate = sourceFiber.alternate; + null !== alternate && (alternate.lanes |= lane); + alternate = sourceFiber; + for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) + (sourceFiber.childLanes |= lane), + (alternate = sourceFiber.alternate), + null !== alternate && (alternate.childLanes |= lane), + (alternate = sourceFiber), + (sourceFiber = sourceFiber.return); + return 3 === alternate.tag ? alternate.stateNode : null; +} +function ensureRootIsScheduled(root, currentTime) { + for ( + var existingCallbackNode = root.callbackNode, + suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes; + 0 < lanes; + + ) { + var index$7 = 31 - clz32(lanes), + lane = 1 << index$7, + expirationTime = expirationTimes[index$7]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { + expirationTime = currentTime; + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; + expirationTimes[index$7] = + 10 <= priority + ? expirationTime + 250 + : 6 <= priority + ? expirationTime + 5e3 + : -1; } - node = node.return; - } - null !== root && - (workInProgressRoot === root && - (markUnprocessedUpdateTime(expirationTime), - workInProgressRootExitStatus === RootSuspendedWithDelay && - markRootSuspendedAtTime(root, renderExpirationTime$1)), - markRootUpdatedAtTime(root, expirationTime)); - return root; -} -function getNextRootExpirationTimeToWorkOn(root) { - var lastExpiredTime = root.lastExpiredTime; - if (0 !== lastExpiredTime) return lastExpiredTime; - lastExpiredTime = root.firstPendingTime; - if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; - var lastPingedTime = root.lastPingedTime; - root = root.nextKnownPendingLevel; - root = lastPingedTime > root ? lastPingedTime : root; - return 2 >= root && lastExpiredTime !== root ? 0 : root; -} -function ensureRootIsScheduled(root) { - if (0 !== root.lastExpiredTime) - (root.callbackExpirationTime = 1073741823), - (root.callbackPriority = 99), - (root.callbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - )); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + suspendedLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + currentTime = return_highestLanePriority; + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode), + (root.callbackNode = null), + (root.callbackPriority = 0)); else { - var expirationTime = getNextRootExpirationTimeToWorkOn(root), - existingCallbackNode = root.callbackNode; - if (0 === expirationTime) - null !== existingCallbackNode && - ((root.callbackNode = null), - (root.callbackExpirationTime = 0), - (root.callbackPriority = 90)); - else { - var currentTime = requestCurrentTimeForUpdate(); - currentTime = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); - if (null !== existingCallbackNode) { - var existingCallbackPriority = root.callbackPriority; - if ( - root.callbackExpirationTime === expirationTime && - existingCallbackPriority >= currentTime - ) - return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); - } - root.callbackExpirationTime = expirationTime; - root.callbackPriority = currentTime; - expirationTime = - 1073741823 === expirationTime - ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleCallback( - currentTime, - performConcurrentWorkOnRoot.bind(null, root), - { timeout: 10 * (1073741821 - expirationTime) - now() } - ); - root.callbackNode = expirationTime; + if (null !== existingCallbackNode) { + if (root.callbackPriority === currentTime) return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); } + 15 === currentTime + ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), + null === syncQueue + ? ((syncQueue = [existingCallbackNode]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(existingCallbackNode), + (existingCallbackNode = fakeCallbackNode)) + : 14 === currentTime + ? (existingCallbackNode = scheduleCallback( + 99, + performSyncWorkOnRoot.bind(null, root) + )) + : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), + (existingCallbackNode = scheduleCallback( + existingCallbackNode, + performConcurrentWorkOnRoot.bind(null, root) + ))); + root.callbackPriority = currentTime; + root.callbackNode = existingCallbackNode; } -} -function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = 0; - if (didTimeout) { - didTimeout = requestCurrentTimeForUpdate(); - var lastExpiredTime = root.lastExpiredTime; - if (0 === lastExpiredTime || lastExpiredTime > didTimeout) - root.lastExpiredTime = didTimeout; - ensureRootIsScheduled(root); - return null; - } - lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); - if (0 === lastExpiredTime) return null; - didTimeout = root.callbackNode; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) +} +function performConcurrentWorkOnRoot(root) { + currentEventTime = -1; + currentEventPendingLanes = currentEventWipLanes = 0; + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - flushPassiveEffects(); - var expirationTime = lastExpiredTime, - prevExecutionContext = executionContext; - executionContext |= RenderContext; - var exitStatus = pushDispatcher(); - if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) - prepareFreshStack(root, expirationTime), - startWorkOnPendingInteractions(root, expirationTime); - expirationTime = pushInteractions(root); + var originalCallbackNode = root.callbackNode; + if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + return null; + var lanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : 0 + ); + if (0 === lanes) return null; + var lanes$jscomp$0 = lanes; + var exitStatus = executionContext; + executionContext |= 16; + var prevDispatcher = pushDispatcher(); + if ( + workInProgressRoot !== root || + workInProgressRootRenderLanes !== lanes$jscomp$0 + ) + (workInProgressRootRenderTargetTime = now() + 500), + prepareFreshStack(root, lanes$jscomp$0), + startWorkOnPendingInteractions(root, lanes$jscomp$0); + lanes$jscomp$0 = pushInteractions(root); do try { workLoopConcurrent(); @@ -5872,205 +6200,164 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = expirationTime; - ReactCurrentDispatcher$1.current = exitStatus; - executionContext = prevExecutionContext; + tracing.__interactionsRef.current = lanes$jscomp$0; + ReactCurrentDispatcher$2.current = prevDispatcher; + executionContext = exitStatus; null !== workInProgress - ? (exitStatus = RootIncomplete) + ? (exitStatus = 0) : ((workInProgressRoot = null), + (workInProgressRootRenderLanes = 0), (exitStatus = workInProgressRootExitStatus)); - if (exitStatus !== RootIncomplete) { - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) - throw ((didTimeout = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), - didTimeout); - prevExecutionContext = root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) + prepareFreshStack(root, 0); + else if (0 !== exitStatus) { + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && (root.hydrate = !1), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = root.current.alternate; + root.finishedLanes = lanes; switch (exitStatus) { - case RootIncomplete: - case RootFatalErrored: + case 0: + case 1: throw Error("Root did not complete. This is a bug in React."); - case RootErrored: + case 2: commitRoot(root); break; - case RootSuspended: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - prevExecutionContext - )); + case 3: + markRootSuspended$1(root, lanes); if ( - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - ((prevExecutionContext = - globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), - 10 < prevExecutionContext) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { - if ( - workInProgressRootHasPendingPing && - ((expirationTime = root.lastPingedTime), - 0 === expirationTime || expirationTime >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - expirationTime = getNextRootExpirationTimeToWorkOn(root); - if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; + if (0 !== getNextLanes(root, 0)) break; + prevDispatcher = root.suspendedLanes; + if ((prevDispatcher & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevDispatcher; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - prevExecutionContext + exitStatus ); break; } commitRoot(root); break; - case RootSuspendedWithDelay: - markRootSuspendedAtTime(root, lastExpiredTime); - exitStatus = root.lastSuspendedTime; - lastExpiredTime === exitStatus && - (root.nextKnownPendingLevel = getRemainingExpirationTime( - prevExecutionContext - )); - if ( - workInProgressRootHasPendingPing && - ((prevExecutionContext = root.lastPingedTime), - 0 === prevExecutionContext || prevExecutionContext >= lastExpiredTime) - ) { - root.lastPingedTime = lastExpiredTime; - prepareFreshStack(root, lastExpiredTime); - break; - } - prevExecutionContext = getNextRootExpirationTimeToWorkOn(root); - if ( - 0 !== prevExecutionContext && - prevExecutionContext !== lastExpiredTime - ) - break; - if (0 !== exitStatus && exitStatus !== lastExpiredTime) { - root.lastPingedTime = exitStatus; - break; + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; + for (prevDispatcher = -1; 0 < lanes; ) { + var index$6 = 31 - clz32(lanes); + lanes$jscomp$0 = 1 << index$6; + index$6 = exitStatus[index$6]; + index$6 > prevDispatcher && (prevDispatcher = index$6); + lanes &= ~lanes$jscomp$0; } - 1073741823 !== workInProgressRootLatestSuspenseTimeout - ? (prevExecutionContext = - 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - - now()) - : 1073741823 === workInProgressRootLatestProcessedExpirationTime - ? (prevExecutionContext = 0) - : ((prevExecutionContext = - 10 * - (1073741821 - workInProgressRootLatestProcessedExpirationTime) - - 5e3), - (exitStatus = now()), - (lastExpiredTime = - 10 * (1073741821 - lastExpiredTime) - exitStatus), - (prevExecutionContext = exitStatus - prevExecutionContext), - 0 > prevExecutionContext && (prevExecutionContext = 0), - (prevExecutionContext = - (120 > prevExecutionContext - ? 120 - : 480 > prevExecutionContext - ? 480 - : 1080 > prevExecutionContext - ? 1080 - : 1920 > prevExecutionContext - ? 1920 - : 3e3 > prevExecutionContext - ? 3e3 - : 4320 > prevExecutionContext - ? 4320 - : 1960 * ceil(prevExecutionContext / 1960)) - - prevExecutionContext), - lastExpiredTime < prevExecutionContext && - (prevExecutionContext = lastExpiredTime)); - if (10 < prevExecutionContext) { + lanes = prevDispatcher; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - prevExecutionContext + lanes ); break; } commitRoot(root); break; - case RootCompleted: - if ( - 1073741823 !== workInProgressRootLatestProcessedExpirationTime && - null !== workInProgressRootCanSuspendUsingConfig - ) { - expirationTime = workInProgressRootLatestProcessedExpirationTime; - var suspenseConfig = workInProgressRootCanSuspendUsingConfig; - prevExecutionContext = suspenseConfig.busyMinDurationMs | 0; - 0 >= prevExecutionContext - ? (prevExecutionContext = 0) - : ((exitStatus = suspenseConfig.busyDelayMs | 0), - (expirationTime = - now() - - (10 * (1073741821 - expirationTime) - - (suspenseConfig.timeoutMs | 0 || 5e3))), - (prevExecutionContext = - expirationTime <= exitStatus - ? 0 - : exitStatus + prevExecutionContext - expirationTime)); - if (10 < prevExecutionContext) { - markRootSuspendedAtTime(root, lastExpiredTime); - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - prevExecutionContext - ); - break; - } - } + case 5: commitRoot(root); break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root); - return root.callbackNode === didTimeout + ensureRootIsScheduled(root, now()); + return root.callbackNode === originalCallbackNode ? performConcurrentWorkOnRoot.bind(null, root) : null; } +function markRootSuspended$1(root, suspendedLanes) { + suspendedLanes &= ~workInProgressRootPingedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; + for (root = root.expirationTimes; 0 < suspendedLanes; ) { + var index$11 = 31 - clz32(suspendedLanes), + lane = 1 << index$11; + root[index$11] = -1; + suspendedLanes &= ~lane; + } +} function performSyncWorkOnRoot(root) { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lastExpiredTime = root.lastExpiredTime; - lastExpiredTime = - 0 !== lastExpiredTime - ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime - ? renderExpirationTime$1 - : lastExpiredTime - : 1073741823; - var exitStatus = renderRootSync(root, lastExpiredTime); + if ( + root === workInProgressRoot && + 0 !== (root.expiredLanes & workInProgressRootRenderLanes) + ) { + var lanes = workInProgressRootRenderLanes; + var exitStatus = renderRootSync(root, lanes); + 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && + ((lanes = getNextLanes(root, lanes)), + (exitStatus = renderRootSync(root, lanes))); + } else + (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); 0 !== root.tag && - exitStatus === RootErrored && - ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), - (exitStatus = renderRootSync(root, lastExpiredTime))); - if (exitStatus === RootFatalErrored) + 2 === exitStatus && + ((executionContext |= 64), + root.hydrate && (root.hydrate = !1), + (lanes = getLanesToRetrySynchronouslyOnError(root)), + 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); + if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, lastExpiredTime), - markRootSuspendedAtTime(root, lastExpiredTime), - ensureRootIsScheduled(root), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), exitStatus); root.finishedWork = root.current.alternate; - root.finishedExpirationTime = lastExpiredTime; + root.finishedLanes = lanes; commitRoot(root); - ensureRootIsScheduled(root); + ensureRootIsScheduled(root, now()); return null; } -function prepareFreshStack(root, expirationTime) { +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} +function popRenderLanes() { + subtreeRenderLanes = subtreeRenderLanesCursor.current; + pop(subtreeRenderLanesCursor); +} +function prepareFreshStack(root, lanes) { root.finishedWork = null; - root.finishedExpirationTime = 0; + root.finishedLanes = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -6088,6 +6375,7 @@ function prepareFreshStack(root, expirationTime) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); + resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -6103,26 +6391,28 @@ function prepareFreshStack(root, expirationTime) { break; case 10: popProvider(interruptedWork); + break; + case 23: + case 24: + popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - renderExpirationTime$1 = expirationTime; - workInProgressRootExitStatus = RootIncomplete; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; - workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootNextUnprocessedUpdateTime = 0; - workInProgressRootHasPendingPing = !1; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; spawnedWorkDuringRender = null; } function handleError(root$jscomp$0, thrownValue) { do { + var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) { for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -6132,51 +6422,54 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - renderExpirationTime = 0; + didScheduleRenderPhaseUpdate = !1; + } + renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdate = !1; - if (null === workInProgress || null === workInProgress.return) - return ( - (workInProgressRootExitStatus = RootFatalErrored), - (workInProgressRootFatalError = thrownValue), - (workInProgress = null) - ); - workInProgress.mode & 8 && - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); + didScheduleRenderPhaseUpdateDuringThisPass = !1; + ReactCurrentOwner$2.current = null; + if (null === erroredWork || null === erroredWork.return) { + workInProgressRootExitStatus = 1; + workInProgressRootFatalError = thrownValue; + workInProgress = null; + break; + } + erroredWork.mode & 8 && + stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); a: { var root = root$jscomp$0, - returnFiber = workInProgress.return, - sourceFiber = workInProgress, + returnFiber = erroredWork.return, + sourceFiber = erroredWork, value = thrownValue; - thrownValue = renderExpirationTime$1; - sourceFiber.effectTag |= 2048; + thrownValue = workInProgressRootRenderLanes; + sourceFiber.flags |= 4096; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var thenable = value; + var wakeable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.expirationTime = currentSource.expirationTime)) + (sourceFiber.lanes = currentSource.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - _workInProgress = returnFiber; + workInProgress$77 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === _workInProgress.tag)) { - var nextState = _workInProgress.memoizedState; + if ((JSCompiler_temp = 13 === workInProgress$77.tag)) { + var nextState = workInProgress$77.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = _workInProgress.memoizedProps; + var props = workInProgress$77.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6188,23 +6481,24 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var thenables = _workInProgress.updateQueue; - if (null === thenables) { + var wakeables = workInProgress$77.updateQueue; + if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(thenable); - _workInProgress.updateQueue = updateQueue; - } else thenables.add(thenable); - if (0 === (_workInProgress.mode & 2)) { - _workInProgress.effectTag |= 64; - sourceFiber.effectTag &= -2981; + updateQueue.add(wakeable); + workInProgress$77.updateQueue = updateQueue; + } else wakeables.add(wakeable); + if (0 === (workInProgress$77.mode & 2)) { + workInProgress$77.flags |= 64; + sourceFiber.flags |= 32768; + sourceFiber.flags &= -5029; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(1073741823, null); + var update = createUpdate(-1, 1); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.expirationTime = 1073741823; + sourceFiber.lanes |= 1; break a; } value = void 0; @@ -6213,86 +6507,90 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(thenable, value)) - : ((value = pingCache.get(thenable)), + pingCache.set(wakeable, value)) + : ((value = pingCache.get(wakeable)), void 0 === value && - ((value = new Set()), pingCache.set(thenable, value))); + ((value = new Set()), pingCache.set(wakeable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - thenable, + wakeable, sourceFiber ); - thenable.then(ping, ping); + wakeable.then(ping, ping); } - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; + workInProgress$77.flags |= 8192; + workInProgress$77.lanes = thrownValue; break a; } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$77 = workInProgress$77.return; + } while (null !== workInProgress$77); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); } - workInProgressRootExitStatus !== RootCompleted && - (workInProgressRootExitStatus = RootErrored); + 5 !== workInProgressRootExitStatus && + (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - _workInProgress = returnFiber; + workInProgress$77 = returnFiber; do { - switch (_workInProgress.tag) { + switch (workInProgress$77.tag) { case 3: - thenable = value; - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update = createRootErrorUpdate( - _workInProgress, - thenable, + root = value; + workInProgress$77.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$77.lanes |= thrownValue; + var update$78 = createRootErrorUpdate( + workInProgress$77, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update); + enqueueCapturedUpdate(workInProgress$77, update$78); break a; case 1: - thenable = value; - var ctor = _workInProgress.type, - instance = _workInProgress.stateNode; + root = value; + var ctor = workInProgress$77.type, + instance = workInProgress$77.stateNode; if ( - 0 === (_workInProgress.effectTag & 64) && + 0 === (workInProgress$77.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - _workInProgress.effectTag |= 4096; - _workInProgress.expirationTime = thrownValue; - var _update2 = createClassErrorUpdate( - _workInProgress, - thenable, + workInProgress$77.flags |= 8192; + thrownValue &= -thrownValue; + workInProgress$77.lanes |= thrownValue; + var update$81 = createClassErrorUpdate( + workInProgress$77, + root, thrownValue ); - enqueueCapturedUpdate(_workInProgress, _update2); + enqueueCapturedUpdate(workInProgress$77, update$81); break a; } } - _workInProgress = _workInProgress.return; - } while (null !== _workInProgress); + workInProgress$77 = workInProgress$77.return; + } while (null !== workInProgress$77); } - workInProgress = completeUnitOfWork(workInProgress); + completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; + workInProgress === erroredWork && + null !== erroredWork && + (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$2.current; + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } function pushInteractions(root) { @@ -6300,28 +6598,13 @@ function pushInteractions(root) { tracing.__interactionsRef.current = root.memoizedInteractions; return prevInteractions; } -function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { - expirationTime < workInProgressRootLatestProcessedExpirationTime && - 2 < expirationTime && - (workInProgressRootLatestProcessedExpirationTime = expirationTime); - null !== suspenseConfig && - expirationTime < workInProgressRootLatestSuspenseTimeout && - 2 < expirationTime && - ((workInProgressRootLatestSuspenseTimeout = expirationTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); -} -function markUnprocessedUpdateTime(expirationTime) { - expirationTime > workInProgressRootNextUnprocessedUpdateTime && - (workInProgressRootNextUnprocessedUpdateTime = expirationTime); -} -function renderRootSync(root, expirationTime) { +function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= RenderContext; + executionContext |= 16; var prevDispatcher = pushDispatcher(); - if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) - prepareFreshStack(root, expirationTime), - startWorkOnPendingInteractions(root, expirationTime); - expirationTime = pushInteractions(root); + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) + prepareFreshStack(root, lanes), startWorkOnPendingInteractions(root, lanes); + lanes = pushInteractions(root); do try { workLoopSync(); @@ -6331,187 +6614,197 @@ function renderRootSync(root, expirationTime) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = expirationTime; + tracing.__interactionsRef.current = lanes; executionContext = prevExecutionContext; - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher$2.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; + workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) - workInProgress = performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) performUnitOfWork(workInProgress); } function workLoopConcurrent() { for (; null !== workInProgress && !Scheduler_shouldYield(); ) - workInProgress = performUnitOfWork(workInProgress); + performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; 0 !== (unitOfWork.mode & 8) ? ((profilerStartTime = now$1()), 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), - (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)), + (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)), stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0)) - : (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)); + : (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current && (current = completeUnitOfWork(unitOfWork)); + null === current + ? completeUnitOfWork(unitOfWork) + : (workInProgress = current); ReactCurrentOwner$2.current = null; - return current; } function completeUnitOfWork(unitOfWork) { - workInProgress = unitOfWork; + var completedWork = unitOfWork; do { - var current = workInProgress.alternate; - unitOfWork = workInProgress.return; - if (0 === (workInProgress.effectTag & 2048)) { - if (0 === (workInProgress.mode & 8)) - current = completeWork(current, workInProgress, renderExpirationTime$1); + var current = completedWork.alternate; + unitOfWork = completedWork.return; + if (0 === (completedWork.flags & 4096)) { + if (0 === (completedWork.mode & 8)) + current = completeWork(current, completedWork, subtreeRenderLanes); else { - var fiber = workInProgress; + var fiber = completedWork; profilerStartTime = now$1(); 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); - current = completeWork(current, workInProgress, renderExpirationTime$1); - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + current = completeWork(current, completedWork, subtreeRenderLanes); + stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); + } + if (null !== current) { + workInProgress = current; + return; } - fiber = workInProgress; - if (1 === renderExpirationTime$1 || 1 !== fiber.childExpirationTime) { - var newChildExpirationTime = 0; - if (0 !== (fiber.mode & 8)) { + current = completedWork; + if ( + (24 !== current.tag && 23 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) + ) { + fiber = 0; + if (0 !== (current.mode & 8)) { for ( - var actualDuration = fiber.actualDuration, - treeBaseDuration = fiber.selfBaseDuration, + var actualDuration = current.actualDuration, + treeBaseDuration = current.selfBaseDuration, shouldBubbleActualDurations = - null === fiber.alternate || - fiber.child !== fiber.alternate.child, - child = fiber.child; + null === current.alternate || + current.child !== current.alternate.child, + child = current.child; null !== child; - ) { - var childUpdateExpirationTime = child.expirationTime, - childChildExpirationTime = child.childExpirationTime; - childUpdateExpirationTime > newChildExpirationTime && - (newChildExpirationTime = childUpdateExpirationTime); - childChildExpirationTime > newChildExpirationTime && - (newChildExpirationTime = childChildExpirationTime); - shouldBubbleActualDurations && - (actualDuration += child.actualDuration); - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; - } - fiber.actualDuration = actualDuration; - fiber.treeBaseDuration = treeBaseDuration; + ) + (fiber |= child.lanes | child.childLanes), + shouldBubbleActualDurations && + (actualDuration += child.actualDuration), + (treeBaseDuration += child.treeBaseDuration), + (child = child.sibling); + 13 === current.tag && + null !== current.memoizedState && + ((shouldBubbleActualDurations = current.child), + null !== shouldBubbleActualDurations && + (treeBaseDuration -= + shouldBubbleActualDurations.treeBaseDuration)); + current.actualDuration = actualDuration; + current.treeBaseDuration = treeBaseDuration; } else - for (actualDuration = fiber.child; null !== actualDuration; ) - (treeBaseDuration = actualDuration.expirationTime), - (shouldBubbleActualDurations = - actualDuration.childExpirationTime), - treeBaseDuration > newChildExpirationTime && - (newChildExpirationTime = treeBaseDuration), - shouldBubbleActualDurations > newChildExpirationTime && - (newChildExpirationTime = shouldBubbleActualDurations), + for (actualDuration = current.child; null !== actualDuration; ) + (fiber |= actualDuration.lanes | actualDuration.childLanes), (actualDuration = actualDuration.sibling); - fiber.childExpirationTime = newChildExpirationTime; + current.childLanes = fiber; } - if (null !== current) return current; null !== unitOfWork && - 0 === (unitOfWork.effectTag & 2048) && + 0 === (unitOfWork.flags & 4096) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = workInProgress.firstEffect), - null !== workInProgress.lastEffect && + (unitOfWork.firstEffect = completedWork.firstEffect), + null !== completedWork.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), - (unitOfWork.lastEffect = workInProgress.lastEffect)), - 1 < workInProgress.effectTag && + (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), + (unitOfWork.lastEffect = completedWork.lastEffect)), + 1 < completedWork.flags && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = workInProgress) - : (unitOfWork.firstEffect = workInProgress), - (unitOfWork.lastEffect = workInProgress))); + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { - current = unwindWork(workInProgress); - if (0 !== (workInProgress.mode & 8)) { - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - fiber = workInProgress.actualDuration; - for ( - newChildExpirationTime = workInProgress.child; - null !== newChildExpirationTime; - - ) - (fiber += newChildExpirationTime.actualDuration), - (newChildExpirationTime = newChildExpirationTime.sibling); - workInProgress.actualDuration = fiber; + current = unwindWork(completedWork); + if (null !== current) { + current.flags &= 4095; + workInProgress = current; + return; + } + if (0 !== (completedWork.mode & 8)) { + stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); + current = completedWork.actualDuration; + for (fiber = completedWork.child; null !== fiber; ) + (current += fiber.actualDuration), (fiber = fiber.sibling); + completedWork.actualDuration = current; } - if (null !== current) return (current.effectTag &= 2047), current; null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), - (unitOfWork.effectTag |= 2048)); + (unitOfWork.flags |= 4096)); } - current = workInProgress.sibling; - if (null !== current) return current; - workInProgress = unitOfWork; - } while (null !== workInProgress); - workInProgressRootExitStatus === RootIncomplete && - (workInProgressRootExitStatus = RootCompleted); - return null; -} -function getRemainingExpirationTime(fiber) { - var updateExpirationTime = fiber.expirationTime; - fiber = fiber.childExpirationTime; - return updateExpirationTime > fiber ? updateExpirationTime : fiber; + completedWork = completedWork.sibling; + if (null !== completedWork) { + workInProgress = completedWork; + return; + } + workInProgress = completedWork = unitOfWork; + } while (null !== completedWork); + 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { +function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - var finishedWork = root$jscomp$0.finishedWork, - expirationTime = root$jscomp$0.finishedExpirationTime; + var finishedWork = root.finishedWork, + lanes = root.finishedLanes; if (null === finishedWork) return null; - root$jscomp$0.finishedWork = null; - root$jscomp$0.finishedExpirationTime = 0; - if (finishedWork === root$jscomp$0.current) + root.finishedWork = null; + root.finishedLanes = 0; + if (finishedWork === root.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root$jscomp$0.callbackNode = null; - root$jscomp$0.callbackExpirationTime = 0; - root$jscomp$0.callbackPriority = 90; - root$jscomp$0.nextKnownPendingLevel = 0; - var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( - finishedWork - ); - root$jscomp$0.firstPendingTime = remainingExpirationTimeBeforeCommit; - expirationTime <= root$jscomp$0.lastSuspendedTime - ? (root$jscomp$0.firstSuspendedTime = root$jscomp$0.lastSuspendedTime = root$jscomp$0.nextKnownPendingLevel = 0) - : expirationTime <= root$jscomp$0.firstSuspendedTime && - (root$jscomp$0.firstSuspendedTime = expirationTime - 1); - expirationTime <= root$jscomp$0.lastPingedTime && - (root$jscomp$0.lastPingedTime = 0); - expirationTime <= root$jscomp$0.lastExpiredTime && - (root$jscomp$0.lastExpiredTime = 0); - root$jscomp$0 === workInProgressRoot && + root.callbackNode = null; + var remainingLanes = finishedWork.lanes | finishedWork.childLanes, + remainingLanes$jscomp$0 = remainingLanes, + noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; + root.pendingLanes = remainingLanes$jscomp$0; + root.suspendedLanes = 0; + root.pingedLanes = 0; + root.expiredLanes &= remainingLanes$jscomp$0; + root.mutableReadLanes &= remainingLanes$jscomp$0; + root.entangledLanes &= remainingLanes$jscomp$0; + remainingLanes$jscomp$0 = root.entanglements; + for ( + var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; + 0 < noLongerPendingLanes; + + ) { + var index$12 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$12; + remainingLanes$jscomp$0[index$12] = 0; + eventTimes[index$12] = -1; + expirationTimes[index$12] = -1; + noLongerPendingLanes &= ~lane; + } + null !== rootsWithPendingDiscreteUpdates && + 0 === (remainingLanes & 24) && + rootsWithPendingDiscreteUpdates.has(root) && + rootsWithPendingDiscreteUpdates.delete(root); + root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (renderExpirationTime$1 = 0)); - 1 < finishedWork.effectTag + (workInProgressRootRenderLanes = 0)); + 1 < finishedWork.flags ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (remainingExpirationTimeBeforeCommit = finishedWork) - : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); - if (null !== remainingExpirationTimeBeforeCommit) { - var prevExecutionContext = executionContext; - executionContext |= CommitContext; - var prevInteractions = pushInteractions(root$jscomp$0); - ReactCurrentOwner$2.current = null; - nextEffect = remainingExpirationTimeBeforeCommit; + (remainingLanes = finishedWork.firstEffect)) + : (remainingLanes = finishedWork) + : (remainingLanes = finishedWork.firstEffect); + if (null !== remainingLanes) { + remainingLanes$jscomp$0 = executionContext; + executionContext |= 32; + eventTimes = pushInteractions(root); + focusedInstanceHandle = ReactCurrentOwner$2.current = null; + shouldFireAfterActiveInstanceBlur = !1; + nextEffect = remainingLanes; do try { commitBeforeMutationEffects(); @@ -6521,18 +6814,14 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); + focusedInstanceHandle = null; commitTime = now$1(); - nextEffect = remainingExpirationTimeBeforeCommit; + nextEffect = remainingLanes; do try { - for ( - var root = root$jscomp$0, - renderPriorityLevel = renderPriorityLevel$jscomp$0; - null !== nextEffect; - - ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { + for (expirationTimes = root; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { var current = nextEffect.alternate; if (null !== current) { var currentRef = current.ref; @@ -6542,52 +6831,50 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { : (currentRef.current = null)); } } - switch (effectTag & 1038) { + switch (flags & 1038) { case 2: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; break; case 6: commitPlacement(nextEffect); - nextEffect.effectTag &= -3; + nextEffect.flags &= -3; commitWork(nextEffect.alternate, nextEffect); break; case 1024: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; break; case 1028: - nextEffect.effectTag &= -1025; + nextEffect.flags &= -1025; commitWork(nextEffect.alternate, nextEffect); break; case 4: commitWork(nextEffect.alternate, nextEffect); break; case 8: - var current$jscomp$0 = nextEffect; - unmountHostComponents( - root, - current$jscomp$0, - renderPriorityLevel - ); - detachFiber(current$jscomp$0); + noLongerPendingLanes = nextEffect; + unmountHostComponents(expirationTimes, noLongerPendingLanes); + var alternate = noLongerPendingLanes.alternate; + detachFiberMutation(noLongerPendingLanes); + null !== alternate && detachFiberMutation(alternate); } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$91) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$91); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root$jscomp$0.current = finishedWork; - nextEffect = remainingExpirationTimeBeforeCommit; + root.current = finishedWork; + nextEffect = remainingLanes; do try { - for (effectTag = root$jscomp$0; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - effectTag$jscomp$0 & 36 && - commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); - if (effectTag$jscomp$0 & 128) { + for (flags = root; null !== nextEffect; ) { + var flags$jscomp$0 = nextEffect.flags; + flags$jscomp$0 & 36 && + commitLifeCycles(flags, nextEffect.alternate, nextEffect); + if (flags$jscomp$0 & 128) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { @@ -6606,73 +6893,85 @@ function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { } nextEffect = nextEffect.nextEffect; } - } catch (error) { + } catch (error$92) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error); + captureCommitPhaseError(nextEffect, error$92); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - tracing.__interactionsRef.current = prevInteractions; - executionContext = prevExecutionContext; - } else (root$jscomp$0.current = finishedWork), (commitTime = now$1()); - if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects)) + tracing.__interactionsRef.current = eventTimes; + executionContext = remainingLanes$jscomp$0; + } else (root.current = finishedWork), (commitTime = now$1()); + if ((flags$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root$jscomp$0), - (pendingPassiveEffectsExpirationTime = expirationTime), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$0); + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsLanes = lanes), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel); else - for ( - nextEffect = remainingExpirationTimeBeforeCommit; - null !== nextEffect; - - ) - (renderPriorityLevel$jscomp$0 = nextEffect.nextEffect), + for (nextEffect = remainingLanes; null !== nextEffect; ) + (ref = nextEffect.nextEffect), (nextEffect.nextEffect = null), - (nextEffect = renderPriorityLevel$jscomp$0); - renderPriorityLevel$jscomp$0 = root$jscomp$0.firstPendingTime; - if (0 !== renderPriorityLevel$jscomp$0) { + nextEffect.flags & 8 && + ((instance = nextEffect), + (instance.sibling = null), + (instance.stateNode = null)), + (nextEffect = ref); + remainingLanes = root.pendingLanes; + if (0 !== remainingLanes) { if (null !== spawnedWorkDuringRender) for ( - remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, + ref = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - ref = 0; - ref < remainingExpirationTimeBeforeCommit.length; - ref++ + instance = 0; + instance < ref.length; + instance++ ) - scheduleInteractions( - root$jscomp$0, - remainingExpirationTimeBeforeCommit[ref], - root$jscomp$0.memoizedInteractions - ); - schedulePendingInteractions(root$jscomp$0, renderPriorityLevel$jscomp$0); + scheduleInteractions(root, ref[instance], root.memoizedInteractions); + schedulePendingInteractions(root, remainingLanes); } else legacyErrorBoundariesThatAlreadyFailed = null; - effectTag$jscomp$0 || - finishPendingInteractions(root$jscomp$0, expirationTime); - 1073741823 === renderPriorityLevel$jscomp$0 - ? root$jscomp$0 === rootWithNestedUpdates + flags$jscomp$0 || finishPendingInteractions(root, lanes); + 1 === remainingLanes + ? root === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$0)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode, expirationTime); - ensureRootIsScheduled(root$jscomp$0); + finishedWork = finishedWork.stateNode; + if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) + try { + injectedHook.onCommitFiberRoot( + rendererID, + finishedWork, + renderPriorityLevel, + 64 === (finishedWork.current.flags & 64) + ); + } catch (err) {} + ensureRootIsScheduled(root, now()); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root$jscomp$0 = firstUncaughtError), + (root = firstUncaughtError), (firstUncaughtError = null), - root$jscomp$0); - if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; + root); + if (0 !== (executionContext & 8)) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); - 0 === (effectTag & 512) || + var current = nextEffect.alternate; + shouldFireAfterActiveInstanceBlur || + null === focusedInstanceHandle || + (0 !== (nextEffect.flags & 8) + ? doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0) + : 13 === nextEffect.tag && + isSuspenseBoundaryBeingHidden(current, nextEffect) && + doesFiberContain(nextEffect, focusedInstanceHandle) && + (shouldFireAfterActiveInstanceBlur = !0)); + var flags = nextEffect.flags; + 0 !== (flags & 256) && commitBeforeMutationLifeCycles(current, nextEffect); + 0 === (flags & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback(97, function() { @@ -6691,56 +6990,87 @@ function flushPassiveEffects() { pendingPassiveEffectsRenderPriority = 90; return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } + return !1; +} +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); + rootDoesHavePassiveEffects || + ((rootDoesHavePassiveEffects = !0), + scheduleCallback(97, function() { + flushPassiveEffects(); + return null; + })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects, - expirationTime = pendingPassiveEffectsExpirationTime; + lanes = pendingPassiveEffectsLanes; rootWithPendingPassiveEffects = null; - pendingPassiveEffectsExpirationTime = 0; - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + pendingPassiveEffectsLanes = 0; + if (0 !== (executionContext & 48)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= CommitContext; - for ( - var prevInteractions = pushInteractions(root), - _effect2 = root.current.firstEffect; - null !== _effect2; - - ) { + executionContext |= 32; + var prevInteractions = pushInteractions(root), + unmountEffects = pendingPassiveHookEffectsUnmount; + pendingPassiveHookEffectsUnmount = []; + for (var i = 0; i < unmountEffects.length; i += 2) { + var effect$97 = unmountEffects[i], + fiber = unmountEffects[i + 1], + destroy = effect$97.destroy; + effect$97.destroy = void 0; + if ("function" === typeof destroy) + try { + destroy(); + } catch (error) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error); + } + } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$97 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; try { - var finishedWork = _effect2; - if (0 !== (finishedWork.effectTag & 512)) - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - case 22: - commitHookEffectListUnmount(5, finishedWork), - commitHookEffectListMount(5, finishedWork); - } - } catch (error) { - if (null === _effect2) throw Error("Should be working on an effect."); - captureCommitPhaseError(_effect2, error); + var create$101 = effect$97.create; + effect$97.destroy = create$101(); + } catch (error$102) { + if (null === fiber) throw Error("Should be working on an effect."); + captureCommitPhaseError(fiber, error$102); } - finishedWork = _effect2.nextEffect; - _effect2.nextEffect = null; - _effect2 = finishedWork; } + for (unmountEffects = root.current.firstEffect; null !== unmountEffects; ) + (create$101 = unmountEffects.nextEffect), + (unmountEffects.nextEffect = null), + unmountEffects.flags & 8 && + ((unmountEffects.sibling = null), (unmountEffects.stateNode = null)), + (unmountEffects = create$101); tracing.__interactionsRef.current = prevInteractions; - finishPendingInteractions(root, expirationTime); + finishPendingInteractions(root, lanes); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); enqueueUpdate(rootFiber, sourceFiber); - rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + sourceFiber = requestEventTime(); + rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); null !== rootFiber && - (ensureRootIsScheduled(rootFiber), - schedulePendingInteractions(rootFiber, 1073741823)); + (markRootUpdated(rootFiber, 1, sourceFiber), + ensureRootIsScheduled(rootFiber, sourceFiber), + schedulePendingInteractions(rootFiber, 1)); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -6759,158 +7089,176 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); - null !== fiber && - (ensureRootIsScheduled(fiber), - schedulePendingInteractions(fiber, 1073741823)); + var update = createClassErrorUpdate(fiber, sourceFiber, 1); + enqueueUpdate(fiber, update); + update = requestEventTime(); + fiber = markUpdateLaneFromFiberToRoot(fiber, 1); + if (null !== fiber) + markRootUpdated(fiber, 1, update), + ensureRootIsScheduled(fiber, update), + schedulePendingInteractions(fiber, 1); + else if ( + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)) + ) + try { + instance.componentDidCatch(error, sourceFiber); + } catch (errorToIgnore) {} break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, thenable, suspendedTime) { +function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - workInProgressRoot === root && renderExpirationTime$1 === suspendedTime - ? workInProgressRootExitStatus === RootSuspendedWithDelay || - (workInProgressRootExitStatus === RootSuspended && - 1073741823 === workInProgressRootLatestProcessedExpirationTime && - now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) - ? prepareFreshStack(root, renderExpirationTime$1) - : (workInProgressRootHasPendingPing = !0) - : isRootSuspendedAtTime(root, suspendedTime) && - ((thenable = root.lastPingedTime), - (0 !== thenable && thenable < suspendedTime) || - ((root.lastPingedTime = suspendedTime), - ensureRootIsScheduled(root), - schedulePendingInteractions(root, suspendedTime))); -} -function resolveRetryThenable(boundaryFiber, thenable) { + null !== pingCache && pingCache.delete(wakeable); + wakeable = requestEventTime(); + root.pingedLanes |= root.suspendedLanes & pingedLanes; + workInProgressRoot === root && + (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && + (4 === workInProgressRootExitStatus || + (3 === workInProgressRootExitStatus && + (workInProgressRootRenderLanes & 62914560) === + workInProgressRootRenderLanes && + 500 > now() - globalMostRecentFallbackTime) + ? prepareFreshStack(root, 0) + : (workInProgressRootPingedLanes |= pingedLanes)); + ensureRootIsScheduled(root, wakeable); + schedulePendingInteractions(root, pingedLanes); +} +function resolveRetryWakeable(boundaryFiber, wakeable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(thenable); - thenable = 0; - 0 === thenable && - ((thenable = requestCurrentTimeForUpdate()), - (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); - boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); + null !== retryCache && retryCache.delete(wakeable); + wakeable = 0; + 0 === wakeable && + ((wakeable = boundaryFiber.mode), + 0 === (wakeable & 2) + ? (wakeable = 1) + : 0 === (wakeable & 4) + ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); + retryCache = requestEventTime(); + boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); null !== boundaryFiber && - (ensureRootIsScheduled(boundaryFiber), - schedulePendingInteractions(boundaryFiber, thenable)); + (markRootUpdated(boundaryFiber, wakeable, retryCache), + ensureRootIsScheduled(boundaryFiber, retryCache), + schedulePendingInteractions(boundaryFiber, wakeable)); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; +beginWork$1 = function(current, workInProgress, renderLanes) { + var updateLanes = workInProgress.lanes; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (updateExpirationTime < renderExpirationTime) { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case 10: + updateLanes = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue); + context._currentValue = updateLanes; + break; + case 12: + 0 !== (renderLanes & workInProgress.childLanes) && + (workInProgress.flags |= 4); + updateLanes = workInProgress.stateNode; + updateLanes.effectDuration = 0; + updateLanes.passiveEffectDuration = 0; + break; + case 13: + if (null !== workInProgress.memoizedState) { + if (0 !== (renderLanes & workInProgress.child.childLanes)) + return updateSuspenseComponent( + current, + workInProgress, + renderLanes + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( + current, workInProgress, - workInProgress.stateNode.containerInfo + renderLanes ); - break; - case 10: - updateExpirationTime = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue); - context._currentValue = updateExpirationTime; - break; - case 12: - workInProgress.childExpirationTime >= renderExpirationTime && - (workInProgress.effectTag |= 4); - updateExpirationTime = workInProgress.stateNode; - updateExpirationTime.effectDuration = 0; - updateExpirationTime.passiveEffectDuration = 0; - break; - case 13: - if (null !== workInProgress.memoizedState) { - updateExpirationTime = workInProgress.child.childExpirationTime; - if ( - 0 !== updateExpirationTime && - updateExpirationTime >= renderExpirationTime - ) - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateLanes = 0 !== (renderLanes & workInProgress.childLanes); + if (0 !== (current.flags & 64)) { + if (updateLanes) + return updateSuspenseListComponent( current, workInProgress, - renderExpirationTime + renderLanes ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateExpirationTime = - workInProgress.childExpirationTime >= renderExpirationTime; - if (0 !== (current.effectTag & 64)) { - if (updateExpirationTime) - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), (context.tail = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (!updateExpirationTime) return null; - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderExpirationTime - ); + workInProgress.flags |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), + (context.tail = null), + (context.lastEffect = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (updateLanes) break; + else return null; + case 23: + case 24: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; - workInProgress.expirationTime = 0; + workInProgress.lanes = 0; switch (workInProgress.tag) { case 2: - updateExpirationTime = workInProgress.type; + updateLanes = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderExpirationTime); + prepareToReadContext(workInProgress, renderLanes); context = renderWithHooks( null, workInProgress, - updateExpirationTime, + updateLanes, current, context, - renderExpirationTime + renderLanes ); - workInProgress.effectTag |= 1; + workInProgress.flags |= 1; if ( "object" === typeof context && null !== context && @@ -6920,7 +7268,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateExpirationTime)) { + if (isContextProvider(updateLanes)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -6929,53 +7277,41 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = - updateExpirationTime.getDerivedStateFromProps; + var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateExpirationTime, + updateLanes, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternalFiber = workInProgress; - mountClassInstance( - workInProgress, - updateExpirationTime, - current, - renderExpirationTime - ); + context._reactInternals = workInProgress; + mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, hasContext, - renderExpirationTime + renderLanes ); } else (workInProgress.tag = 0), - reconcileChildren( - null, - workInProgress, - context, - renderExpirationTime - ), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: + context = workInProgress.elementType; a: { - context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); + (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - initializeLazyComponentType(context); - if (1 !== context._status) throw context._result; - context = context._result; + hasContext = context._init; + context = hasContext(context._payload); workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -6986,7 +7322,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 1: @@ -6995,7 +7331,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 11: @@ -7004,7 +7340,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, current, - renderExpirationTime + renderLanes ); break a; case 14: @@ -7013,8 +7349,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, resolveDefaultProps(context.type, current), - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); break a; } @@ -7027,126 +7363,106 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return workInProgress; case 0: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 1: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 3: pushHostRootContext(workInProgress); - updateExpirationTime = workInProgress.updateQueue; - if (null === current || null === updateExpirationTime) + updateLanes = workInProgress.updateQueue; + if (null === current || null === updateLanes) throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); - updateExpirationTime = workInProgress.pendingProps; + updateLanes = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue( - workInProgress, - updateExpirationTime, - null, - renderExpirationTime - ); - updateExpirationTime = workInProgress.memoizedState.element; - updateExpirationTime === context + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes )) - : (reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (updateLanes = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child), - workInProgress + reconcileChildren(current, workInProgress, updateLanes, renderLanes), + workInProgress.child ); case 6: return null; case 13: - return updateSuspenseComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseComponent(current, workInProgress, renderLanes); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (updateLanes = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes )) : reconcileChildren( current, workInProgress, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ), workInProgress.child ); case 11: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, - updateExpirationTime, + updateLanes, context, - renderExpirationTime + renderLanes ) ); case 7: @@ -7155,7 +7471,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps, - renderExpirationTime + renderLanes ), workInProgress.child ); @@ -7165,27 +7481,27 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); case 12: return ( - (workInProgress.effectTag |= 4), - (updateExpirationTime = workInProgress.stateNode), - (updateExpirationTime.effectDuration = 0), - (updateExpirationTime.passiveEffectDuration = 0), + (workInProgress.flags |= 4), + (updateLanes = workInProgress.stateNode), + (updateLanes.effectDuration = 0), + (updateLanes.passiveEffectDuration = 0), reconcileChildren( current, workInProgress, workInProgress.pendingProps.children, - renderExpirationTime + renderLanes ), workInProgress.child ); case 10: a: { - updateExpirationTime = workInProgress.type._context; + updateLanes = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -7197,9 +7513,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === - typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( context$jscomp$0, hasContext ) @@ -7213,7 +7528,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderExpirationTime + renderLanes ); break a; } @@ -7234,25 +7549,24 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { ) { if ( - dependency.context === updateExpirationTime && + dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate(renderExpirationTime, null)), + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.expirationTime < renderExpirationTime && - (context$jscomp$0.expirationTime = renderExpirationTime); + context$jscomp$0.lanes |= renderLanes; dependency = context$jscomp$0.alternate; - null !== dependency && - dependency.expirationTime < renderExpirationTime && - (dependency.expirationTime = renderExpirationTime); + null !== dependency && (dependency.lanes |= renderLanes); scheduleWorkOnParentPath( context$jscomp$0.return, - renderExpirationTime + renderLanes ); - list.expirationTime < renderExpirationTime && - (list.expirationTime = renderExpirationTime); + list.lanes |= renderLanes; break; } dependency = dependency.next; @@ -7290,7 +7604,7 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { current, workInProgress, context.children, - renderExpirationTime + renderLanes ); workInProgress = workInProgress.child; } @@ -7299,17 +7613,12 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateExpirationTime = hasContext.children), - prepareToReadContext(workInProgress, renderExpirationTime), + (updateLanes = hasContext.children), + prepareToReadContext(workInProgress, renderLanes), (context = readContext(context, hasContext.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(context)), - (workInProgress.effectTag |= 1), - reconcileChildren( - current, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), + (updateLanes = updateLanes(context)), + (workInProgress.flags |= 1), + reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: @@ -7325,8 +7634,8 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, context, hasContext, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ) ); case 15: @@ -7335,48 +7644,43 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime + updateLanes, + renderLanes ); case 17: return ( - (updateExpirationTime = workInProgress.type), + (updateLanes = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateExpirationTime + workInProgress.elementType === updateLanes ? context - : resolveDefaultProps(updateExpirationTime, context)), + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), + (workInProgress.flags |= 2)), (workInProgress.tag = 1), - isContextProvider(updateExpirationTime) + isContextProvider(updateLanes) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderExpirationTime), - constructClassInstance(workInProgress, updateExpirationTime, context), - mountClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), + prepareToReadContext(workInProgress, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, - updateExpirationTime, + updateLanes, !0, current, - renderExpirationTime + renderLanes ) ); case 19: - return updateSuspenseListComponent( - current, - workInProgress, - renderExpirationTime - ); + return updateSuspenseListComponent(current, workInProgress, renderLanes); + case 23: + return updateOffscreenComponent(current, workInProgress, renderLanes); + case 24: + return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( "Unknown unit of work tag (" + @@ -7384,16 +7688,21 @@ beginWork$1 = function(current, workInProgress, renderExpirationTime) { "). This error is likely caused by a bug in React. Please file an issue." ); }; -function scheduleInteractions(root, expirationTime, interactions) { +function markSpawnedWork(lane) { + null === spawnedWorkDuringRender + ? (spawnedWorkDuringRender = [lane]) + : spawnedWorkDuringRender.push(lane); +} +function scheduleInteractions(root, lane, interactions) { if (0 < interactions.size) { var pendingInteractionMap = root.pendingInteractionMap, - pendingInteractions = pendingInteractionMap.get(expirationTime); + pendingInteractions = pendingInteractionMap.get(lane); null != pendingInteractions ? interactions.forEach(function(interaction) { pendingInteractions.has(interaction) || interaction.__count++; pendingInteractions.add(interaction); }) - : (pendingInteractionMap.set(expirationTime, new Set(interactions)), + : (pendingInteractionMap.set(lane, new Set(interactions)), interactions.forEach(function(interaction) { interaction.__count++; })); @@ -7401,20 +7710,20 @@ function scheduleInteractions(root, expirationTime, interactions) { if (null !== pendingInteractionMap) pendingInteractionMap.onWorkScheduled( interactions, - 1e3 * expirationTime + root.interactionThreadID + 1e3 * lane + root.interactionThreadID ); } } -function schedulePendingInteractions(root, expirationTime) { - scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); +function schedulePendingInteractions(root, lane) { + scheduleInteractions(root, lane, tracing.__interactionsRef.current); } -function startWorkOnPendingInteractions(root, expirationTime) { +function startWorkOnPendingInteractions(root, lanes) { var interactions = new Set(); root.pendingInteractionMap.forEach(function( scheduledInteractions, - scheduledExpirationTime + scheduledLane ) { - scheduledExpirationTime >= expirationTime && + 0 !== (lanes & scheduledLane) && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -7423,7 +7732,7 @@ function startWorkOnPendingInteractions(root, expirationTime) { if (0 < interactions.size) { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber) { - root = 1e3 * expirationTime + root.interactionThreadID; + root = 1e3 * lanes + root.interactionThreadID; try { subscriber.onWorkStarted(interactions, root); } catch (error) { @@ -7434,14 +7743,14 @@ function startWorkOnPendingInteractions(root, expirationTime) { } } } -function finishPendingInteractions(root, committedExpirationTime) { - var earliestRemainingTimeAfterCommit = root.firstPendingTime; +function finishPendingInteractions(root, committedLanes) { + var remainingLanesAfterCommit = root.pendingLanes; try { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber && 0 < root.memoizedInteractions.size) subscriber.onWorkStopped( root.memoizedInteractions, - 1e3 * committedExpirationTime + root.interactionThreadID + 1e3 * committedLanes + root.interactionThreadID ); } catch (error) { scheduleCallback(99, function() { @@ -7449,54 +7758,23 @@ function finishPendingInteractions(root, committedExpirationTime) { }); } finally { var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - scheduledExpirationTime > earliestRemainingTimeAfterCommit && - (pendingInteractionMap.delete(scheduledExpirationTime), + pendingInteractionMap.forEach(function(scheduledInteractions, lane) { + 0 === (remainingLanesAfterCommit & lane) && + (pendingInteractionMap.delete(lane), scheduledInteractions.forEach(function(interaction) { interaction.__count--; if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { + } catch (error$103) { scheduleCallback(99, function() { - throw error; + throw error$103; }); } })); }); } } -var onCommitFiberRoot = null, - onCommitFiberUnmount = null, - isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__; -function injectInternals(internals) { - if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (hook.isDisabled || !hook.supportsFiber) return !0; - try { - var rendererID = hook.inject(internals); - onCommitFiberRoot = function(root, expirationTime) { - try { - var didError = 64 === (root.current.effectTag & 64), - currentTime = 1073741821 - ((now() / 10) | 0), - priorityLevel = inferPriorityFromExpirationTime( - currentTime, - expirationTime - ); - hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); - } catch (err) {} - }; - onCommitFiberUnmount = function(fiber) { - try { - hook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) {} - }; - } catch (err) {} - return !0; -} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7506,14 +7784,17 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.effectTag = 0; + this.flags = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childExpirationTime = this.expirationTime = 0; + this.childLanes = this.lanes = 0; this.alternate = null; this.actualDuration = 0; this.actualStartTime = -1; this.treeBaseDuration = this.selfBaseDuration = 0; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); @@ -7531,7 +7812,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, @@ -7543,14 +7824,15 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.effectTag = 0), + (workInProgress.type = current.type), + (workInProgress.flags = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.childExpirationTime = current.childExpirationTime; - workInProgress.expirationTime = current.expirationTime; + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7559,11 +7841,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.dependencies = null === pendingProps ? null - : { - expirationTime: pendingProps.expirationTime, - firstContext: pendingProps.firstContext, - responders: pendingProps.responders - }; + : { lanes: pendingProps.lanes, firstContext: pendingProps.firstContext }; workInProgress.sibling = current.sibling; workInProgress.index = current.index; workInProgress.ref = current.ref; @@ -7577,7 +7855,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - expirationTime + lanes ) { var fiberTag = 2; owner = type; @@ -7586,15 +7864,10 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment( - pendingProps.children, - mode, - expirationTime, - key - ); - case REACT_CONCURRENT_MODE_TYPE: + return createFiberFromFragment(pendingProps.children, mode, lanes, key); + case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 7; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7602,26 +7875,35 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(12, pendingProps, key, mode | 8)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), (type.stateNode = { effectDuration: 0, passiveEffectDuration: 0 }), type ); case REACT_SUSPENSE_TYPE: return ( - (type = new FiberNode(13, pendingProps, key, mode)), + (type = createFiber(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = new FiberNode(19, pendingProps, key, mode)), + (type = createFiber(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.expirationTime = expirationTime), + (type.lanes = lanes), + type + ); + case REACT_OFFSCREEN_TYPE: + return createFiberFromOffscreen(pendingProps, mode, lanes, key); + case REACT_LEGACY_HIDDEN_TYPE: + return ( + (type = createFiber(24, pendingProps, key, mode)), + (type.elementType = REACT_LEGACY_HIDDEN_TYPE), + (type.lanes = lanes), type ); default: @@ -7653,30 +7935,36 @@ function createFiberFromTypeAndProps( "." ); } - key = new FiberNode(fiberTag, pendingProps, key, mode); + key = createFiber(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.expirationTime = expirationTime; + key.lanes = lanes; return key; } -function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(7, elements, key, mode); - elements.expirationTime = expirationTime; +function createFiberFromFragment(elements, mode, lanes, key) { + elements = createFiber(7, elements, key, mode); + elements.lanes = lanes; return elements; } -function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); - content.expirationTime = expirationTime; +function createFiberFromOffscreen(pendingProps, mode, lanes, key) { + pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps.elementType = REACT_OFFSCREEN_TYPE; + pendingProps.lanes = lanes; + return pendingProps; +} +function createFiberFromText(content, mode, lanes) { + content = createFiber(6, content, null, mode); + content.lanes = lanes; return content; } -function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( +function createFiberFromPortal(portal, mode, lanes) { + mode = createFiber( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.expirationTime = expirationTime; + mode.lanes = lanes; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -7686,54 +7974,34 @@ function createFiberFromPortal(portal, mode, expirationTime) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; - this.current = null; this.containerInfo = containerInfo; - this.pingCache = this.pendingChildren = null; - this.finishedExpirationTime = 0; - this.finishedWork = null; + this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 90; - this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; + this.callbackPriority = 0; + this.eventTimes = createLaneMap(0); + this.expirationTimes = createLaneMap(-1); + this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; + this.entanglements = createLaneMap(0); this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } -function isRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime; - root = root.lastSuspendedTime; - return ( - 0 !== firstSuspendedTime && - firstSuspendedTime >= expirationTime && - root <= expirationTime - ); -} -function markRootSuspendedAtTime(root, expirationTime) { - var firstSuspendedTime = root.firstSuspendedTime, - lastSuspendedTime = root.lastSuspendedTime; - firstSuspendedTime < expirationTime && - (root.firstSuspendedTime = expirationTime); - if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) - root.lastSuspendedTime = expirationTime; - expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); - expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); -} -function markRootUpdatedAtTime(root, expirationTime) { - expirationTime > root.firstPendingTime && - (root.firstPendingTime = expirationTime); - var firstSuspendedTime = root.firstSuspendedTime; - 0 !== firstSuspendedTime && - (expirationTime >= firstSuspendedTime - ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) - : expirationTime >= root.lastSuspendedTime && - (root.lastSuspendedTime = expirationTime + 1), - expirationTime > root.nextKnownPendingLevel && - (root.nextKnownPendingLevel = expirationTime)); +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findHostInstance(component) { - var fiber = component._reactInternalFiber; + var fiber = component._reactInternals; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -7747,11 +8015,10 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - currentTime = requestCurrentTimeForUpdate(), - suspenseConfig = ReactCurrentBatchConfig.suspense; - currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); + eventTime = requestEventTime(), + lane = requestUpdateLane(current); a: if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; + parentComponent = parentComponent._reactInternals; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -7760,22 +8027,23 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var parentContext = parentComponent; + var JSCompiler_inline_result = parentComponent; do { - switch (parentContext.tag) { + switch (JSCompiler_inline_result.tag) { case 3: - parentContext = parentContext.stateNode.context; + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode.context; break b; case 1: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode + if (isContextProvider(JSCompiler_inline_result.type)) { + JSCompiler_inline_result = + JSCompiler_inline_result.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - parentContext = parentContext.return; - } while (null !== parentContext); + JSCompiler_inline_result = JSCompiler_inline_result.return; + } while (null !== JSCompiler_inline_result); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -7786,34 +8054,26 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - parentContext + JSCompiler_inline_result ); break a; } } - parentComponent = parentContext; + parentComponent = JSCompiler_inline_result; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(currentTime, suspenseConfig); + container = createUpdate(eventTime, lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleWork(current, currentTime); - return currentTime; + scheduleUpdateOnFiber(current, lane, eventTime); + return lane; } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function emptyFindFiberByHostInstance() { + return null; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7842,53 +8102,70 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - executionContext === NoContext && flushSyncCallbackQueue(); + 0 === executionContext && + ((workInProgressRootRenderTargetTime = now() + 500), + flushSyncCallbackQueue()); } }; -var roots = new Map(); -(function(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals({ - bundleType: devToolsConfig.bundleType, - version: devToolsConfig.version, - rendererPackageName: devToolsConfig.rendererPackageName, - rendererConfig: devToolsConfig.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; - }, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null - }); -})({ - findFiberByHostInstance: getInstanceFromTag, - bundleType: 0, - version: "16.13.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } -}); +var roots = new Map(), + devToolsConfig$jscomp$inline_930 = { + findFiberByHostInstance: getInstanceFromTag, + bundleType: 0, + version: "17.0.1-4e5d7faf5", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } + }; +var internals$jscomp$inline_1148 = { + bundleType: devToolsConfig$jscomp$inline_930.bundleType, + version: devToolsConfig$jscomp$inline_930.version, + rendererPackageName: devToolsConfig$jscomp$inline_930.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_930.rendererConfig, + overrideHookState: null, + overrideHookStateDeletePath: null, + overrideHookStateRenamePath: null, + overrideProps: null, + overridePropsDeletePath: null, + overridePropsRenamePath: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: + devToolsConfig$jscomp$inline_930.findFiberByHostInstance || + emptyFindFiberByHostInstance, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null +}; +if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { + var hook$jscomp$inline_1149 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if ( + !hook$jscomp$inline_1149.isDisabled && + hook$jscomp$inline_1149.supportsFiber + ) + try { + (rendererID = hook$jscomp$inline_1149.inject( + internals$jscomp$inline_1148 + )), + (injectedHook = hook$jscomp$inline_1149); + } catch (err) {} +} exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function(reactTag) { return (reactTag = getInstanceFromTag(reactTag)) @@ -7935,12 +8212,17 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var uninitializedFiber = 0; - isDevToolsPresent && (uninitializedFiber |= 8); - uninitializedFiber = new FiberNode(3, null, null, uninitializedFiber); - root.current = uninitializedFiber; - uninitializedFiber.stateNode = root; - initializeUpdateQueue(uninitializedFiber); + var JSCompiler_inline_result = 0; + isDevToolsPresent && (JSCompiler_inline_result |= 8); + JSCompiler_inline_result = createFiber( + 3, + null, + null, + JSCompiler_inline_result + ); + root.current = JSCompiler_inline_result; + JSCompiler_inline_result.stateNode = root; + initializeUpdateQueue(JSCompiler_inline_result); roots.set(containerTag, root); } updateContainer(element, root, null, callback); diff --git a/package.json b/package.json index 20f3a32191a655..333f42b99c5ddc 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "repo-config" ], "peerDependencies": { - "react": "16.13.1" + "react": "17.0.1" }, "dependencies": { "@jest/create-cache-key-function": "^26.5.0", @@ -110,7 +110,7 @@ "react-devtools-core": "^4.6.0", "react-refresh": "^0.4.0", "regenerator-runtime": "^0.13.2", - "scheduler": "0.19.1", + "scheduler": "^0.20.1", "stacktrace-parser": "^0.1.3", "use-subscription": "^1.0.0", "whatwg-fetch": "^3.0.0", @@ -118,7 +118,7 @@ }, "devDependencies": { "flow-bin": "^0.136.0", - "react": "16.13.1" + "react": "17.0.1" }, "detox": { "test-runner": "jest", diff --git a/packages/rn-tester/package.json b/packages/rn-tester/package.json index 189b0e3824743b..167fcd6bc70000 100644 --- a/packages/rn-tester/package.json +++ b/packages/rn-tester/package.json @@ -14,7 +14,7 @@ "nullthrows": "^1.1.1" }, "peerDependencies": { - "react": "16.13.1", + "react": "17.0.1", "react-native": "*" }, "devDependencies": { diff --git a/repo-config/package.json b/repo-config/package.json index 37de5705ec84b0..3f2e4a1f14d4b3 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -39,9 +39,9 @@ "jscodeshift": "^0.11.0", "mkdirp": "^0.5.1", "prettier": "1.19.1", - "react": "16.13.1", - "react-shallow-renderer": "16.13.1", - "react-test-renderer": "16.13.1", + "react": "17.0.1", + "react-shallow-renderer": "16.14.1", + "react-test-renderer": "17.0.1", "shelljs": "^0.7.8", "signedsource": "^1.0.0", "ws": "^6.1.4", diff --git a/template/package.json b/template/package.json index f56c80265cda8c..edf653d6a4a8bb 100644 --- a/template/package.json +++ b/template/package.json @@ -10,7 +10,7 @@ "lint": "eslint ." }, "dependencies": { - "react": "16.13.1", + "react": "17.0.1", "react-native": "1000.0.0" }, "devDependencies": { @@ -21,7 +21,7 @@ "eslint": "^6.5.1", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.63.0", - "react-test-renderer": "16.13.1", + "react-test-renderer": "17.0.1", "react-native-codegen": "0.0.4" }, "jest": { diff --git a/yarn.lock b/yarn.lock index a403779477568f..9c3b986ae39d36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5846,42 +5846,46 @@ react-devtools-core@^4.6.0: shell-quote "^1.6.1" ws "^7" -react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: +react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== +"react-is@^16.12.0 || ^17.0.0", react-is@^17.0.1: + version "17.0.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.1.tgz#5b3531bd76a645a4c9fb6e693ed36419e3301339" + integrity sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA== + react-refresh@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.4.0.tgz#d421f9bd65e0e4b9822a399f14ac56bda9c92292" integrity sha512-bacjSio8GOtzNZKZZM6EWqbhlbb6pr28JWJWFTLwEBKvPIBRo6/Ob68D2EWZA2VyTdQxAh+TRnCYOPNKsQiXTA== -react-shallow-renderer@16.13.1: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.13.1.tgz#4cfd6dc0f05a8d4d261ff7a80e9b88f15491a00a" - integrity sha512-hLmExm5/ZnjodLgm/4oxYw4i7fL6LLPhbO9mF/4tmaZUurtLrp2aSeDHZmRk0SVCHXPz0VaEbb3Dqi5J7odz7Q== +react-shallow-renderer@16.14.1, react-shallow-renderer@^16.13.1: + version "16.14.1" + resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.14.1.tgz#bf0d02df8a519a558fd9b8215442efa5c840e124" + integrity sha512-rkIMcQi01/+kxiTE9D3fdS959U1g7gs+/rborw++42m1O9FAQiNI/UNRZExVUoAOprn4umcXf+pFRou8i4zuBg== dependencies: object-assign "^4.1.1" - react-is "^16.12.0" + react-is "^16.12.0 || ^17.0.0" -react-test-renderer@16.13.1: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.13.1.tgz#de25ea358d9012606de51e012d9742e7f0deabc1" - integrity sha512-Sn2VRyOK2YJJldOqoh8Tn/lWQ+ZiKhyZTPtaO0Q6yNj+QDbmRkVFap6pZPy3YQk8DScRDfyqm/KxKYP9gCMRiQ== +react-test-renderer@17.0.1: + version "17.0.1" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-17.0.1.tgz#3187e636c3063e6ae498aedf21ecf972721574c7" + integrity sha512-/dRae3mj6aObwkjCcxZPlxDFh73XZLgvwhhyON2haZGUEhiaY5EjfAdw+d/rQmlcFwdTpMXCSGVk374QbCTlrA== dependencies: object-assign "^4.1.1" - prop-types "^15.6.2" - react-is "^16.8.6" - scheduler "^0.19.1" + react-is "^17.0.1" + react-shallow-renderer "^16.13.1" + scheduler "^0.20.1" -react@16.13.1: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e" - integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w== +react@17.0.1: + version "17.0.1" + resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127" + integrity sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" - prop-types "^15.6.2" read-pkg-up@^7.0.1: version "7.0.1" @@ -6240,10 +6244,10 @@ saxes@^5.0.0: dependencies: xmlchars "^2.2.0" -scheduler@0.19.1, scheduler@^0.19.1: - version "0.19.1" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196" - integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA== +scheduler@^0.20.1: + version "0.20.1" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.1.tgz#da0b907e24026b01181ecbc75efdc7f27b5a000c" + integrity sha512-LKTe+2xNJBNxu/QhHvDR14wUXHRQbVY5ZOYpOGWRzhydZUqrLb2JBvLPY7cAqFmqrWuDED0Mjk7013SZiOz6Bw== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1"